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.

Making Scripts Channel Specific

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
D
Diablo228
Voice
Posts: 5
Joined: Thu Sep 27, 2007 8:30 pm

Making Scripts Channel Specific

Post by Diablo228 »

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

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.
t
tueb
Halfop
Posts: 76
Joined: Thu Oct 04, 2007 6:09 am
Location: #quiz.de @ irc.gamesurge.net
Contact:

Post by tueb »

Hi,

I had a similar problem and simply used:

Code: Select all

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

at the beginning of the "proc's".


Hope that helps,

tueb
#Quiz.de @ irc.GameSurge.net
JavaChat
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

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

setudef flag nameOfTheGame
include the following snippet as the first line in any proc that needs to be limited:

Code: Select all

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"?
Post Reply