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.

Channel-Specific Information

Old posts that have not been replied to for several years.
Locked
m
mike-c
Voice
Posts: 20
Joined: Thu Jul 25, 2002 3:40 pm

Channel-Specific Information

Post by mike-c »

Hi,

Please excuse the length of this post, it needs explaining :)

I'm looking to write a script that gets channel-specific details, and uses them accordingly...

I've thought of 3 ways to do this (although i'm not sure if 2 of them are possible):

1) text file for each channel, 1 setting per line
2) have 'set channel_var whatever' in the tcl
3) Use .chanset settings

#1 I'm sure could be done easily, but this is not my preferred option, as it requires the editing of text files to change the settings (without writing fancy text editing code from dcc commands)

#2 I have attempted - I've tried various things but cannot get it to interpret the settings:

Code: Select all

bind pub -|- "!info" Info_pub
proc Info_pub {nick uhost hand chan text} {
  set channel [string tolower $chan]
  set mychannel_setting1 foo
  <code goes here>
}
If I use:

Code: Select all

set Setting1 $[string trimleft $channel #]_setting1
the code later on puts this to the channel:
Channel Info: $mychannel_setting1
(The channel is #mychannel) - it's returning it as a string, not the value of it.

Now if I use:

Code: Select all

set Setting1 [$[string trimleft $channel #]_setting1]
I get a tcl error saying
Tcl error [Info_pub]: invalid command name "$mychannel_setting1"
No matter what I try, it doesn't return the actual value of the variable... How can this be done? (if it can be)

#3 is my preferred method, but I'm not sure if it's possible... Is it possible to store strings using .chanset, like you do with
.chanset #mychannel need-op ...
... can you create custom settings? And then how do you read those settings?


If you managed to read this far, thank you :) I'm really stuck on this, i've been trying to solve it all night. All help appreciated :)

Cheers,

Mike
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

For #2, you're best off using arrays. Instead of having channame_setting1 as the var, why not have setting1(channame)? Then your config section will look something like

Code: Select all

set setting1(#chan1) abc
set setting2(#chan1) def

set setting1(#chan2) ghi
set setting2(#chan2) jkl

proc info_pub {nick uhost hand chan text} {
  global setting1 setting2
  set chan [string tolower $chan]
  blah blah $setting1($chan)
}
#3 is possible... but only with eggdrop 1.6.14 (current cvs version). Yes, people can access it with using the .chanset dcc command. If you want to do it, it goes something like:

Code: Select all

setudef str setting1
setudef str setting2
proc info_pub {nick uhost hand chan text} {
  set val [channel get $chan setting1]
}
m
mike-c
Voice
Posts: 20
Joined: Thu Jul 25, 2002 3:40 pm

Post by mike-c »

I've coded it using method #1 (setting files), and it works great....

I went off #2 as that is actually harder than #1 to change things (requires rehash)

#3 is the ideal, but if it's only on the cvs release, I guess i'll wait (I'm on 1.6.13 atm)

when 1.6.14 is out, i'll think about rewriting it :)

thanks

Mike
m
mike-c
Voice
Posts: 20
Joined: Thu Jul 25, 2002 3:40 pm

Post by mike-c »

hmm... on a slightly different topic, as I'm using the settings files for the moment... how would you count the number of files in a directory? (eg. the number of channels with settings)

either the search function doesn't like me, I'm blind, or it's not been asked :lol:

Cheers,

Mike
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Aren't files also inconvenient? You have to edit the file each time you want to change the setting. You may want to add a dcc command to let the owner change settings from the dcc console. That brings you the ease of use of #3 with the compatibility of #1 and #2.
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

It would be simpler to combine #1 and #2 together.

Store current settings in memory. Read them at startup, save them at shutdown, save/read on rehash.
Locked