Strfind?
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

Strfind?

Started by Optimus, 08 January, 2004, 20:40:29

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Optimus

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?

NightLitch

then don't allow those signs... :-) simple... hehe
//NL

plop

s,e,cmd,victim = strfind(data, "%b<>%s+(%S+)%s+([^%S]+)")
wild gues  hope it works

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

NightLitch

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 :-)
//NL

Optimus

Going to test it, thx Plop

Optimus

Nope it ain't working at the moment, it gives a nil error

plop

s,e,cmd,victim = strfind(data, "%b<>%s+(%S+)%s+([^%s]+)")
should be a small s.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Optimus

shitss, almost the same

Syntax error: bad argument #1 to `write' (string expected, got nil)

plop

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
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

plop

#9
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
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Optimus

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

plop

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
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Optimus

ok gone test again, thx  ;)

Optimus

mm, still the same result... it's for a offline message

plop

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
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

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
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Optimus

Will post results here? almost there

Thx to the Ploperarot  ;)

plop

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
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Optimus

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

SMF spam blocked by CleanTalk