egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Binding commands to a single set of channels

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    egghelp.org community Forum Index -> Archive
View previous topic :: View next topic  
Author Message
Joel
Voice


Joined: 06 Sep 2005
Posts: 11

PostPosted: Fri Sep 09, 2005 5:23 am    Post subject: Binding commands to a single set of channels Reply with quote

--new code below--


Is what i have, but my bot sits in a load of channels, but i only want the commands to be available in #chan and #chan.admin? How do i bind the script to those channels?

Joel


Last edited by Joel on Fri Sep 09, 2005 8:58 am; edited 3 times in total
Back to top
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Fri Sep 09, 2005 5:38 am    Post subject: Reply with quote

you can't [bind pub] to channel, but you can check inside the proc if $chan is allowed for that command
Back to top
View user's profile Send private message Visit poster's website
Joel
Voice


Joined: 06 Sep 2005
Posts: 11

PostPosted: Fri Sep 09, 2005 7:22 am    Post subject: Reply with quote

Ah, right, updated the code above, but i'm getting a silly error that i cant seem to see whats causing it

12:24 <KryptoBot>12:21] Tcl error [stats_run]: extra characters after
close-brace

is it something to do with newline chars?

Joel
Back to top
View user's profile Send private message
oxygen
Voice


Joined: 05 Sep 2005
Posts: 22
Location: Germany

PostPosted: Fri Sep 09, 2005 7:52 am    Post subject: Reply with quote

hi Joel

maybe because:
Code:
if {($chan != $radiochans) || ($chan != $adminchans)}{

must be:
Code:
if {($chan != $radiochans) || ($chan != $adminchans)} {


but to check allowed chans try this:
Code:
set allowedchans "#chan #chan.admin"

bind * !stats stats_run

proc stats_run {nick uhost hand chan rest} {
   global streamip streamport streampass allowedchans
      if {(([lsearch -exact [string tolower $allowedchans] [string tolower $chan]] != -1)||($allowedchans == "*"))} {
          if {[catch {set sock [socket $streamip $streamport] } sockerror]} {
             putlog "error: $sockerror"
             return 0
          } else {
             blabla....


hope this helps. btw. the first if must be in one line

friendly regards
oxygen
Back to top
View user's profile Send private message
Joel
Voice


Joined: 06 Sep 2005
Posts: 11

PostPosted: Fri Sep 09, 2005 9:03 am    Post subject: Reply with quote

Thankyou kindly for your help, added that, and sorted a problem with the position of my { and } (I think :S)

anyway, I now have this
Code:


--- Code Cut ---



But get the error

[13:53] Tcl error [stats_run]: invalid command name "shrink"

Have i got something in the wrong place? excude my n00b ness, but I'm more familiar with PHP, just getting started in this arena :S

Oh and out of interest, what editor do people use? I could really do with one with auto indent? jEdit doesnt seem to do it.

Joel


Last edited by Joel on Fri Sep 09, 2005 9:58 am; edited 2 times in total
Back to top
View user's profile Send private message
oxygen
Voice


Joined: 05 Sep 2005
Posts: 22
Location: Germany

PostPosted: Fri Sep 09, 2005 9:21 am    Post subject: Reply with quote

hi Joel

I think a proc is missing. maybe something like that?
Code:
proc shrink { calc number string start bl} { return [expr [string first "$string" $bl $start] $calc $number] }


hope it helps

friendly regards
oxygen
Back to top
View user's profile Send private message
Joel
Voice


Joined: 06 Sep 2005
Posts: 11

PostPosted: Fri Sep 09, 2005 9:31 am    Post subject: Reply with quote

Doh, what a plonker...
Back to top
View user's profile Send private message
Joel
Voice


Joined: 06 Sep 2005
Posts: 11

PostPosted: Fri Sep 09, 2005 10:03 am    Post subject: Reply with quote

Code:


set allowedchans "#linod"
set streamip ""
set streamport "9000"
set streampass ""

bind pub * !stats stats_run

# Basic Edit Functions
proc shrink { calc number string start bl} { return [expr [string first "$string" $bl $start] $calc $number] }

#Command Functions
proc stats_run {nick uhost hand chan rest} {
   global streamip streamport streampass allowedchans
      if {(([lsearch -exact [string tolower $allowedchans] [string tolower $chan]] != -1)||($allowedchans == "*"))} {
          if {[catch {set sock [socket $streamip $streamport] } sockerror]} {
             putlog "error: $sockerror"
             return 0
        } else {
      if {[catch {set sock [socket $streamip $streamport] } sockerror]} {
         putlog "error: $sockerror"
         return 0
      } else {
         puts $sock "GET /admin.cgi?pass=$streampass&mode=viewxml&page=0 HTTP/1.0"
         puts $sock "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.9)"
         puts $sock "Host: $streamip"
         puts $sock "Connection: close"
         puts $sock ""
         flush $sock
         putlog "debug 01 $chan"
         while {[eof $sock] != 1} {
            set bl [gets $sock]
            if { [string first "standalone" $bl] != -1 } {
               set streamstatus [string range $bl [shrink + 14 "<STREAMSTATUS>" 0 $bl] [shrink - 1 "</STREAMSTATUS>" 0 $bl]]
            }
         }
            close $sock
         }
         if { $streamstatus == "1" } {
            putlog "shoutcast: $nick asked for serverstats from $chan"
            if {[catch {set sock [socket $streamip $streamport] } sockerror]} {
               putlog "error: $sockerror"
               return 0
            } else {
               puts $sock "GET /admin.cgi?pass=$streampass&mode=viewxml&page=0 HTTP/1.0"
               puts $sock "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.9)"
               puts $sock "Host: $streamip"
               puts $sock "Connection: close"
               puts $sock ""
               flush $sock
               putlog "debug 02 $chan"
               while {[eof $sock] != 1} {
                  putlog "debug 03 $chan"
                  set bl [gets $sock]
                  putlog "debug 04 $chan"
                  if { [string first "standalone" $bl] != -1 } {
                     putlog "Generating info"
                     
                     set streamstatus [string range $bl [shrink + 14 "<STREAMSTATUS>" 0 $bl] [shrink - 1 "</STREAMSTATUS>" 0 $bl]]
                     set repl [string range $bl [shrink + 19 "<REPORTEDLISTENERS>" 0 $bl] [shrink - 1 "</REPORTEDLISTENERS>" 0 $bl]]
                     set curhigh [string range $bl [shrink + 15 "<PEAKLISTENERS>" 0 $bl] [shrink - 1 "</PEAKLISTENERS>" 0 $bl]]
                     set currentl [string range $bl [shrink + 18 "<CURRENTLISTENERS>" 0 $bl] [shrink - 1 "</CURRENTLISTENERS>" 0 $bl]]
                     set surl [string range $bl [shrink + 11 "<SERVERURL>" 0 $bl] [shrink - 1 "</SERVERURL>" 0 $bl]]
                     set maxl [string range $bl [shrink + 14 "<MAXLISTENERS>" 0 $bl] [shrink - 1 "</MAXLISTENERS>" 0 $bl]]
                     set bitrate [string range $bl [shrink + 9 "<BITRATE>" 0 $bl] [shrink - 1 "</BITRATE>" 0 $bl]]
                     set stitle [string range $bl [shrink + 13 "<SERVERTITLE>" 0 $bl] [shrink - 1 "</SERVERTITLE>" 0 $bl]]
                     set sgenre [string range $bl [shrink + 13 "<SERVERGENRE>" 0 $bl] [shrink - 1 "</SERVERGENRE>" 0 $bl]]
                     if {$sgenre != ""} {set sgenre " ($sgenre)"}
                     set avgtime [string range $bl [shrink + 13 "<AVERAGETIME>" 0 $bl] [shrink - 1 "</AVERAGETIME>" 0 $bl]]
                     set irc [string range $bl [shrink + 5 "<IRC>" 0 $bl] [shrink - 1 "</IRC>" 0 $bl]]
                     set webhits [string range $bl [shrink + 9 "<WEBHITS>" 0 $bl] [shrink - 1 "</WEBHITS>" 0 $bl]]
                     set streamhits [string range $bl [shrink + 12 "<STREAMHITS>" 0 $bl] [shrink - 1 "</STREAMHITS>" 0 $bl]]
                     set version [string range $bl [shrink + 9 "<VERSION>" 0 $bl] [shrink - 1 "</VERSION>" 0 $bl]]

                  }
                  close $sock
               }
            }
               putchan $chan "$stitle$sgenre is online, running shoutcast $version and streaming at $bitrate kbps,  your dj is $dj. please visit $surl"       
               putchan $chan "$stitle$sgenre is online, running shoutcast $version and streaming at $bitrate kbps,  your dj is $dj. please visit $surl"
               putchan $chan "there are currently $repl unique people listening, the listener maximum is $maxl, our user peak was at $curhigh listeners."
               putchan $chan "the average user is listening $avgtime seconds, our stream had $webhits webhits and $streamhits streamhits."
               putchan $chan "you can contact the team by irc on $irc"
            } else {
               return 0
   }
         }
      }
   }


Right well after some broken bits, i think i'm nearly there, once i've cracked this bit i should be ok for the rest,

I'm getting a weird thing going on now, not sure what i've done, but when i do !stats in the chan i get a TCL error:

Tcl error [stats_run]: can not find channel named "sock24"

the 24 on the end incriments by one every time i run the command. I cant see where i've ended up looping the chan name into that :s

the last message i get to the party line is debug 04 $chan, so i think its after that that causes the problem, unless its further up and i just cant see it :s

Thanks in advance

Joel.... Slowly getting the hang of this :S
Back to top
View user's profile Send private message
Joel
Voice


Joined: 06 Sep 2005
Posts: 11

PostPosted: Mon Sep 12, 2005 4:39 am    Post subject: Reply with quote

Anyone any ideas Sad

Joel
Back to top
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Mon Sep 12, 2005 12:30 pm    Post subject: Reply with quote

I'd go for 'setudef' and 'channel get' (check the tcl-commands.doc file) instead of a some specified in a variable way if you want to have commands just for one or some specific channels, this in case the list of allowed channels changes.

Post what errors you get (see this page for instructions).
_________________
Once the game is over, the king and the pawn go back in the same box.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    egghelp.org community Forum Index -> Archive All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber