CHANNELS MODULE
TCL COMMANDS:
channel add <name> <option-list>
adds a channel record for the bot to monitor; the full list of possible options is given in the "eggdrop.conf" sample config file; note that the channel options must be in a list (enclosed in {})
returns: nothing

channel set <name> <options...>
sets options for the channel specified; the full list of possible options is given in the "eggdrop.conf" sample config file
returns: nothing

channel info <name>
returns: list of info about that channel record: enforced mode, idle kick limit, need-op script, need-invite script, and then various +/- options as seen in the config file

channel remove <name>
destroys a channel record for the bot and makes the bot no longer monitor that channel
returns: nothing

savechannels
saves the channel settings to the channel-file if one is defined.
returns: nothing

loadchannels
reloads the channel settings from the channel-file if one is defined.
returns: nothing

channels
returns: list of the channels the bot is monitoring (or trying to)

validchan <channel>
checks if the bot is monitoring that channel
returns: 1 if the channel exists, 0 if not

isdynamic <channel>
returns: 1 if the channel is an existing dynamic channel, 0 if not

newchanban <channel> <ban> <creator> <comment> [lifetime] [options]
adds a ban to the enforced ban list of a channel; creator is given credit for the ban in the ban list; lifetime is specified in minutes; if lifetime is not specified, ban-time (usually 60) is used; setting the lifetime to 0 makes it a permanent ban; valid options are:

sticky - forces the ban to be always active on a channel, even with dynamic bans on
none - (no effect)
returns: nothing

newban <ban> <creator> <comment> [lifetime] [options]
adds a ban to the global ban list (which takes effect on all channels); other arguments work exactly like newchanban
returns: nothing

killchanban <channel> <ban>
removes a ban from the enforced ban list for a channel
returns: "1" if successful, "0" otherwise

killban <ban>
removes a ban from the global ban list
returns: "1" if successful, "0" otherwise

isban <ban> [channel]
returns: "1" if that ban is in the global ban list, "0" otherwise; if a channel is specified, that channel's ban list is checked too

ispermban <ban> [channel]
returns: "1" if that ban is in the global ban list AND is marked as permanent, "0" otherwise; if a channel is specified, that channel's ban list is checked too

matchban <nick!user@host> [channel]
returns: "1" if that user address matches a ban in the global ban list, "0" otherwise; if a channel is specified, that channel's ban list is checked too

banlist [channel]
returns: list of global bans, or (if a channel is specified) list of channel-specific bans; each entry is itself a list, containing: hostmask, comment, expiration timestamp, time added, last time active, and creator (the three timestamps are in unixtime format)

addchanrec <handle> <channel>
add a channel record for the user
returns: "1" on success, "0" if the user does not exist or if there isn't such a channel

delchanrec <handle> <channel>
removes a channel record for the user; this includes all associated channel flags
returns: "1" on success, "0" if the user does not exist or if there isn't such a channel

getchaninfo <handle> <channel>
returns: info line for a specific channel (behaves just like 'getinfo')

setchaninfo <handle> <channel> <info>
sets the info line on a specific channel for a user
returns: nothing

setlaston <handle> [channel] [time]
sets the laston time for a user, if a channel is specified then the channel laston time is set, otherwise the global one is set, if no time is given the current time is used.


TCL VARIABLES:
share-greet 0/1
If sharing userfiles, share info lines?

use-info 0/1
Allow use of global & channel info lines

ban-time <mins>
Set the time a ban will be kept on a dynamicbans channel

chanfile
Where to store settings set using +/-chan, settings in this file OVERRIDE config file settings. If you want the config file settings to override, set this to ""


C FUNCTIONS:
The following C functions are exported by this module for use by other modules, all of these are part of the modcall_channels structure, which can be found by calling module_depends(ME,"channels",1,1,0)
int setsticky_ban (struct chanset_t * chan, chat * ban, int yn);
set a ban sticky or unsticky, chan = channel (NULL for global ban), ban = ban, either a number (eg "1") or the ban itself, yn = yes/no for stick/unstick

int delban (struct chanset_t * chan, char * ban, int doit);
remove a ban for a channel (or global if chan == NULL), ban can be a string for the ban or a string number which is counted down to 0, doit is 1 for delete, 0 for counting through

int addban (struct chanset_t * chan, char * ban, char * from, char * note, time_t expire_time, int flags);
add a new channel ban (global ban if chan == NULL), ban is the ban, from is who set it, note is a descriptive note on the ban, expire_time is how long the ban lasts. flags is any of:

BANREC_STICKY: make this ban a sticky ban
BANREC_PERM: make this ban a permanent ban
int write_bans (FILE * file, int idx);
writes all the bans to the file file, as if being prepared for a userfile send to the bot specified by idx, (-1 = global write) This only really exists for the sharing module.

struct chanuserrec * get_chanrec (struct userrec * u, char * chan);
Returns the channel record for a user (u) associated with channel chan, or NULL if no such channel record exists.

struct chanuserrec * add_chanrec (struct userrec * u, char * chan);
Adds a new channel record (or returns the old one if it exists already) for a user (u) with channel chan. chan must be a valid channel or NULL will be returned.

void del_chanrec (struct userrec * u, char *);
Removes a channel record for a user (u) of channel chan. Silently fails if no such channel record exists.

void set_handle_chaninfo (struct userrec * userlist, char * handle, char * channel, char * info);
Sets the channel info for user handle (in userlist - there can be 2 userlists during sharing transfer) on channel channel to info.

int match_ban (struct chanset_t * chan, char * hostmask);
Returns 1 if the given host mask matches a ban on the given channel (global bans if chan == NULL)

int equals_ban (struct chanset_t * chan, char * ban);
Returns 1 if the given ban is in the banlist for the given channel, 2 if the ban is sticky.

void set_handle_laston (char * chan, struct userrec * u, time_t when);
Set a users laston time, chan = "*" for global time, otherwise specifies a channel record which must exist (otherwise it's not set)

void get_handle_chaninfo (char * handle, char * channel, char * buffer);
Sets buffer to equal a users channel specific info line for the given channel (if one exists)

C VARIABLES:
int ban_time
time in minutes for bans to last

int use_info
use info lines?


EXTENDABLE CHANNEL SETTINGS:
It is now possible to add additional settings for channels, to do so, first define a chan_settings_type structure and pass it to add_chan_settings, this will initialise the settings for each current channel (and cause it to be added to any new channels) (to ensure a clean cleanup of your module be sure to rem_chan_settings in you close function). To access the settings from you module use find_chan_settings.

The structure:

struct chan_settings_type {
struct chan_settings_type * next;
int (*set_handler) ( struct chan_settings * cst, char * arg1, char * arg2, int idx);
void (*view_handler) ( int idx, struct chan_settings * );
int (*write_handler) ( FILE *, struct chan_settings * );
int (*get_handler) ( Tcl_Interp *, struct chan_settings *);
void (*init_handler) (struct chan_settings *);
void (*kill_handler) (struct chan_settings *);
int (*expmem_handler) (struct chan_settings *);
};

Explanation:

next
internally used pointer

set_handler
this is called any time the setting is set, from tcl, the chanfile or by using .chanset, cst is the relevant channel settings, arg1 & arg2 are then next 2 arguments, idx is a users idx (-1 if internally set), return 0 if you dont process this setting, 1 if you only use arg1, 2 if you use both arguments

view_handler
this function displays the channel settings defined by this type to the user

write_handler
this function writes the setting out to the chanfile, it should be in the form 'channel set <#channel> settings\n'

get_handler
this function is used to output the value of the settings to tcl

init_handler
this function is called every time the setting is created for a channel, allowing additional setup to be done

kill_handler
this function is called every time the setting is destroyed for a channel, allowing you to cleanup the structures

expmem_handler
if any memory was malloced for this setting (type memtype_settings) it should be tallyed in this function for memory checking)

The actual channel setings structure:

struct chan_settings {
struct chan_settings_type * type; /* points to the structure above */
struct chan_settings * next; /* internal list var */
struct chanset_t * chan; /* the channel for this setting */
void * extra; /* you can use this to point to any extra allocated memory */
};
struct chan_settings * find_chan_settings (struct chanset_t * chan, struct chan_settings_type * type)
lookup a channel setting for a channel, it *should* always exist.

void add_chan_settings (struct chan_settings_type * type)
void rem_chan_settings (struct chan_settings_type * type)

add/remove a channel setting type, calling init/kill for each existing channel.

Shown below are the list of built-in settings, and then the extra structure:

CHANSET_FLOOD - flood settings

struct chan_settings_flood {
int pub_thr;
int pub_time;
int join_thr;
int join_time;
int deop_thr;
int deop_time;
int kick_thr;
int kick_time;
int ctcp_thr;
int ctcp_time;
};
CHANSET_CHANMODE - protect mode settings
struct chan_settings_chanmode {
int pls_prot; /* modes to enforce */
int mns_prot; /* modes to reject */
int limit_prot; /* desired limit */
char key_prot[121]; /* desired password */
};
CHANSET_IDLE - max idle time
(long)extra = minutes
CHANSET_FLAGS - various +/- flags extra
No structure is used
*NOTE*: all memory used in channel settings should be my_malloc'd from memtype_settings

(c) 1997 Robey Pointer
(c) 1998 Eggdrop Development Team