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.

Dump chanlist to file

Old posts that have not been replied to for several years.
Locked
S
Sikes
Voice
Posts: 3
Joined: Tue May 31, 2005 3:44 am

Dump chanlist to file

Post by Sikes »

I have been asked to write a bash script that interacts with ftp. Part of that is they need the users online for certain announcements. I have the bash part under control, and just need to check logins against a dump of who is in the channel.

To be honest I thought this would only be a couple of lines of code and was hoping to get away with out having to learn TCl (at least leave it till I get some time), so I have been scanning scripts and these forums for correct syntax. Below is what i have come up with so far;

Code: Select all

# Get list of current online usernames
set my_chan "#accounts"
set my_nick "Sikes"

# Need this to be a timer every 3(?) minutes
# timer 180 [puts $my_file [chanlist $my_chan]]
# Try a bind to get imediate output
bind pubm - !writelist pubm:write_chanlist

# Open,write to, and close file

proc pubm:write_chanlist {my_chan my_nick} {
                set my_file [open onchan.chanlist w]
                puts $my_file [chanlist $my_chan]
                putserv "PRIVMSG $my_nick :Done"
                # try to get output from chanlist
                putserv "PRIVMSG $my_nick :$chanlist"
                close $my_file
                }

Now the above trigger dosn't work. But no matter what I do I can't get any output from $chanlist. I started off simple with;

Code: Select all


set my_file onchan.chanlist
open $my_file w
puts $my_file [chanlist $my_chan]
close $my_file

Without any luck. Can anyone point me to why the above bind dosn't work and I can never seem to get any output from chanlist?

Thanks
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Re: Dump chanlist to file

Post by awyeah »

Sikes wrote:I have been asked to write a bash script that interacts with ftp. Part of that is they need the users online for certain announcements. I have the bash part under control, and just need to check logins against a dump of who is in the channel.

To be honest I thought this would only be a couple of lines of code and was hoping to get away with out having to learn TCl (at least leave it till I get some time), so I have been scanning scripts and these forums for correct syntax. Below is what i have come up with so far;

Code: Select all

# Get list of current online usernames
set my_chan "#accounts"
set my_nick "Sikes"

# Need this to be a timer every 3(?) minutes
# timer 180 [puts $my_file [chanlist $my_chan]]
# Try a bind to get imediate output
bind pubm - !writelist pubm:write_chanlist

# Open,write to, and close file

proc pubm:write_chanlist {my_chan my_nick} {
                set my_file [open onchan.chanlist w]
                puts $my_file [chanlist $my_chan]
                putserv "PRIVMSG $my_nick :Done"
                # try to get output from chanlist
                putserv "PRIVMSG $my_nick :$chanlist"
                close $my_file
                }

Now the above trigger dosn't work. But no matter what I do I can't get any output from $chanlist. I started off simple with;

Code: Select all


set my_file onchan.chanlist
open $my_file w
puts $my_file [chanlist $my_chan]
close $my_file

Without any luck. Can anyone point me to why the above bind dosn't work and I can never seem to get any output from chanlist?

Thanks
First of all:

1) If you use a trigger in the bind you should use the PUB bind, not PUBM bind.
2) You have an incorrect number of arguments in your procedure, for bind pub or even pubm. It should be like this:

Code: Select all

bind pub - !writelist pub:write_chanlist

proc pub:write_chanlist {nick uhost hand chan text} {
 #your stuff here
}
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
S
Sikes
Voice
Posts: 3
Joined: Tue May 31, 2005 3:44 am

Post by Sikes »

Thanks for the reply awyeah.
1) If you use a trigger in the bind you should use the PUB bind, not PUBM bind.
Ok, was reading http://johoho.eggheads.org/eggdrop/other/guide2tcl.html
2) You have an incorrect number of arguments in your procedure, for bind pub or even pubm. It should be like this:

bind pub - !writelist pub:write_chanlist

proc pub:write_chanlist {nick uhost hand chan text} {
#your stuff here
}
I now have;

Code: Select all

bind pub - !writelist pub:write_chanlist
proc pub:write_chanlist {nick uhost hand chan text} {
                set my_file [open onchan.chanlist w]
...
But still no go getting any reply.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

You need to globalize my_nick and my_chan. Here try this:

Code: Select all

# Get list of current online usernames 
set my_chan "#accounts" 
set my_nick "Sikes" 

# pub bind
bind pub - !writelist pubm:write_chanlist 
# timer 3 minutes
timer 3 [list write:these 1 $my_chan $my_nick]

# procs
proc pubm:write_chanlist {nick uhost hand chan arg} {
  global my_chan my_nick
  write:these 0 $my_chan $my_nick
}

proc write:these {istimer chan nick} {
 set my_file [open onchan.chanlist w] 
 puts $my_file [chanlist $chan] 
 putserv "PRIVMSG $nick :Done" 
 close $my_file 
 if {$istimer} {
  timer 3 [list write:these $istimer $chan $nick]
 }
}
S
Sikes
Voice
Posts: 3
Joined: Tue May 31, 2005 3:44 am

Post by Sikes »

You need to globalize my_nick and my_chan. Here try this:
Thanks heaps Sir_Fz. You saved me a load of time. I wouldn't have got the syntax right without siiting down to properly learn TCL.

Appreciate all your help.

Sikes
Locked