This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

regexp problem

Old posts that have not been replied to for several years.
Locked
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

regexp problem

Post by metroid »

Now, im pretty lousy with regexp, but i tried to use this code so it pms the channel service with chanlev <channel> and it retrieves the things, now its not quite complete but the regexp i made doesnt seem to work

Code: Select all

bind pub o|o \$chanlev pub:chanlevcheck

proc pub:chanlevcheck { nick host hand chan text } {
  set ::chanlev(chan) "$chan"
  bind notc - * notc:chanlev
  putserv "PRIVMSG $chan :\002\273\002 Checking $chan's chanlev"
  putserv "PRIVMSG [cserve $chan] :CHANLEV $chan"
}

proc notc:chanlev {nick host hand text [censored]} {
  set chan $::chanlev(chan)
  set from "$nick!$host"
  if {[string match -nocase "Q!TheQBot@CServe.quakenet.org" $from]} {
	if regex ^Total:\s([0-9]+)\s\(owner:\s([0-9]+),\smaster:\s([0-9]+),\sop:\s([0-9]+),\svoice:\s([0-9]+),\sban:\s([0-9]+)\)\.$}
# I have no clue how to use it :|
      putserv "PRIVMSG $chan :\002\273\002 Unknown channel Blah!"
      unbind notc - * notc:chanlev
      return
    }

proc cserve {chan} {
if {[onchan Q $chan]} {return "Q"} elseif {[onchan L $chan]} {return "L"} else {return ""}
}
Now again, i have no clue how to use it, so it looks like crap :P

This is the error on the partyline

Code: Select all

[08:18] Tcl error [notc:chanlev]: invalid command name "0-9"
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

I am not that good myself with regular expressions, but you are not using the correct syntax of regexp even. You forgot to mention the variable to match with even, so I will assume it to be $text.

As for that tcl error escape the [0-9] square brackets. That is what the error is about. As for the matching bit, I am not sure because I don't have the output which you are trying to match.

Replace:

Code: Select all

   if regex ^Total:\s([0-9]+)\s\(owner:\s([0-9]+),\smaster:\s([0-9]+),\sop:\s([0-9]+),\svoice:\s([0-9]+),\sban:\s([0-9]+)\)\.$} 
With:

Code: Select all

   if {[regexp -- {^Total:\s(\[0-9\]+)\s\(owner:\s(\[0-9\]+),\smaster:\s(\[0-9\]+),\sop:\s(\[0-9\]+),\svoice:\s(\[0-9\]+),\sban:\s(\[0-9\]+)\)\.$} $text]} {
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
Locked