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 

Same script with different output depending on channel

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
starpossen
Op


Joined: 10 Jan 2006
Posts: 139

PostPosted: Mon May 05, 2008 5:14 pm    Post subject: Same script with different output depending on channel Reply with quote

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
View user's profile Send private message
strikelight
Owner


Joined: 07 Oct 2002
Posts: 708

PostPosted: Mon May 05, 2008 7:04 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
starpossen
Op


Joined: 10 Jan 2006
Posts: 139

PostPosted: Mon May 05, 2008 7:30 pm    Post subject: Reply with quote

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
View user's profile Send private message
strikelight
Owner


Joined: 07 Oct 2002
Posts: 708

PostPosted: Mon May 05, 2008 7:38 pm    Post subject: Reply with quote

change the two lines that have:
Code:

putserv "PRIVMSG $chan :...."


to:

Code:

putserv "NOTICE $nick :..."
Back to top
View user's profile Send private message Visit poster's website
starpossen
Op


Joined: 10 Jan 2006
Posts: 139

PostPosted: Mon May 05, 2008 7:52 pm    Post subject: Reply with quote

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
View user's profile Send private message
strikelight
Owner


Joined: 07 Oct 2002
Posts: 708

PostPosted: Mon May 05, 2008 8:21 pm    Post subject: Reply with quote

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

set var "arg arg2"
Back to top
View user's profile Send private message Visit poster's website
starpossen
Op


Joined: 10 Jan 2006
Posts: 139

PostPosted: Mon May 05, 2008 8:43 pm    Post subject: Reply with quote

Okay, now i'm lost, could you please explain to me like I was very young hehe.
Back to top
View user's profile Send private message
strikelight
Owner


Joined: 07 Oct 2002
Posts: 708

PostPosted: Mon May 05, 2008 8:49 pm    Post subject: Reply with quote

<spoonfeed>
Code:

set linktext(#chan1) "\002link can be found at\002 http://link"

</spoonfeed>
Back to top
View user's profile Send private message Visit poster's website
starpossen
Op


Joined: 10 Jan 2006
Posts: 139

PostPosted: Mon May 05, 2008 9:05 pm    Post subject: Reply with quote

Okay I feel stupid now, that was obvious, maybe next time I should be rested before asking questions,thanks for dinner though Laughing
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 -> Script Requests 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