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