can anyone help me finish converting this seen bot please.
can it be changed to send answers in pm please. heres the script
BotName = "LeonBot"
SeenTrigger = "!seen"
minLen = 2
maxLen = 20
seenArray={}
function Main()
frmHub:RegBot(BotName)
end
function NewUserConnected(curUser)
local boolDisc = 0
if string.len(curUser.sName) < minLen then
curUser:SendPM(BotName, "Your nick is to short, a minimum of "..minLen.." chars is required!")
curUser:SendPM(BotName, "Disconnecting...")
curUser:Disconnect()
boolDisc = 1
elseif string.len(curUser.sName) > maxLen then
curUser:SendPM(BotName, "Your nick is to long, a maximum of "..maxLen.." chars is required!")
curUser:SendPM(BotName, "Disconnecting...")
curUser:Disconnect()
boolDisc = 1
elseif ( string.find (curUser.sName, " ", 1, 1) ) then
curUser:SendPM(BotName, "Spaces not allowed in nicknames!")
curUser:SendPM(BotName, "Disconnecting...")
curUser:Disconnect()
boolDisc = 1
end
if (boolDisc == 0) then
seenArray[curUser.sName]=os.date(curUser.sName.." connected at %d/%m/%Y %T and is still here.")
end
end
function OpConnected(curUser)
seenArray[curUser.sName]=os.date(curUser.sName.." connected at %d/%m/%Y %T and is still here.")
end
function OpDisconnected(curUser)
seenArray[curUser.sName]=os.date(curUser.sName.." disconnected at %d/%m/%Y %T and has not been seen since.")
end
function UserDisconnected(curUser)
seenArray[curUser.sName]=os.date(curUser.sName.." disconnected at %d/%m/%Y %T and has not been seen since.")
end
function DataArrival(curUser, data)
seenArray[curUser.sName]=os.date(curUser.sName.." was last seen at %d/%m/%Y %T writing things.")
if( string.sub(data, 1, 1) == "<" ) then
data=string.sub(data,1,string.len(data)-1)
_,_,cmd,arg = string.find( data, "%b<>%s+(%S+)%s+(%S+)" )
if (cmd == SeenTrigger) then
if (arg == curUser.sName) then
SendToAll(BotName, "You should not do #seen's for yourself ;)" )
elseif (seenArray[arg] ~= nil) then
SendToAll(BotName, "User: "..seenArray[arg] )
else
SendToAll(BotName, "I have not seen "..arg.."!" )
end
end
end
end
[COLOR=red]function DataArrival(curUser, data) [/COLOR]
seenArray[curUser.sName]=os.date(curUser.sName.." was last seen at %d/%m/%Y %T writing things.")
[COLOR=blue]if( string.sub(data, 1, 1) == "<" ) then[/COLOR]
data=string.sub(data,1,string.len(data)-1)
_,_,cmd,arg = string.find( data, "%b<>%s+(%S+)%s+(%+)" )
if (cmd == SeenTrigger) then
if (arg == curUser.sName) then
[COLOR=red]SendToAll(BotName, "You should not do #seen's for yourself ;)" ) [/COLOR]
elseif (seenArray[arg] ~= nil) then
[COLOR=red]SendToAll(BotName, "User: "..seenArray[arg] ) [/COLOR]
else
[COLOR=red]SendToAll(BotName, "I have not seen "..arg.."!" ) [/COLOR]
[COLOR=blue]end [/COLOR]
end
end
end
yap sure, change the lines in red as follows:
Change from DataArrival to ChatArrival
Change from SendToAll to curUser:SendPM
and delete the lines in blue
Good luck !
changed and deleted lines but for some reason still dont wonna work. no errors comeing up to any thoughts
try this [ not tested ]:
BotName = "LeonBot"
SeenTrigger = "!seen"
minLen = 2
maxLen = 20
seenArray={}
function Main()
frmHub:RegBot(BotName)
end
function NewUserConnected(curUser)
local boolDisc = 0
if string.len(curUser.sName) < minLen then
curUser:SendPM(BotName, "Your nick is to short, a minimum of "..minLen.." chars is required!")
curUser:SendPM(BotName, "Disconnecting...")
curUser:Disconnect()
boolDisc = 1
elseif string.len(curUser.sName) > maxLen then
curUser:SendPM(BotName, "Your nick is to long, a maximum of "..maxLen.." chars is required!")
curUser:SendPM(BotName, "Disconnecting...")
curUser:Disconnect()
boolDisc = 1
elseif ( string.find (curUser.sName, " ", 1, 1) ) then
curUser:SendPM(BotName, "Spaces not allowed in nicknames!")
curUser:SendPM(BotName, "Disconnecting...")
curUser:Disconnect()
boolDisc = 1
end
if (boolDisc == 0) then
seenArray[curUser.sName]=os.date(curUser.sName.." connected at %d/%m/%Y %T and is still here.")
end
end
function OpConnected(curUser)
seenArray[curUser.sName]=os.date(curUser.sName.." connected at %d/%m/%Y %T and is still here.")
end
function OpDisconnected(curUser)
seenArray[curUser.sName]=os.date(curUser.sName.." disconnected at %d/%m/%Y %T and has not been seen since.")
end
function UserDisconnected(curUser)
seenArray[curUser.sName]=os.date(curUser.sName.." disconnected at %d/%m/%Y %T and has not been seen since.")
end
function ChatArrival(curUser, data)
seenArray[curUser.sName]=os.date(curUser.sName.." was last seen at %d/%m/%Y %T writing things.")
data=string.sub(data,1,string.len(data)-1)
_,_,cmd,arg = string.find( data, "%b<>%s+(%S+)%s+(%S+)" )
if (cmd == SeenTrigger) then
if (arg == curUser.sName) then
curUser:SendPM(BotName, "You should not do #seen's for yourself ;)" )
elseif (seenArray[arg] ~= nil) then
curUser:SendPM(BotName, "User: "..seenArray[arg] )
else
curUser:SendPM(BotName, "I have not seen "..arg.."!" )
end
end
end
c ya
thx for the help this script works but can i stop it from posting the command and who you are seeing in main
as i have users with nicks like [DH]damo then sends the pm like its suposed to but also sends the command and user name to main
Nice script. But can you guys also ad something like this?
howToSend = 2, -- 1:Sends to all / 2:Sends to user / 3:PM to the user / 4:PM to the user and regs a bot.
:)
Thanks in advance :D
-- Creator Leon
-- Started lua 5 conversion, damo
-- Fully converted to lua 5 by 6Marilyn6Manson6
---- Modded By Madman
-- Added save to file
-- Added HowToSend, request by Ubikk
-- Hidden the command, request by damo
BotName = "LeonBot"
SeenTrigger = "!seen"
minLen = 2
maxLen = 20
HowToSend = 3 -- 1: Send to all, 2: Send to user, 3: PM to the user
require("seen.dat")
function Main()
if HowToSend == 3 then
frmHub:RegBot(BotName)
end
end
function NewUserConnected(curUser)
local boolDisc = 0
if string.len(curUser.sName) < minLen then
curUser:SendPM(BotName, "Your nick is to short, a minimum of "..minLen.." chars is required!")
curUser:SendPM(BotName, "Disconnecting...")
curUser:Disconnect()
boolDisc = 1
elseif string.len(curUser.sName) > maxLen then
curUser:SendPM(BotName, "Your nick is to long, a maximum of "..maxLen.." chars is required!")
curUser:SendPM(BotName, "Disconnecting...")
curUser:Disconnect()
boolDisc = 1
elseif ( string.find (curUser.sName, " ", 1, 1) ) then
curUser:SendPM(BotName, "Spaces not allowed in nicknames!")
curUser:SendPM(BotName, "Disconnecting...")
curUser:Disconnect()
boolDisc = 1
end
if (boolDisc == 0) then
if seenArray[curUser.sName] == nil then
seenArray[curUser.sName] = {}
seenArray[curUser.sName] = os.date(curUser.sName.." connected at %d/%m/%Y %T and is still here.")
SaveToFile("Seen.dat", seenArray, "seenArray")
else
seenArray[curUser.sName] = os.date(curUser.sName.." connected at %d/%m/%Y %T and is still here.")
SaveToFile("Seen.dat", seenArray, "seenArray")
end
end
end
function OpConnected(curUser)
if seenArray[curUser.sName] == nil then
seenArray[curUser.sName] = {}
seenArray[curUser.sName] = os.date(curUser.sName.." connected at %d/%m/%Y %T and is still here.")
SaveToFile("Seen.dat", seenArray, "seenArray")
else
seenArray[curUser.sName] = os.date(curUser.sName.." connected at %d/%m/%Y %T and is still here.")
SaveToFile("Seen.dat", seenArray, "seenArray")
end
end
function OpDisconnected(curUser)
if seenArray[curUser.sName] == nil then
seenArray[curUser.sName] = {}
seenArray[curUser.sName] = os.date(curUser.sName.." disconnected at %d/%m/%Y %T and has not been seen since.")
SaveToFile("Seen.dat", seenArray, "seenArray")
else
seenArray[curUser.sName] = os.date(curUser.sName.." disconnected at %d/%m/%Y %T and has not been seen since.")
SaveToFile("Seen.dat", seenArray, "seenArray")
end
end
UserDisconnected = OpDisconnected
function ChatArrival(curUser, data)
if seenArray[curUser.sName] == nil then
seenArray[curUser.sName] = {}
seenArray[curUser.sName] = os.date(curUser.sName.." was last seen at %d/%m/%Y %T writing things.")
SaveToFile("Seen.dat", seenArray, "seenArray")
else
seenArray[curUser.sName] = os.date(curUser.sName.." was last seen at %d/%m/%Y %T writing things.")
SaveToFile("Seen.dat", seenArray, "seenArray")
end
data=string.sub(data,1,string.len(data)-1)
_,_,cmd,arg = string.find( data, "%b<>%s+(%S+)%s+(%S+)" )
if (cmd == SeenTrigger) then
if (arg == curUser.sName) then
if HowToSend == 1 then
SendToAll(BotName, "You should not do #seen's for yourself " ..curUser.sName.. " ;)" )
elseif HowToSend == 2 then
curUser:SendData(BotName, "You should not do #seen's for yourself " ..curUser.sName.. " ;)" )
elseif HowToSend == 3 then
curUser:SendPM(BotName, "You should not do #seen's for yourself " ..curUser.sName.. " ;)" )
end
elseif (seenArray[arg] ~= nil) then
if HowToSend == 1 then
SendToAll(BotName, "User: "..seenArray[arg] )
elseif HowToSend == 2 then
curUser:SendData(BotName, "User: "..seenArray[arg] )
elseif HowToSend == 3 then
curUser:SendPM(BotName, "User: "..seenArray[arg] )
end
else
if HowToSend == 1 then
SendToAll(BotName, "I have not seen "..arg.."!" )
elseif HowToSend == 2 then
curUser:SendData(BotName, "I have not seen "..arg.."!" )
elseif HowToSend == 3 then
curUser:SendPM(BotName, "I have not seen "..arg.."!" )
end
end
return 1
end
end
function Serialize(tTable, sTableName, sTab)
assert(tTable, "tTable equals nil");
assert(sTableName, "sTableName equals nil");
assert(type(tTable) == "table", "tTable must be a table!");
assert(type(sTableName) == "string", "sTableName must be a string!");
sTab = sTab or "";
sTmp = ""
sTmp = sTmp..sTab..sTableName.." = {\n"
for key, value in tTable do
local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key);
if(type(value) == "table") then
sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
else
local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value);
sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
end
sTmp = sTmp..",\n"
end
sTmp = sTmp..sTab.."}"
return sTmp
end
function SaveToFile(file , table , tablename)
local handle = io.open(file,"w+")
handle:write(Serialize(table, tablename))
handle:flush()
handle:close()
end
function LoadFromFile(file)
local handle = io.open(file,"r")
if (handle ~= nil) then
loadstring(handle:read("*all"))
handle:flush()
handle:close()
end
end
The bot must be regged to send pm.. so I skipped nr 4 =)
Important
Since it save to file, witch allows it to remeber after script restart, you must create a file called seen.dat with the the following text in it
seenArray = {
}
if you dont, it will give errors like
attempt to index global `seenArray' (a nil value)
*Edit*
Fixed an typo... ;)
HowToSend 2 Was not working....
very nice changes you made however i have a small problem with an error that i get when you look for yourself all others work fine heres the error seen.lua:96: attempt to call field `sName' (a string value)
Just missing .. after curUser.sName in the followong line:
SendToAll(BotName, "You should not do #seen's for yourself " ..curUser.sName " ;)" )
Should read:
SendToAll(BotName, "You should not do #seen's for yourself " ..curUser.sName.." ;)" )
Thanks [UK]Madman
Missed that... =)
Script has been edited
Thx for all the help with this script is very nice and the save feature is a nice bonus
QuoteOriginally posted by damo
Thx for all the help with this script is very nice and the save feature is a nice bonus
Np at all =)
Is it possible to make the script to work for Ip's too?
E.g: !seen 192.168.240.31
For the version i posted
Fixed an typo... ;)
HowToSend 2 Was not working....
QuoteOriginally posted by Ubikk
Is it possible to make the script to work for Ip's too?
E.g: !seen 192.168.240.31
Yup it can...
-- Creator Leon
-- Started lua 5 conversion, damo
-- Fully converted to lua 5 by 6Marilyn6Manson6
---- Modded By Madman
-- Added save to file
-- Added HowToSend, request by Ubikk
-- Hidden the command, request by damo
-- Added OnError Msg
-- Rewrote the ChatArrival
-- Added postibilite so seen ips, Request by Ubikk
BotName = "LeonBot"
minLen = 2
maxLen = 20
HowToSend = 2 -- 1: Send to all, 2: Send to user, 3: PM to the user
require("seen.dat")
function Main()
if HowToSend == 3 then
frmHub:RegBot(BotName)
end
end
function NewUserConnected(curUser)
local boolDisc = 0
if string.len(curUser.sName) < minLen then
curUser:SendPM(BotName, "Your nick is to short, a minimum of "..minLen.." chars is required!")
curUser:SendPM(BotName, "Disconnecting...")
curUser:Disconnect()
boolDisc = 1
elseif string.len(curUser.sName) > maxLen then
curUser:SendPM(BotName, "Your nick is to long, a maximum of "..maxLen.." chars is required!")
curUser:SendPM(BotName, "Disconnecting...")
curUser:Disconnect()
boolDisc = 1
elseif ( string.find (curUser.sName, " ", 1, 1) ) then
curUser:SendPM(BotName, "Spaces not allowed in nicknames!")
curUser:SendPM(BotName, "Disconnecting...")
curUser:Disconnect()
boolDisc = 1
end
if (boolDisc == 0) then
if seenArray == nil then
seenArray = {}
seenArray[curUser.sName] = {}
seenArray[curUser.sIP] = {}
seenArray[curUser.sName] = os.date(curUser.sName.." connected at %d/%m/%Y %T and is still here.")
seenArray[curUser.sIP] = os.date(curUser.sIP.." connected at %d/%m/%Y %T and is still here.")
SaveToFile("Seen.dat", seenArray, "seenArray")
SendToAll("Weee")
else
seenArray[curUser.sName] = os.date(curUser.sName.." connected at %d/%m/%Y %T and is still here.")
seenArray[curUser.sIP] = os.date(curUser.sIP.." connected at %d/%m/%Y %T and is still here.")
SaveToFile("Seen.dat", seenArray, "seenArray")
end
end
end
function OpConnected(curUser)
if seenArray == nil then
seenArray = {}
seenArray[curUser.sName] = {}
seenArray[curUser.sIP] = {}
seenArray[curUser.sName] = os.date(curUser.sName.." connected at %d/%m/%Y %T and is still here.")
seenArray[curUser.sIP] = os.date(curUser.sIP.." connected at %d/%m/%Y %T and is still here.")
SaveToFile("Seen.dat", seenArray, "seenArray")
else
seenArray[curUser.sName] = os.date(curUser.sName.." connected at %d/%m/%Y %T and is still here.")
seenArray[curUser.sIP] = os.date(curUser.sIP.." connected at %d/%m/%Y %T and is still here.")
SaveToFile("Seen.dat", seenArray, "seenArray")
end
end
function OpDisconnected(curUser)
if seenArray == nil then
seenArray = {}
seenArray[curUser.sName] = {}
seenArray[curUser.sIP] = {}
seenArray[curUser.sName] = os.date(curUser.sName.." disconnected at %d/%m/%Y %T and has not been seen since.")
seenArray[curUser.sIP] = os.date(curUser.sIP.." disconnected at %d/%m/%Y %T and has not been seen since.")
SaveToFile("Seen.dat", seenArray, "seenArray")
else
seenArray[curUser.sName] = os.date(curUser.sName.." disconnected at %d/%m/%Y %T and has not been seen since.")
seenArray[curUser.sIP] = os.date(curUser.sIP.." disconnected at %d/%m/%Y %T and has not been seen since.")
SaveToFile("Seen.dat", seenArray, "seenArray")
end
end
UserDisconnected = OpDisconnected
function OnError(ErrorMsg)
SendToOps(ErrorMsg)
end
function ChatArrival(curUser, data)
if seenArray == nil then
seenArray = {}
seenArray[curUser.sName] = {}
seenArray[curUser.sIP] = {}
seenArray[curUser.sName] = os.date(curUser.sName.." was last seen at %d/%m/%Y %T writing things.")
seenArray[curUser.sIP] = os.date(curUser.sIP.." was last seen at %d/%m/%Y %T writing things.")
SaveToFile("Seen.dat", seenArray, "seenArray")
else
seenArray[curUser.sName] = os.date(curUser.sName.." was last seen at %d/%m/%Y %T writing things.")
seenArray[curUser.sIP] = os.date(curUser.sIP.." was last seen at %d/%m/%Y %T writing things.")
SaveToFile("Seen.dat", seenArray, "seenArray")
end
local data = string.sub(data, 1, -2)
local s,e,cmd = string.find(data, "%b<>%s+[%!%+%?%#](%S+)")
if cmd then
local tCmds = {
["seen"] = function(curUser, data)
local s,e,arg = string.find(data, "%b<>%s+%S+%s+(%S+)")
if not arg then
if HowToSend == 1 then
SendToAll(BotName, "Syntax is: !" ..cmd.. " ")
elseif HowToSend == 2 then
curUser:SendData(BotName, "Syntax is: !" ..cmd.. " ")
elseif HowToSend == 3 then
curUser:SendPM(BotName, "Syntax is: !" ..cmd.. " ")
end
return 1
end
if (arg == curUser.sName) or (arg == curUser.sIP) then
if HowToSend == 1 then
SendToAll(BotName, "You should not do seen's for yourself " ..curUser.sName.. " ;)" )
elseif HowToSend == 2 then
curUser:SendData(BotName, "You should not do seen's for yourself " ..curUser.sName.. " ;)" )
elseif HowToSend == 3 then
curUser:SendPM(BotName, "You should not do seen's for yourself " ..curUser.sName.. " ;)" )
end
return 1
end
if seenArray[arg] == nil then
if HowToSend == 1 then
SendToAll(BotName, "I have not seen "..arg.."!" )
elseif HowToSend == 2 then
curUser:SendData(BotName, "I have not seen "..arg.."!" )
elseif HowToSend == 3 then
curUser:SendPM(BotName, "I have not seen "..arg.."!" )
end
return 1
end
if HowToSend == 1 then
SendToAll(BotName, "User: "..seenArray[arg] )
elseif HowToSend == 2 then
curUser:SendData(BotName, "User: "..seenArray[arg] )
elseif HowToSend == 3 then
curUser:SendPM(BotName, "User: "..seenArray[arg] )
end
return 1
end,
}
if tCmds[cmd] then
return tCmds[cmd](curUser, data)
end
end
end
function Serialize(tTable, sTableName, sTab)
assert(tTable, "tTable equals nil");
assert(sTableName, "sTableName equals nil");
assert(type(tTable) == "table", "tTable must be a table!");
assert(type(sTableName) == "string", "sTableName must be a string!");
sTab = sTab or "";
sTmp = ""
sTmp = sTmp..sTab..sTableName.." = {\n"
for key, value in tTable do
local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key);
if(type(value) == "table") then
sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
else
local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value);
sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
end
sTmp = sTmp..",\n"
end
sTmp = sTmp..sTab.."}"
return sTmp
end
function SaveToFile(file , table , tablename)
local handle = io.open(file,"w+")
handle:write(Serialize(table, tablename))
handle:flush()
handle:close()
end
function LoadFromFile(file)
local handle = io.open(file,"r")
if (handle ~= nil) then
loadstring(handle:read("*all"))
handle:flush()
handle:close()
end
end
very nice updates glad i asked for help now :D
Are you sure HowToSend 2 works now? ?(
Oh.. and by the way, the script is causing all the users a little bit of lag... even to me :( I have a lag of 1-2 seconds on my own hub !! :)
QuoteOriginally posted by Ubikk
Are you sure HowToSend 2 works now? ?(
lol.. sorry... fixed it in Version 1... but forgot to change it in Version 2 ;p
QuoteOriginally posted by Ubikk
Oh.. and by the way, the script is causing all the users a little bit of lag... even to me :( I have a lag of 1-2 seconds on my own hub !! :)
hmm... no idea why...
Maybe somebody got an idea :/
QuoteOriginally posted by Ubikk
Oh.. and by the way, the script is causing all the users a little bit of lag... even to me :( I have a lag of 1-2 seconds on my own hub !! :)
Did the lag disappear when you unloaded (if) this script?
Cheers
this script saves the data files on every chat msg.
poor harddrive, specialy if there is a av checking the data files.
now you found the cause, next find a way 2 solve it.
plop
QuoteOriginally posted by plop
this script saves the data files on every chat msg.
poor harddrive, specialy if there is a av checking the data files.
now you found the cause, next find a way 2 solve it.
plop
True.. didn't think of that... Thanks plop
My soultion is... make a switch for loging chat
and also a switch that is only triggerd if someone wrote something in main...
if both triger is 1 then save the new data...
on timer... the time can be setted on how many minues you want... =)
-- Creator Leon
-- Started lua 5 conversion, damo
-- Fully converted to lua 5 by 6Marilyn6Manson6
---- Modded By Madman
-- Added save to file
-- Added HowToSend, request by Ubikk
-- Hidden the command, request by damo
-- Added OnError Msg
-- Rewrote the ChatArrival
-- Added postibilite so seen ips, Request by Ubikk
-- Added switch to seen on chatarrival
-- Added saveing ontimer, only updates chat
-- Added SomeoneChated, only set to 1 if somebody wrote something in main
---- if SomeoneChated is set to one, update file ontimer
BotName = "LeonBot"
SeenChat = 1 -- Save chat 1 = yes, nil = no
minLen = 2
maxLen = 20
HowToSend = 2 -- 1: Send to all, 2: Send to user, 3: PM to the user
ChatTime = 5 -- How many minutes beetween saves
require("Seen.dat")
function Main()
if HowToSend == 3 then
frmHub:RegBot(BotName)
end
SetTimer(1000*60*ChatTime)
StartTimer()
end
function OnTimer()
if SeenChat then
if SomeoneChated == 1 then
SaveToFile("Seen.dat", seenArray, "seenArray")
SomeoneChated = 0
end
end
end
function NewUserConnected(curUser)
local boolDisc = 0
if string.len(curUser.sName) < minLen then
curUser:SendPM(BotName, "Your nick is to short, a minimum of "..minLen.." chars is required!")
curUser:SendPM(BotName, "Disconnecting...")
curUser:Disconnect()
boolDisc = 1
elseif string.len(curUser.sName) > maxLen then
curUser:SendPM(BotName, "Your nick is to long, a maximum of "..maxLen.." chars is required!")
curUser:SendPM(BotName, "Disconnecting...")
curUser:Disconnect()
boolDisc = 1
elseif ( string.find (curUser.sName, " ", 1, 1) ) then
curUser:SendPM(BotName, "Spaces not allowed in nicknames!")
curUser:SendPM(BotName, "Disconnecting...")
curUser:Disconnect()
boolDisc = 1
end
if (boolDisc == 0) then
if seenArray == nil then
seenArray = {}
seenArray[curUser.sName] = {}
seenArray[curUser.sIP] = {}
seenArray[curUser.sName] = os.date(curUser.sName.." connected at %d/%m/%Y %T and is still here.")
seenArray[curUser.sIP] = os.date(curUser.sIP.." connected at %d/%m/%Y %T and is still here.")
SaveToFile("Seen.dat", seenArray, "seenArray")
SendToAll("Weee")
else
seenArray[curUser.sName] = os.date(curUser.sName.." connected at %d/%m/%Y %T and is still here.")
seenArray[curUser.sIP] = os.date(curUser.sIP.." connected at %d/%m/%Y %T and is still here.")
SaveToFile("Seen.dat", seenArray, "seenArray")
end
end
end
function OpConnected(curUser)
if seenArray == nil then
seenArray = {}
seenArray[curUser.sName] = {}
seenArray[curUser.sIP] = {}
seenArray[curUser.sName] = os.date(curUser.sName.." connected at %d/%m/%Y %T and is still here.")
seenArray[curUser.sIP] = os.date(curUser.sIP.." connected at %d/%m/%Y %T and is still here.")
SaveToFile("Seen.dat", seenArray, "seenArray")
else
seenArray[curUser.sName] = os.date(curUser.sName.." connected at %d/%m/%Y %T and is still here.")
seenArray[curUser.sIP] = os.date(curUser.sIP.." connected at %d/%m/%Y %T and is still here.")
SaveToFile("Seen.dat", seenArray, "seenArray")
end
end
function OpDisconnected(curUser)
if seenArray == nil then
seenArray = {}
seenArray[curUser.sName] = {}
seenArray[curUser.sIP] = {}
seenArray[curUser.sName] = os.date(curUser.sName.." disconnected at %d/%m/%Y %T and has not been seen since.")
seenArray[curUser.sIP] = os.date(curUser.sIP.." disconnected at %d/%m/%Y %T and has not been seen since.")
SaveToFile("Seen.dat", seenArray, "seenArray")
else
seenArray[curUser.sName] = os.date(curUser.sName.." disconnected at %d/%m/%Y %T and has not been seen since.")
seenArray[curUser.sIP] = os.date(curUser.sIP.." disconnected at %d/%m/%Y %T and has not been seen since.")
SaveToFile("Seen.dat", seenArray, "seenArray")
end
end
UserDisconnected = OpDisconnected
function OnError(ErrorMsg)
SendToOps(ErrorMsg)
end
function ChatArrival(curUser, data)
if SeenChat then
if seenArray == nil then
seenArray = {}
seenArray[curUser.sName] = {}
seenArray[curUser.sIP] = {}
seenArray[curUser.sName] = os.date(curUser.sName.." was last seen at %d/%m/%Y %T writing things.")
seenArray[curUser.sIP] = os.date(curUser.sIP.." was last seen at %d/%m/%Y %T writing things.")
SomeoneChated = 1
else
seenArray[curUser.sName] = os.date(curUser.sName.." was last seen at %d/%m/%Y %T writing things.")
seenArray[curUser.sIP] = os.date(curUser.sIP.." was last seen at %d/%m/%Y %T writing things.")
SomeoneChated = 1
end
end
local data = string.sub(data, 1, -2)
local s,e,cmd = string.find(data, "%b<>%s+[%!%+%?%#](%S+)")
if cmd then
local tCmds = {
["seen"] = function(curUser, data)
local s,e,arg = string.find(data, "%b<>%s+%S+%s+(%S+)")
if not arg then
if HowToSend == 1 then
SendToAll(BotName, "Syntax is: !" ..cmd.. " ")
elseif HowToSend == 2 then
curUser:SendData(BotName, "Syntax is: !" ..cmd.. " ")
elseif HowToSend == 3 then
curUser:SendPM(BotName, "Syntax is: !" ..cmd.. " ")
end
return 1
end
arg = string.lower(arg)
if (arg == curUser.sName) or (arg == curUser.sIP) then
if HowToSend == 1 then
SendToAll(BotName, "You should not do seen's for yourself " ..curUser.sName.. " ;)" )
elseif HowToSend == 2 then
curUser:SendData(BotName, "You should not do seen's for yourself " ..curUser.sName.. " ;)" )
elseif HowToSend == 3 then
curUser:SendPM(BotName, "You should not do seen's for yourself " ..curUser.sName.. " ;)" )
end
return 1
end
if seenArray[arg] == nil then
if HowToSend == 1 then
SendToAll(BotName, "I have not seen "..arg.."!" )
elseif HowToSend == 2 then
curUser:SendData(BotName, "I have not seen "..arg.."!" )
elseif HowToSend == 3 then
curUser:SendPM(BotName, "I have not seen "..arg.."!" )
end
return 1
end
if HowToSend == 1 then
SendToAll(BotName, "User: "..seenArray[arg] )
elseif HowToSend == 2 then
curUser:SendData(BotName, "User: "..seenArray[arg] )
elseif HowToSend == 3 then
curUser:SendPM(BotName, "User: "..seenArray[arg] )
end
return 1
end,
}
if tCmds[cmd] then
return tCmds[cmd](curUser, data)
end
end
end
function Serialize(tTable, sTableName, sTab)
assert(tTable, "tTable equals nil");
assert(sTableName, "sTableName equals nil");
assert(type(tTable) == "table", "tTable must be a table!");
assert(type(sTableName) == "string", "sTableName must be a string!");
sTab = sTab or "";
sTmp = ""
sTmp = sTmp..sTab..sTableName.." = {\n"
for key, value in tTable do
local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key);
if(type(value) == "table") then
sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
else
local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value);
sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
end
sTmp = sTmp..",\n"
end
sTmp = sTmp..sTab.."}"
return sTmp
end
function SaveToFile(file , table , tablename)
local handle = io.open(file,"w+")
handle:write(Serialize(table, tablename))
handle:flush()
handle:close()
end
function LoadFromFile(filename)
local f = io.open( filename, "r")
if f then
local r = f:read( "*a" )
f:flush()
f:close()
local func, err = loadstring(r)
if func then x,err = pcall(func) end
end
end
Important
Since it save to file, witch allows it to remeber after script restart, you must create a file called seen.dat with the the following text in it
seenArray = {
}
Nice madman very nice ^^
-- Creator Unknown
BotName = "LeonBot"
that should give u a hint of who created it, "leon bot"
and here (http://www.plop.nl/ptokaxbots/Leon/seenbot.lua) is the proof :)
QuoteOriginally posted by Dessamator
-- Creator Unknown
BotName = "LeonBot"
that should give u a hint of who created it, "leon bot"
and here (http://www.plop.nl/ptokaxbots/Leon/seenbot.lua) is the proof :)
thanks...
Scripts been edited =)
ur welcome :)
Thank you so much for your help guyz :)
One last request for this script, is it possible to make it work for like this (i dont know how to express this in english):
example:
If the nickname is Ubikk
I want the script to work for ubikk and for uBikk too... i dont want it to depend on the capital of a nickname or on the littles.
!seen Ubikk = !seen ubikk = !seen uBiKK = !seen UbiKK etc...
:D
Too bad i dont know english that well. I hope you guyz understood what i ment to say :P if not, i will try to explain harder :D
QuoteOriginally posted by Ubikk
Thank you so much for your help guyz :)
One last request for this script, is it possible to make it work for like this (i dont know how to express this in english):
example:
If the nickname is Ubikk
I want the script to work for ubikk and for uBikk too... i dont want it to depend on the capital of a nickname or on the littles.
!seen Ubikk = !seen ubikk = !seen uBiKK = !seen UbiKK etc...
:D
Too bad i dont know english that well. I hope you guyz understood what i ment to say :P if not, i will try to explain harder :D
what u mean is remove the case "sensetivity" just add/edit this :
local s,e,arg = string.find(data, "%b<>%s+%S+%s+(%S+)")
arg = string.lower(arg)
So, where should i add that? :)
All that i could find in my code similar to that was:
local s,e,cmd = string.find(data, "%b<>%s+[%!%+%?%#](%S+)")
Something like this (check the red line):
local tCmds = {
["seen"] = function(curUser, data)
local s,e,arg = string.find(data, "%b<>%s+%S+%s+(%S+)")
if not arg then
if HowToSend == 1 then
SendToAll(BotName, "Syntax is: !" ..cmd.. " ")
elseif HowToSend == 2 then
curUser:SendData(BotName, "Syntax is: !" ..cmd.. " ")
elseif HowToSend == 3 then
curUser:SendPM(BotName, "Syntax is: !" ..cmd.. " ")
end
return 1
end
[COLOR=red]arg = string.lower(arg)[/COLOR]
Best regards,
jiten
can you make ubikk`s idea ?( ? its a good idea !!!! :D
If the nickname is GodLike
I want the script to work for GodLike and for godlike too... i dont want it to depend on the capital of a nickname or on the littles.
!seen GodLike = !seen GODLIKE = !seen godlike = !seen GODlike etc...
i hope can you make :]
Check jitens post....
He tell u all about how to do it.. but i'll edit the script..
Unfortunately I keep this script disabled.... it still uses 90% of my CPU when I activate it... :rolleyes:
This script crashes my hub, only solution is restart, and renaming the script file so it does not load again on startup...I'm running Verli 0.9.8c RC2...anyone else with this problem?
It consumes way too much cpu and ram ... maybe a more experienced user can help us :)
hmm, it really shouldnt consume that much memory, only in a hub with a lot of traffic !
QuoteOriginally posted by kvisko
This script crashes my hub, only solution is restart, and renaming the script file so it does not load again on startup...I'm running Verli 0.9.8c RC2...anyone else with this problem?
Verli? this ia a PtokaX script...