Author Topic: CmdReport 1.1  (Read 2348 times)

0 Members and 1 Guest are viewing this topic.

Offline Madman

  • Scripter
  • Emperor
  • ******
  • Posts: 1 316
  • Karma: +75/-1
CmdReport 1.1
« on: 08 February, 2008, 18:00:06 »
Code: [Select]
--[[
CmdReport 1.1 LUA 5.1

By American Idiot 03/18/06
Requested by Mikey

Reports command usage to specified nicks
Option to exclude certain nicks from check.

Changes 1.1
Rewritten to new API by Madman 08.02.08

]]--

--Script Configuration
CsCfg = {
Bot = "PtokaX", -- Bot name
Desc = "Command report", -- Bot description
Mail = "help@domain.com", -- Bot email address
ReportTo = { -- Report to these
["Still_Ballin`"] = "main", -- Nicks = Message type
["Sh0rTy"] = "main",
},
Exclude = { -- Exclude these Nicks from check
American Idiot = 1, -- Nick = 1,
YourNick = 1,
},
}

OnStartup = function()
Core.RegBot(CsCfg.Bot, CsCfg.Desc, CsCfg.Mail,true)
--Core.SendToAll(SetMan.GetString(29))
end

ChatArrival = function(user,data)
if not CsCfg.Exclude[user.sNick] then
local msgtype = "Main chat"
local s,e,to = string.find(data,"^$To:%s(%S+)%s+From:")
local s,e,pre = string.find(data,"%b<>%s(%p)")
local s,e,cmd = string.find(data,"%b<>%s%p(%S+)")
local s,e,msg = string.find(data,"%b<>%s%p%w+%s(.+)|$")
if not msg then msg = "" end
if to then msgtype = "Private Message" end
if pre and cmd then
Prefix = GetArgs(SetMan.GetString(29))
for i,v in pairs(Prefix) do
if pre == v then
cmd = pre..cmd
local reply = "The user "..user.sNick.." sent the command "..
"in "..msgtype.." -> "..cmd.." "..msg
for i,v in pairs(CsCfg.ReportTo) do
local usr = Core.GetUser(i)
if usr then
if v == "pm" then
Core.SendPmToUser(usr,CsCfg.Bot,reply)
else
Core.SendToUser(usr,"<"..CsCfg.Bot.. "> " ..reply)
end
end
end
break
end
end
end
end
end

GetArgs = function(data)
local Args = {}
if data then
Args.sMessage = data
for w in string.gmatch(data, "(%p)") do
table.insert(Args,w)
end
if table.getn(Args) > 0 then
return Args
end
end
end

ToArrival = ChatArrival

Quick rewrite, should work...
« Last Edit: 10 February, 2008, 13:31:18 by Madman »
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

PtokaX forum

CmdReport 1.1
« on: 08 February, 2008, 18:00:06 »

Offline Jusper

  • Junior Member
  • **
  • Posts: 18
  • Karma: +11/-1
Re: CmdReport 1.1
« Reply #1 on: 08 February, 2008, 20:25:07 »
i think this script should have an ability to write cmd log.

Offline ThugLife

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
Re: CmdReport 1.1
« Reply #2 on: 08 February, 2008, 21:48:03 »
Thankz Madman. The script is working fine  ;D
Skype: galin93

PtokaX forum

Re: CmdReport 1.1
« Reply #2 on: 08 February, 2008, 21:48:03 »