PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: [NL]trucker on 03 December, 2003, 17:52:27

Title: kick-tempban -ban logger bot????
Post by: [NL]trucker on 03 December, 2003, 17:52:27
hai all

 i really want/need a bot that can log all this.

kick         with reason
tempban with reason
ban         with reason

this with who kicked and time and date.

this all because i get a lot of users asking me why they kicked and i have not any kind of log of that.

i would prefer something like this:

xxxx has kicked/tempbanned/banned [user] at 21-10  at 14.00 hours
reason: wrong files.

and saved in a txt file so no need for commands like showkicklog or something like that..

so if anyon feels up to this challenge......

would be very gratefull.

tia peter.
Title:
Post by: Event_Horizon on 03 December, 2003, 20:48:51
ChannelBot supports this.....

I also use it & no probs here :D

Greez Event_Horizon
Title:
Post by: [NL]trucker on 03 December, 2003, 20:59:06
Event_Horizon

i know that channelbot has this feature built in but i,m quitte happy with my hubsoft .

that is why i wanted this one to be stand-alone

greetz trucker.
Title:
Post by: [NL]trucker on 04 December, 2003, 00:02:39
c,mon folks is someone looking into this?

i wouold hate to see this threat blead to dead
Title:
Post by: plop on 04 December, 2003, 01:46:28
chilla's logger bot ????????
i could say the same again as i did on a couple other requests from you.  lol
don't wanne give optimus 2 much work.
my bot so far all but 1 of your requests.  lol

plop
Title:
Post by: Snoris on 04 December, 2003, 01:56:54
QuoteOriginally posted by [NL]trucker
c,mon folks is someone looking into this?

i wouold hate to see this threat blead to dead

Why dont try to take that part out of CB and try make ur own script??
If u dont know how to script just ask how to do it =))
I dont know jack ( I think altleast:] ) but i could give it a shoot if u like to??
Title:
Post by: [NL]trucker on 04 December, 2003, 02:08:06
plop

chilla,s bot logs a lot and i like it but it doesnt log who kicked who and why.
besides this bot would be a little bit more expanded.
and probably not so expanded as chilla,s bot if you get my drift.

snoris

be my guest m8
even though i have been on lua forum for a while now i,m still further away from scripting then a noob.
Title: Sorry
Post by: Snoris on 05 December, 2003, 12:39:44
Tried some codes but didnt get it to work...Since I have my own hub and Network aswell I cant finish the thing...But hey....I gave it a shoot atleast =]

I hope u get it to work by your self or if someone else might be helpful =))
Title:
Post by: Optimus on 05 December, 2003, 13:11:28
Well duno but here is a Simple start for making the script... It's just a Example to make more

-- Quick logger by Optimus
-- and tested quickly

Bot = "-MMmmm-"

Prefix = "!"
file = "logs.txt"

function Main()
   frmHub:RegBot(Bot)
end

function DataArrival(user,data)
   if( strsub(data, 1, 1) == "<" ) then
      data=strsub(data,1,strlen(data)-1)
      local _,_,cmd = strfind( data, "%b<>%s+(%S+)" )
      if user.bOperator then
         if (cmd == Prefix.."kick" ) then
            doKick(user, data, cmd)
            return 1
         elseif (cmd == Prefix.."ban" ) then
            doBan(user, data, cmd)
            return 1
         end
      end
   end
end

function doKick(user, data, cmd)
   s,e,cmd,Name,reason = strfind( data, "%b<>%s+(%S+)%s+(%S+)%s+(.+)" )

   if reason == nil then
   rsn = "No reason given!"
   s,e,cmd,Name = strfind( data, "%b<>%s+(%S+)%s+(%S+)" )
   else
      rsn = reason
   end

   victim = GetItemByName(Name)

   if victim ~= nil then
   victim:SendData(Bot,"You are being KICKED by "..user.sName.." - Reason: "..reason)
   SendToAll(Bot,"User "..victim.sName.." has been KICKED by "..user.sName.." - Reason: "..reason)
   Writetolog(date("%d").."/"..date("%m").."-"..date("%Y").." "..date("%T").." "..victim.sName.." ("..victim.sIP..") kicked by "..user.sName.." - Reason: "..reason)
   victim:Disconnect()
   return 1
   end
end

function doBan(user, data,cmd)
   s,e,cmd,Name,reason = strfind( data, "%b<>%s+(%S+)%s+(%S+)%s+(.+)" )

   if reason == nil then
   rsn = "No reason given!"
   s,e,cmd,Name = strfind( data, "%b<>%s+(%S+)%s+(%S+)" )
   else
      rsn = reason
   end

   victim = GetItemByName(Name)

   if victim ~= nil then
   victim:SendData(Bot,"You are being BANNED by "..user.sName.." - Reason: "..reason)
   SendToAll(Bot,"User "..victim.sName.." has been BANNED by "..user.sName.." - Reason: "..reason)
   Writetolog(date("%d").."/"..date("%m").."-"..date("%Y").." "..date("%T").." "..victim.sName.." ("..victim.sIP..") banned by "..user.sName.." - Reason: "..reason)
   victim:Ban()
   return 1
   end
end

function Writetolog(what)
   appendto(file)
      write(what.."\n")
   writeto()
end
Title:
Post by: [NL]trucker on 07 December, 2003, 13:50:50
Optimus

thnx m8


i,m gonna try this as soon as i have my comp back.

a liitle idear from a noob

i heard that with elseif a script can be optimized

so i was thinking something like this:

function doKick(user, data, cmd)
elseif
function doBan(user, data, cmd)
s,e,cmd,Name,reason = strfind( data, "%b<>%s+(%S+)%s+(%S+)%s+(.+)" )

this just beeing an idear would it function?

and is it possible to make the mesages show in main only to OPs and above?

i dont like the idear of the chat flooded by kickmessages
it intterupts the chat to much i think.
Title:
Post by: Optimus on 07 December, 2003, 14:15:03
Yups, no prob Trucker will make ya a new 1

Except for this >>>

function doKick(user, data, cmd)
elseif
function doBan(user, data, cmd)

That's not cool
Title:
Post by: Optimus on 07 December, 2003, 14:17:20
Quotedon't wanne give optimus 2 much work.
Mmmm,
Title:
Post by: Optimus on 07 December, 2003, 14:27:41
New 1, Notification ToOps and Above...

Bot = "-MMmmm-"

Prefix = "!"
file = "logs.txt"

function Main()
   frmHub:RegBot(Bot)
end

function DataArrival(user,data)
   if( strsub(data, 1, 1) == "<" ) then
      data=strsub(data,1,strlen(data)-1)
      local _,_,cmd = strfind( data, "%b<>%s+(%S+)" )
      if user.bOperator then
         if (cmd == Prefix.."kick" ) then
            doKick(user, data, cmd)
            return 1
         elseif (cmd == Prefix.."ban" ) then
            doBan(user, data, cmd)
            return 1
         end
      end
   end
end

function doKick(user, data, cmd)
   s,e,cmd,Name,reason = strfind( data, "%b<>%s+(%S+)%s+(%S+)%s+(.+)" )

   if reason == nil then
   rsn = "No reason given!"
   s,e,cmd,Name = strfind( data, "%b<>%s+(%S+)%s+(%S+)" )
   else
      rsn = reason
   end

   victim = GetItemByName(Name)

   if victim ~= nil then
   victim:SendData(Bot,"You are being KICKED by "..user.sName.." - Reason: "..reason)
   SendToOps(Bot,"User "..victim.sName.." has been KICKED by "..user.sName.." - Reason: "..reason)
   Writetolog(date("%d").."/"..date("%m").."-"..date("%Y").." "..date("%T").." "..victim.sName.." ("..victim.sIP..") kicked by "..user.sName.." - Reason: "..reason)
   victim:Disconnect()
   return 1
   end
end

function doBan(user, data,cmd)
   s,e,cmd,Name,reason = strfind( data, "%b<>%s+(%S+)%s+(%S+)%s+(.+)" )

   if reason == nil then
   rsn = "No reason given!"
   s,e,cmd,Name = strfind( data, "%b<>%s+(%S+)%s+(%S+)" )
   else
      rsn = reason
   end

   victim = GetItemByName(Name)

   if victim ~= nil then
   victim:SendData(Bot,"You are being BANNED by "..user.sName.." - Reason: "..reason)
   SendToOps(Bot,"User "..victim.sName.." has been BANNED by "..user.sName.." - Reason: "..reason)
   Writetolog(date("%d").."/"..date("%m").."-"..date("%Y").." "..date("%T").." "..victim.sName.." ("..victim.sIP..") banned by "..user.sName.." - Reason: "..reason)
   victim:Ban()
   return 1
   end
end

function Writetolog(what)
   appendto(file)
      write(what.."\n")
   writeto()
end
Title:
Post by: [NL]trucker on 07 December, 2003, 23:05:31
Thanks Optimus


function doKick(user, data, cmd)
elseif
function doBan(user, data, cmd)

this was just an idear to optimize it all  but i guess it was wrong thinking from my site.

cause now you have a separate thing for kick and ban and have two routines for it

also with the

if reason == nil then
rsn = "No reason given!"
s,e,cmd,Name = strfind( data, "%b<>%s+(%S+)%s+(%S+)" )
else
rsn = reason
end

it is twice in the script i thought it would be an idear to reduce that to one with the command {elseif }

but i gues i still have a lot to learn .

anyway thanks for the script and the effort you made with it.
Title:
Post by: Optimus on 08 December, 2003, 00:45:32
- UPDATE -

Bot = "-MMmmm-"

Prefix = "!"
file = "logs.txt"

function Main()
frmHub:RegBot(Bot)
end

function DataArrival(user,data)
if( strsub(data, 1, 1) == "<" ) then
data=strsub(data,1,strlen(data)-1)
local _,_,cmd = strfind( data, "%b<>%s+(%S+)" )
if user.bOperator then
if (cmd == Prefix.."kick" ) then
doKick(user, data, cmd)
return 1
elseif (cmd == Prefix.."ban" ) then
doBan(user, data, cmd)
return 1
end
end
end
end

function doName_Reason(user, data)
s,e,cmd,Name,reason = strfind( data, "%b<>%s+(%S+)%s+(%S+)%s+(.+)" )
if reason == nil then
rsn = "No reason given!"
s,e,cmd,Name = strfind( data, "%b<>%s+(%S+)%s+(%S+)" )
else
rsn = reason
end
end

function doKick(user, data, cmd)
doName_Reason(user, data)
victim = GetItemByName(Name)
if victim ~= nil then
victim:SendData(Bot,"You are being KICKED by "..user.sName.." - Reason: "..rsn)
SendToOps(Bot,"User "..victim.sName.." has been KICKED by "..user.sName.." - Reason: "..rsn)
Writetolog(date("%d").."/"..date("%m").."-"..date("%Y").." "..date("%T").." "..victim.sName.." ("..victim.sIP..") kicked by "..user.sName.." - Reason: "..rsn)
victim:Disconnect()
return 1
end
end

function doBan(user, data,cmd)
doName_Reason(user, data)
victim = GetItemByName(Name)
if victim ~= nil then
victim:SendData(Bot,"You are being BANNED by "..user.sName.." - Reason: "..rsn)
SendToOps(Bot,"User "..victim.sName.." has been BANNED by "..user.sName.." - Reason: "..rsn)
Writetolog(date("%d").."/"..date("%m").."-"..date("%Y").." "..date("%T").." "..victim.sName.." ("..victim.sIP..") banned by "..user.sName.." - Reason: "..rsn)
victim:Ban()
return 1
end
end

function Writetolog(what)
appendto(file)
write(what.."\n")
writeto()
end

Title:
Post by: [NL]trucker on 08 December, 2003, 19:57:36
thanks optimus

i will test this one soon. :-))
Title:
Post by: [NL]trucker on 08 December, 2003, 22:29:44
optimus

where to put the logs.txt?

i have it now in the same dir as the script but it wont log.
so do  i need a special dir for it?
Title:
Post by: Optimus on 08 December, 2003, 23:37:19
Yes in scripts folder, that's all...

It's working here, please check again

08/12-2003 23:35:07 Test (192.168.1.1) kicked by [SU]Optimus - Reason: No reason given!
Title:
Post by: Troubadour on 21 December, 2003, 01:39:47
[NL]trucker do you mean something like the old kick-log bot like piglja released last year!
If so contact me and i'll send it to you!
It contains it all!

-Troubadour-
Title:
Post by: [NL]trucker on 23 December, 2003, 20:08:22
troubadour

yep something like that m8 i really would love to have it.

if you can give me a addy where to download it it would be perfect as my hub is hosted now for a few.

otherwise you could send it to my mail addy

pfokkink@hotmail.com

thanx m8
Title:
Post by: Spyro on 02 January, 2004, 14:08:21
trie this one:

code:

Bot = "bot_name"

Prefix = "!"
file = "logs.txt"

function Main()
frmHub:RegBot(Bot)
end

function DataArrival(user,data)
if( strsub(data, 1, 1) == "<" ) then
data=strsub(data,1,strlen(data)-1)
local _,_,cmd = strfind( data, "%b<>%s+(%S+)" )
if user.bOperator then
if (cmd == Prefix.."kick" ) then
doKick(user, data, cmd)
return 1
elseif (cmd == Prefix.."ban" ) then
doBan(user, data, cmd)
return 1
end
end
end
end

function doName_Reason(user, data)
s,e,cmd,Name,reason = strfind( data, "%b<>%s+(%S+)%s+(%S+)%s+(.+)" )
if reason == nil then
rsn = "No reason given!"
s,e,cmd,Name = strfind( data, "%b<>%s+(%S+)%s+(%S+)" )
else
rsn = reason
end
end

function doKick(user, data, cmd)
doName_Reason(user, data)
victim = GetItemByName(Name)
if victim ~= nil then
victim:SendData(Bot,"You are being KICKED by "..user.sName.." - Reason: "..rsn)
SendToOps(Bot,"User "..victim.sName.." has been KICKED by "..user.sName.." - Reason: "..rsn)
Writetolog(date("%d").."/"..date("%m").."-"..date("%Y").." "..date("%T").." "..victim.sName.." ("..victim.sIP..") kicked by "..user.sName.." - Reason: "..rsn)
victim:Disconnect()
return 1
end
end

function doBan(user, data,cmd)
doName_Reason(user, data)
victim = GetItemByName(Name)
if victim ~= nil then
victim:SendData(Bot,"You are being BANNED by "..user.sName.." - Reason: "..rsn)
SendToOps(Bot,"User "..victim.sName.." has been BANNED by "..user.sName.." - Reason: "..rsn)
Writetolog(date("%d").."/"..date("%m").."-"..date("%Y").." "..date("%T").." "..victim.sName.." ("..victim.sIP..") banned by "..user.sName.." - Reason: "..rsn)
victim:Ban()
return 1
end
end

function Writetolog(what)
appendto(file)
write(what.."\n")
writeto()
end
Title:
Post by: [NL]trucker on 02 January, 2004, 18:06:58
Spyro


thnx i will tr this one out soon and post any comment back to you.