| View previous topic :: View next topic |
| Author |
Message |
starpossen Op
Joined: 10 Jan 2006 Posts: 139
|
Posted: Mon May 05, 2008 5:14 pm Post subject: Same script with different output depending on channel |
|
|
What I wish for is, a script with a public command, output denpending on which channel the command is called.
example:
Channel1
command: !link
Result: visit http://******1.com
Channel2
command: !link
Result: visit http://******2.com
Meaning, same input on both channels, but different output
depending on which channel the command is called. |
|
| Back to top |
|
 |
strikelight Owner

Joined: 07 Oct 2002 Posts: 708
|
Posted: Mon May 05, 2008 7:04 pm Post subject: |
|
|
| Code: |
# configuration #
# use lowercase for chan names
set linktext(default) http://www.default.com/
set linktext(#chan1) http://www.chan1.com/
set linktext(#chan2) http://www.chan2.com/
# etc..
#end of config #
bind pub - !link proc:linktext
proc proc:linktext {nick uhost hand chan text} {
global linktext
set chan [string tolower $chan]
if {![info exists linktext($chan)]} {
putserv "PRIVMSG $chan :$linktext(default)"
} else {
putserv "PRIVMSG $chan :$linktext($chan)"
}
}
|
|
|
| Back to top |
|
 |
starpossen Op
Joined: 10 Jan 2006 Posts: 139
|
Posted: Mon May 05, 2008 7:30 pm Post subject: |
|
|
| Awsome, this works perfectly, thanks alot, I was wondering, where would I alter the script, so it would notice the one using the comand, so it won't show the output to the entire channel? |
|
| Back to top |
|
 |
strikelight Owner

Joined: 07 Oct 2002 Posts: 708
|
Posted: Mon May 05, 2008 7:38 pm Post subject: |
|
|
change the two lines that have:
| Code: |
putserv "PRIVMSG $chan :...."
|
to:
| Code: |
putserv "NOTICE $nick :..."
|
|
|
| Back to top |
|
 |
starpossen Op
Joined: 10 Jan 2006 Posts: 139
|
Posted: Mon May 05, 2008 7:52 pm Post subject: |
|
|
Damn.. awsome quick response and thanks again, I have yet another question (sorry to bug you)
I tried using some text formatting like so:
| Code: |
set linktext(#chan1) \002link can be found at\002 http://link
|
But I guess that was very far from correct since the bot crashed. |
|
| Back to top |
|
 |
strikelight Owner

Joined: 07 Oct 2002 Posts: 708
|
Posted: Mon May 05, 2008 8:21 pm Post subject: |
|
|
You'll need to encapsulate multiple arguments (words) in quotes or brackets...
ie.
set var "arg arg2" |
|
| Back to top |
|
 |
starpossen Op
Joined: 10 Jan 2006 Posts: 139
|
Posted: Mon May 05, 2008 8:43 pm Post subject: |
|
|
| Okay, now i'm lost, could you please explain to me like I was very young hehe. |
|
| Back to top |
|
 |
strikelight Owner

Joined: 07 Oct 2002 Posts: 708
|
Posted: Mon May 05, 2008 8:49 pm Post subject: |
|
|
<spoonfeed>
| Code: |
set linktext(#chan1) "\002link can be found at\002 http://link"
|
</spoonfeed> |
|
| Back to top |
|
 |
starpossen Op
Joined: 10 Jan 2006 Posts: 139
|
Posted: Mon May 05, 2008 9:05 pm Post subject: |
|
|
Okay I feel stupid now, that was obvious, maybe next time I should be rested before asking questions,thanks for dinner though  |
|
| Back to top |
|
 |
|