Hi guys have a little problem?
s,e,cmd,victim = strfind(data, "%b<>%s+(%S+)%s+(%S+)")
I use above example to get the nick of a user, but when i use it whit this nick :T??:.test
I get errors because of strange signs
Any ideas?
then don't allow those signs... :-) simple... hehe
s,e,cmd,victim = strfind(data, "%b<>%s+(%S+)%s+([^%S]+)")
wild gues hope it works
plop
while in to this...
Quotes,e,cmd,victim = strfind(data, "%b<>%s+(%S+)%s+([^%S]+)")
what does [^ do have never dealt with it so much... exept P/C :-)
Going to test it, thx Plop
Nope it ain't working at the moment, it gives a nil error
s,e,cmd,victim = strfind(data, "%b<>%s+(%S+)%s+([^%s]+)")
should be a small s.
plop
shitss, almost the same
Syntax error: bad argument #1 to `write' (string expected, got nil)
s,e,cmd,victim = strfind(data, "%b<>%s+(%S+)%s+(%S+)%s+")
also search for whats behind victim seems 2 work here.
it gets stuck on the . for example
s,e,cmd,victim = strfind(data, "%b<>%s+(%S+)%s+(%S+)%.+")
returns :T??:
plop
QuoteOriginally posted by NightLitch
while in to this...
what does [^ do have never dealt with it so much... exept P/C :-)
you can make your own ranges 2 search for or single things.
in this case it was a longer way 2 search for anything beside a space.
[^0-6] would return anything beside 0 to 6.
[^a-f] would return anything beside a to f
[^a] would return anything beside a
[a] returns only a
etc....
plop
Yups your right there is something else wrong?
strfind was ok.
local handle=openfile("logs/online/"..victim..".txt","a")
write(handle, user.sName.."\r\n")
closefile(handle)
This is the problem when it writes to disk it don't regonize the signs *lol* - and that
s true offcourse Forgot all about it.
mm, now i have todesign some other construction
victim = gsub(victim, "%.", "$")
and your done. lol
on loading saving you change the . for something else.
they can't use the $ in there nick, so it should be save.
plop
ok gone test again, thx ;)
mm, still the same result... it's for a offline message
sleeping here.
( ) . % + - * ? [ ^ $ are all magic things so you need 2 escape it on loading.
changing it back on loading would be
victim = gsub(victim, "%$", ".")
if it still doesn't work can you give me those parts of the code so i can try it here.??
plop
think i found the full problem.
if so optimus should respond here happy 2morrow. lol
strfind got lost on the . and saving loading got lost on the :
this i used 2 find the victem:
s,e,cmd,victim = strfind(data, "%b<>%s+(%S+)%s+(%S+)%s*$")
and this i used 2 solve the : problem:
temp = gsub(user, ":", "$")
loading and saving, strfind now all seem 2 work.
lets wait for the final answer from optimus.
plop
Will post results here? almost there
Thx to the Ploperarot ;)
QuoteOriginally posted by Optimus
Will post results here? almost there
Thx to the Ploperarot ;)
check pm.
[20:36]
*** Online check to user <:T??:.Test> has been set!
[20:36] Private message from Online_Demo: *** User <:T??:.Test> went online at: 01/09/04 20:30:17 - His IP:
plop
Here is the Result! lol Ploperator
-- Online Check Demo - by Opti
-- Modded by Plop to work with Strange Signs in username
-- Added other strfind & gsub handling Plop
-- Fixed small Buggs Plop
sBot = "Online_Demo"
timedate = date()
prefix = "!"
function Main()
frmHub:RegBot(sBot)
end
function NewUserConnected(user)
OnlineConnect(user, data)
end
OpConnected = NewUserConnected
function DataArrival(user, data)
if( strsub(data, 1, 1) == "<" ) then
data=strsub(data,1,strlen(data)-1)
s,e,cmd,victim = strfind(data, "%b<>%s+(%S+)")
if (cmd == prefix.."online") then
s,e,cmd,victim = strfind(data, "%b<>%s+(%S+)%s+(%S+)%s*$")
if victim == nil then user:SendData(sBot, "*** Enter a username!") return 1 end
victim2 = gsub(victim, ":", "$")
local handle=openfile(victim2..".txt","a")
write(handle, user.sName.."\r\n")
closefile(handle)
user:SendData(sBot, "*** Online check to user <"..victim.."> has been set!")
return 1
end
end
end
--// Online Check
function OnlineConnect(user, data)
temp = gsub(user.sName, ":", "$")
readfrom(temp..".txt")
while 1 do
SendUser = read()
if SendUser == nil then
break
end
SendPmToNick(SendUser, sBot, "*** User <"..user.sName.."> went online at: "..timedate.." - His IP: "..user.sIP)
end
readfrom()
a,b=remove(temp..".txt")
end