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 

Using Bind msg and Bind Pub for one Proc

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
ComputerTech
Master


Joined: 22 Feb 2020
Posts: 393

PostPosted: Sat Nov 14, 2020 4:18 pm    Post subject: Using Bind msg and Bind Pub for one Proc Reply with quote

Is it possible to let Bind Msg and Bind Pub use the same proc?

Like
Code:

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 Very Happy
_________________
ComputerTech
Back to top
View user's profile Send private message Send e-mail Visit poster's website
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Sat Nov 14, 2020 6:55 pm    Post subject: Reply with quote

No, you can't. In msg, you don't have the channel.
You can just do the following to "translate" pub to msg:
Code:
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:
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
}

_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
willyw
Revered One


Joined: 15 Jan 2009
Posts: 1175

PostPosted: Sat Nov 14, 2020 6:59 pm    Post subject: Re: Using Bind msg and Bind Pub for one Proc Reply with quote

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 !
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help 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