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.

Same script with different output depending on channel

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
s
starpossen
Op
Posts: 139
Joined: Tue Jan 10, 2006 1:08 am

Same script with different output depending on channel

Post by starpossen »

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.
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

Code: Select all

# 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)"
  }
}
s
starpossen
Op
Posts: 139
Joined: Tue Jan 10, 2006 1:08 am

Post by starpossen »

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?
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

change the two lines that have:

Code: Select all

putserv "PRIVMSG $chan :...."
to:

Code: Select all

putserv "NOTICE $nick :..."
s
starpossen
Op
Posts: 139
Joined: Tue Jan 10, 2006 1:08 am

Post by starpossen »

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: Select all

set linktext(#chan1) \002link can be found at\002 http://link
But I guess that was very far from correct since the bot crashed.
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

You'll need to encapsulate multiple arguments (words) in quotes or brackets...
ie.

set var "arg arg2"
s
starpossen
Op
Posts: 139
Joined: Tue Jan 10, 2006 1:08 am

Post by starpossen »

Okay, now i'm lost, could you please explain to me like I was very young hehe.
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

<spoonfeed>

Code: Select all

set linktext(#chan1) "\002link can be found at\002 http://link"
</spoonfeed>
s
starpossen
Op
Posts: 139
Joined: Tue Jan 10, 2006 1:08 am

Post by starpossen »

Okay I feel stupid now, that was obvious, maybe next time I should be rested before asking questions,thanks for dinner though :lol:
Post Reply