using $To to block commands and PMs
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

using $To to block commands and PMs

Started by Legion?, 02 December, 2004, 00:58:59

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Legion?

Ok, here is my problem..
I've cobbled this script together from various other ones, and the little that I do know about LUA.
For the most part it works (I know some of it probably isn't the best way to do things though), however, I can't get it to stop PM's to the sHubBotName (being another script I run which has chat commands).
The only command I want to be able to get through are +help from either the main chat, or PM to the bot.

Any help would be much appreciated


   -- SafeOp by Legion? ver 1.1--
   -- Stops OPs from kicking each other
   -- Enables you to log all Kicks/Bans/Drops as well as all registrations and deregistation
   -- Admin can still kick his OPs
   -- Users cannot circumvent gagging by reconnecting, or using hubbot chat commands

sBotName = "OpLog"      -- The Bot Name that shows in the hub
sHubBotName = "BritEliteBot?"  -- Hub Chat Bot name
adminnick = "Legion?"          -- Fill this in with your nick


gaglist = {}

function Main()

  frmHub:RegBot(sBotName)

end
 
function DataArrival(user, data)

 if strsub(data,1,5) == "$Kick"  then
   s,e, Name = strfind(data,"$Kick+%s+(%S+)|")
   victim = GetItemByName(Name)
      if (victim.bOperator) and (user.sName ~= adminnick) then
         user:SendData(sBotName, "*** Don't Kick another operator!")
          SendPmToNick(adminnick, sBotName, "*** " ..user.sName.. " tried to kick the OP " ..victim.sName)
         return 1
      end
       SendPmToNick(adminnick, sBotName, "*** " ..user.sName.. " has kicked " ..victim.sName)
    end
 
 if (strsub(data,1,3) == "$To") then
  if whoTo==sBotName then
    local _,_,whoTo,_,mes = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$(.*)")
    data = strsub(mes,1,strlen(mes)-1)
    HowToSend = "PM"
  else
    return 0
  end
  if whoTo==sHubBotName then
   local _,_,whoTo,com,mes = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$(.*)")
   if gaglist[user.sName] ~= nil then
      if (strlower(com) ~= strlower("+help")) then
         return 1
      end
   end
  end

  elseif (strsub(data,1,1) == "<") then
    data = strsub(data,1,strlen(data)-1)
    HowToSend = "Main"
  else
    return 0

  end

 local _,_,cmd = strfind(data, "%b<>%s+(%S+)")
 local _,_,_,arg1 = strfind(data, "%b<>%s+(%S+)%s+(%S+)")
 local _,_,_,_,arg2 = strfind(data, "%b<>%s+(%S+)%s+(%S+)%s+(.+)")



-- stops users avoiding !gag by PMing the bots,

 if gaglist[user.sName] ~= nil then
    if (strlower(cmd) ~= strlower("+help")) then
       return 1
    end
 end

 if user.bOperator == 1 then  

 if (strlower(cmd) == strlower("!gag")) then
    gaglist[arg1] = "gagged" -- add user to table
 end

 if (strlower(cmd) == strlower("!ungag")) then
   gaglist[arg1] = nil -- remove user to table
 end

 if (strlower(cmd) == strlower("!getgaglist")) then
    user:SendData(sBotName, "GAGLIST:" )
    user:SendData(sBotName, "" )
    for key,a in gaglist do
       user:SendData(sBotName, key)
    end
    user:SendData(sBotName, "" )
    user:SendData(sBotName, "Use !ungag to Ungag" )
    return 1
 end

 if (strlower(cmd) == strlower("!drop")) then
    SendPmToNick(adminnick, sBotName, "*** " ..user.sName.. " has dropped " ..arg1)
 end
 
 if (strlower(cmd) == strlower("!ban")) then
    SendPmToNick(adminnick, sBotName, "*** " ..user.sName.. " has banned " ..arg1)
 end

 if (strlower(cmd) == strlower("!nickban")) then
    SendPmToNick(adminnick, sBotName, "*** " ..user.sName.. " has banned " ..arg1)
 end

 if (strlower(cmd) == strlower("!banip")) then
    SendPmToNick(adminnick, sBotName, "*** " ..user.sName.. " has banned " ..arg1)
 end

 if (strlower(cmd) == strlower("!unban")) then
    SendPmToNick(adminnick, sBotName, "*** " ..user.sName.. " has unbanned " ..arg1)
 end

 if (strlower(cmd) == strlower("!addreguser")) then
    SendPmToNick(adminnick, sBotName, "*** " ..user.sName.. " has registered " ..arg1)
 end

 if (strlower(cmd) == strlower("!delreguser")) then
    SendPmToNick(adminnick, sBotName, "*** " ..user.sName.. " has unregistered " ..arg1)
 end

 if (strlower(cmd) == strlower("!drop")) then
    if arg1 == adminnick then
       return 1
    end
 end

 end

 end


function SendToUser(user, message)
   if HowToSend == "PM" then
      user:SendPM(sBotName, message)
   elseif HowToSend == "Main" then
      user:SendData(sBotName, message)
   end
end

SMF spam blocked by CleanTalk