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.
Help for those learning Tcl or writing their own scripts.
ComputerTech
Master
Posts: 399 Joined: Sat Feb 22, 2020 10:29 am
Contact:
Post
by ComputerTech » Sat Nov 14, 2020 4:18 pm
Is it possible to let Bind Msg and Bind Pub use the same proc?
Like
Code: Select all
bind pub - !blah blah:blah
bind msg - blah blah:blah
proc blah:blah {nick host hand chan text} {
putserv "PRIVMSG $chan :blah"
}
but somehow remove the variable "text" in the proc when using bind msg?
Thanks in advanced
ComputerTech
CrazyCat
Revered One
Posts: 1306 Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:
Post
by CrazyCat » Sat Nov 14, 2020 6:55 pm
No, you can't. In msg, you don't have the channel.
You can just do the following to "translate" pub to msg:
Code: Select all
bind pub - !blah pub:blah
bind msg - !blah blah
proc pub:blah {nick uhost handle chan text} {
blah $nick $uhost $handle $text
}
proc blah {nick uhost handle text} {
putserv "PRIVMSG $nick :hello"
}
Or you can do the other way, but you'll have to force msg to be something like "!blah #chan hello pple":
Code: Select all
bind pub - !blah blah
bind msg - !blah msg:blah
proc blah {nick uhost handle chan text} {
putserv "PRIVMSG $chan :$text"
}
proc msg:blah {nick uhost handle text} {
set chan [join [lindex [split $text] 0]]
# check that $chan is really a channel or exit
set msg [join [lrange [split $text] 1 end]]
blah $nick $uhost $handle $chan $msg
}
willyw
Revered One
Posts: 1205 Joined: Thu Jan 15, 2009 12:55 am
Post
by willyw » Sat Nov 14, 2020 6:59 pm
ComputerTech wrote:
...
but somehow remove the variable "text" in the proc when using bind msg?
When calling the proc with a bind msg, how is it going to know what channel to post in? Is it fixed?.... just one channel?... and thus you can hard code it?
In other words: Need more info.
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !