| View previous topic :: View next topic |
| Author |
Message |
Diablo228 Voice
Joined: 27 Sep 2007 Posts: 5
|
Posted: Thu Nov 13, 2008 9:46 pm Post subject: Making Scripts Channel Specific |
|
|
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 |
|
 |
tueb Halfop
Joined: 04 Oct 2007 Posts: 76 Location: #quiz.de @ irc.gamesurge.net
|
Posted: Fri Nov 14, 2008 5:18 am Post subject: |
|
|
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 |
|
 |
user

Joined: 18 Mar 2003 Posts: 1452 Location: Norway
|
Posted: Fri Nov 14, 2008 5:37 am Post subject: |
|
|
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 |
|
 |
|