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 

Making Scripts Channel Specific

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


Joined: 27 Sep 2007
Posts: 5

PostPosted: Thu Nov 13, 2008 9:46 pm    Post subject: Making Scripts Channel Specific Reply with quote

I have numerous Game & Channel Management scripts loaded on my Eggdrop (v 1.6.19). Some scripts have in-built functionality for specifying the respective #Channel the script should work on, and some don't. My bot sits on two Channels. #Games and #Help. We have some geniuses who activate the games on #Help.

1) As a counter-measure I was wondering if there is a "bind" syntax that limits the commands to one specific channel?

2) Alternatively, could there be a 'quick proc' at the beginning of each TCL script to check if the commands are being issued in the right channel? I want this proc to be more universal in nature, rather than being script specific.

Would this work:

Code:
set channels "#Games"
if {[lsearch -exact $channels $chan] == -1} {return 0}
else {
... execute rest of the script
}


Theoretically, I know what I want to do, but I am unable to implement it due to my lack of scripting knowledge. I tried playing around with "setudef flag" too, without much success. Thanks in advance for any replies.
Back to top
View user's profile Send private message
tueb
Halfop


Joined: 04 Oct 2007
Posts: 76
Location: #quiz.de @ irc.gamesurge.net

PostPosted: Fri Nov 14, 2008 5:18 am    Post subject: Reply with quote

Hi,

I had a similar problem and simply used:


Code:

if {[string tolower $channel] != "#games"} {
   return
}



at the beginning of the "proc's".


Hope that helps,

tueb
_________________
#Quiz.de @ irc.GameSurge.net
JavaChat
Back to top
View user's profile Send private message Visit poster's website
user
 


Joined: 18 Mar 2003
Posts: 1452
Location: Norway

PostPosted: Fri Nov 14, 2008 5:37 am    Post subject: Reply with quote

If you only want your game to work in a single channel, the code provided by tueb is fine, but if you want a more flexible way to manage what channels your games work in, create a new channel setting using setudef:
Code:
setudef flag nameOfTheGame

include the following snippet as the first line in any proc that needs to be limited:
Code:
if {![channel get $chan nameOfTheGame]} return

and use .chanset #chan +/-nameOfTheGame to enable/disable the game in your channels.
_________________
Have you ever read "The Manual"?
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