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.

Lindex help

Help for those learning Tcl or writing their own scripts.
User avatar
CrazyCat
Revered One
Posts: 1306
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Here's a small correction : added a debug advert when regexp didn't matches.

Code: Select all

proc rls:id3 {nick host hand chan arg} {
   global chann_ sitebot_ ftp_
    if { $chan == $chann_(spam) && $nick == $sitebot_(nick) } {
         set pattern {iD3 > ([^>]+)? > ([^>]+)? from ([0-9]+)? at ([0-9]+)? Hz}
         if { [regexp $pattern $arg match rlsname genre year sampling] } {
            if {[string trim $genre] == ""} { set genre "-" }
            if {[string trim $year] == ""} { set year "-" }
            if {[string trim $sampling] == ""} { set sampling "-" }
            if { $rlsname == "" } {
               putquick "PRIVMSG $chann_(echo) :\0034 Error!! Release Name Empty\003"
               return 0
            }
         } else {
            putserv "PRIVMSG $chann_(echo) :$arg didn't match"
            return 0
         }
         putquick  "PRIVMSG $chann_(echo) :!addid3c $rlsname $genre $year $sampling"
    }
}
I noticed something strange in your code:

Code: Select all

putquick  "PRIVMSG $chann_(echo) :!addid3c $rlsname $genre $year $sampling"
Is !addid3c the bind for the rls:id3 proc ? If it is, the "command line" is not what is expected in the regexp.

If you really want help, I think you have to give us your complete code and not just bits of it.
C
COBRa
Halfop
Posts: 49
Joined: Fri Jan 04, 2013 8:23 am

Post by COBRa »

the bind is this

Code: Select all

bind pub - iD3 rls:id3
User avatar
CrazyCat
Revered One
Posts: 1306
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Ok, so the "!addid3c" command has no relation with this part of the script.

Can you give me an example of non-matching command ? (paste the complete irc log without any modification).
C
COBRa
Halfop
Posts: 49
Joined: Fri Jan 04, 2013 8:23 am

Post by COBRa »

The !addid3c is announced in a specific channel and another bot which is linked adds the info into a database so yes its part of this code

so when the line !addid3c some_release some_genre etc hits the channel another bot picks up the !addid3c line and enter it into the database

the error im getting is this

Deine_Freunde-Heile_Welt-DE-2014-CARDiNALS > Pop from 2014 at 44100 Hz didn't match
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Sorry for the late answer.

Since you are using the "pub" binding, "id3" is considered the command, and thus removed from the text-argument ($arg). Thus, the regular expression needs to be adjusted accordingly:

Code: Select all

set pattern {([^>]+)? > ([^>]+)? from ([0-9]+)? at ([0-9]+)? Hz}
NML_375
C
COBRa
Halfop
Posts: 49
Joined: Fri Jan 04, 2013 8:23 am

Post by COBRa »

Many thanks to all that helped me sort the code out it now works fine
C
COBRa
Halfop
Posts: 49
Joined: Fri Jan 04, 2013 8:23 am

Post by COBRa »

Hi using similar code to the previous post in trying to capture this line via the regex method and wondered if you guys could assist me plz i think its the regex line thts wrong anyhow heres my first draught

Code: Select all

proc rls:spec {nick host hand chan arg} {
   global chann_ sitebot_ ftp_
     if { $chan == $chann_(spam) && $nick == $sitebot_(nick) } {
         set pattern {([^>]+)? > Codec: ([^>]+)? FPS: ([^fps][0-9]+)? Res:([0-9]+)? AR: ([0-9]+)? > Audio: ([^>]+)? BitRate: ([^kbps][0-9]+)? Freq: ([^KHz][0-9]+)? Channels: ([^ch][0-9]+)?}
         if { [regexp $pattern $arg match rlsname videocodec fps ar audiocodec audiobitrate audiofreq channels] } {
     	 if {[string trim $videocodec] == ""} { set videocodec "-" }
         if {[string trim $fps] == ""} { set fps "-" }
         if {[string trim $ar] == ""} { set ar "-" }
         if {[string trim $audiocodec] == ""} { set audiocodec "-" }
         if {[string trim $audiobitrate] == ""} { set audiobitrate "-" }
         if {[string trim $audiofreq] == ""} { set audiofreq "-" }
         if {[string trim $channels] == ""} { set channels "-" }
         if { $rlsname == "" } {
               putquick "PRIVMSG $chann_(add) :\0034 Error!! Release Name Empty\003"
               return 0
            }
         } else {
            putserv "PRIVMSG $chann_(add) :$arg didn't match"
            return 0
         }
            putquick "PRIVMSG $chann_(add) :!addvideoinfo $rlsname $videocodec $fps $ar $audiocodec $audiobitrate $audiofreq $channels"
            putquick "PRIVMSG $chann_(add) :\[\0035SAMPLE-SPEC\003\] $rlsname"
   }
}        
and this is the line im trying to capture

Code: Select all

SPEC > At.Midnight.2015.08.05.HDTV.x264-TASTETV > Codec: AVC FPS: 29.970fps Res: 720x404 AR: 16:9 > Audio: AAC BitRate: 124Kbps Freq: 48.0KHz Channels: 2ch
Post Reply