PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: kepp on 10 November, 2003, 17:34:39

Title: Mute
Post by: kepp on 10 November, 2003, 17:34:39
A simple mute script?
on command Mute all or one user?
and unmute all ofcorse
unmute user...

Title:
Post by: Tuben on 10 November, 2003, 18:30:00
Maybe this


--// Made by Tuben --\\

BotName = "-Mute-"

function Main()
frmHub:RegBot(BotName)
LoadMute()
end

Mutes = {}
MuteAll = 1

function LoadMute()
readfrom("Mute.txt")
while 1 do
local line = read()
      if line == nil then
break
else
User = strsub(line, 1, strfind(line, ";")-1)
         Reason = strsub(line, strfind(line, ";")+1,-1)
Mutes[User] = Reason
end
end
readfrom()
         end
function WriteMute()
writeto("Mute.txt")
for User,Reason in Mutes do
write(User..";"..Reason.."\r\n")
end
writeto()
end
function GetArgs2(sdata)
local _,_, arg1,arg2 = strfind(sdata,"%S+%s+%S+%s+(%S+)%s+(.*)")
return arg1,arg2
      end  
function GetArgs5(sdata)
local _,_, arg4,arg5 = strfind(sdata,"$To:%s+%S+%s+From:%s+%S+%s+$%S+%s+%S+%s+(%S+)%s+(.*)")
return arg4,arg5
      end
function GetArgs1(sdata)
local _,_, arg1 = strfind(sdata,"%s+%S+%s+(.+)")
return arg1
      end
function GetArgs4(sdata)
local _,_, arg4 = strfind(sdata,"$To:%s+%S+%s+From:%s+%S+%s+$%S+%s+%S+%s+(.*)")
return arg4
      end
function DataArrival(curUser,sdata)
if (strsub(sdata,1,4) == "$To:") or strfind(sdata,"<")  then
  sdata = strsub(sdata,1,-2)
  local _,_,   check,cmd = strfind(sdata,"$To:+%s+(%S+)%s+From:+%s+%S+%s+$+%S+%s+(%S+)")
  local _,_,   cmd = strfind(sdata,"%b<>%s+(%S+)")
if (check == Bot_Name) or (strsub(sdata,1,1) ~= "$") and curUser.bOperator then
if (cmd=="+mute") then
  DoMute(curUser,sdata)
  return 1
elseif (cmd=="+unmute") then
   DoUnMute(curUser,sdata)
   return 1
elseif (cmd=="+muteall") then
   DoMuteAll(curUser)
   return 1
   end
                    end
                    end  
if (strsub(sdata,1,1) == "<") and not curUser.bOperator then
  if MuteAll == 0 then
                      return 1;
                      else
                      return 0;
     end                    
                      sdata=strsub(sdata,1,-2)
     local _,_, User = strfind(sdata,"<(%S+)>%s+.*")  
     for i,n in Mutes do
if i == User then
curUser:SendData(BotName,"You are banned from the main chat beacuse: "..n)
return 1
                    end
       end
               end
                                end
 function DoMute(curUser,sdata)
if strsub(sdata,1,4) == "$To:" then
  arg1,arg2 = GetArgs5(sdata)
          else
  arg1,arg2 = GetArgs2(sdata)
                  end
   if arg1~=nil and arg2~=nil then
Mutes[arg1] = arg2
WriteMute()
curUser:SendData(BotName,"User: "..arg1.." is now muted from main chat bacuse: "..arg2);
               end
                                        end
function DoUnMute(curUser,sdata)
        if strsub(sdata,1,4) == "$To:" then
    arg1 = GetArgs4(sdata)
                          else
                  arg1 = GetArgs1(sdata)
                                  end
    if arg1~=nil then
          Mutes[arg1] = nil
          WriteMute()
          curUser:SendData(BotName,"User: "..arg1.." is now unmuted");
                          end
                                                   end
                                       function DoMuteAll(curUser)
if MuteAll == 1 then
                                                   MuteAll = 0
                                                   SendToAll(BotName,"The chat is now muted.")
  return 1
elseif MuteAll == 0 then
                                                   MuteAll = 1
                                                   SendToAll(BotName,"The chat can now be used.")
  return 1
                      end
                                                   end  



And then create a txt whit the name "Mute.txt" in the
same folder as the script.

And write in the first line in Mute.txt Users;Reason

"Edit"

Commandsen ?r:

+mute
+unmute

"EDIT2" fuck

Forgot muteall ;)

I have changed the script.

+muteall type +muteall agin too unmuteall ;)
+mute
+unmute

And it is only for ops and it mutes not ops only evrybody else
Title:
Post by: kepp on 20 November, 2003, 17:27:45
Tack tack Tuben :)