2004-05-16 14:58:40 +00:00
|
|
|
/* +------------------------------------+
|
|
|
|
* | Inspire Internet Relay Chat Daemon |
|
|
|
|
* +------------------------------------+
|
|
|
|
*
|
2006-01-15 15:59:11 +00:00
|
|
|
* InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
|
2004-05-16 14:58:40 +00:00
|
|
|
* E-mail:
|
|
|
|
* <brain@chatspike.net>
|
|
|
|
* <Craig@chatspike.net>
|
|
|
|
*
|
|
|
|
* Written by Craig Edwards, Craig McLure, and others.
|
|
|
|
* This program is free but copyrighted software; see
|
|
|
|
* the file COPYING for details.
|
|
|
|
*
|
|
|
|
* ---------------------------------------------------
|
|
|
|
*/
|
2003-01-23 19:45:57 +00:00
|
|
|
|
2006-01-12 20:14:43 +00:00
|
|
|
#ifndef __CHANNELS_H__
|
|
|
|
#define __CHANNELS_H__
|
|
|
|
|
2003-01-23 19:45:57 +00:00
|
|
|
#include "inspircd_config.h"
|
2003-01-26 23:53:03 +00:00
|
|
|
#include "base.h"
|
2003-01-23 19:45:57 +00:00
|
|
|
#include <time.h>
|
|
|
|
#include <vector>
|
2004-04-04 13:41:01 +00:00
|
|
|
#include <string>
|
2006-01-12 20:14:43 +00:00
|
|
|
#include <map>
|
2003-01-23 19:45:57 +00:00
|
|
|
|
2006-03-12 18:03:02 +00:00
|
|
|
/** RFC1459 channel modes
|
|
|
|
*/
|
2006-03-08 18:25:51 +00:00
|
|
|
enum ChannelModes {
|
2006-03-12 14:26:15 +00:00
|
|
|
CM_TOPICLOCK = 't'-65,
|
|
|
|
CM_NOEXTERNAL = 'n'-65,
|
|
|
|
CM_INVITEONLY = 'i'-65,
|
|
|
|
CM_MODERATED = 'm'-65,
|
|
|
|
CM_SECRET = 's'-65,
|
|
|
|
CM_PRIVATE = 'p'-65,
|
|
|
|
CM_KEY = 'k'-65,
|
|
|
|
CM_LIMIT = 'l'-65
|
2006-03-08 18:25:51 +00:00
|
|
|
};
|
2005-05-12 18:42:06 +00:00
|
|
|
|
2005-12-14 17:10:40 +00:00
|
|
|
class userrec;
|
2006-08-08 13:22:30 +00:00
|
|
|
class chanrec;
|
2005-12-14 17:10:40 +00:00
|
|
|
|
2003-01-23 19:45:57 +00:00
|
|
|
/** Holds an entry for a ban list, exemption list, or invite list.
|
|
|
|
* This class contains a single element in a channel list, such as a banlist.
|
|
|
|
*/
|
2003-01-26 23:53:03 +00:00
|
|
|
class HostItem : public classbase
|
2003-01-23 19:45:57 +00:00
|
|
|
{
|
|
|
|
public:
|
2006-08-08 16:47:14 +00:00
|
|
|
/** Time the item was added
|
|
|
|
*/
|
2003-01-23 19:45:57 +00:00
|
|
|
time_t set_time;
|
2006-08-08 16:47:14 +00:00
|
|
|
/** Who added the item
|
|
|
|
*/
|
2003-01-23 19:45:57 +00:00
|
|
|
char set_by[NICKMAX];
|
2006-08-08 16:47:14 +00:00
|
|
|
/** The actual item data
|
|
|
|
*/
|
2003-01-23 19:45:57 +00:00
|
|
|
char data[MAXBUF];
|
|
|
|
|
|
|
|
HostItem() { /* stub */ }
|
|
|
|
virtual ~HostItem() { /* stub */ }
|
|
|
|
};
|
|
|
|
|
|
|
|
/** A subclass of HostItem designed to hold channel bans (+b)
|
|
|
|
*/
|
|
|
|
class BanItem : public HostItem
|
|
|
|
{
|
|
|
|
};
|
|
|
|
|
|
|
|
/** A subclass of HostItem designed to hold channel exempts (+e)
|
|
|
|
*/
|
|
|
|
class ExemptItem : public HostItem
|
|
|
|
{
|
|
|
|
};
|
|
|
|
|
|
|
|
/** A subclass of HostItem designed to hold channel invites (+I)
|
|
|
|
*/
|
|
|
|
class InviteItem : public HostItem
|
|
|
|
{
|
|
|
|
};
|
|
|
|
|
|
|
|
/** Holds a complete ban list
|
|
|
|
*/
|
2005-05-16 11:31:58 +00:00
|
|
|
typedef std::vector<BanItem> BanList;
|
2003-01-23 19:45:57 +00:00
|
|
|
|
|
|
|
/** Holds a complete exempt list
|
|
|
|
*/
|
2005-05-16 11:31:58 +00:00
|
|
|
typedef std::vector<ExemptItem> ExemptList;
|
2003-01-23 19:45:57 +00:00
|
|
|
|
|
|
|
/** Holds a complete invite list
|
|
|
|
*/
|
2005-05-16 11:31:58 +00:00
|
|
|
typedef std::vector<InviteItem> InviteList;
|
2003-01-23 19:45:57 +00:00
|
|
|
|
2006-03-08 18:59:55 +00:00
|
|
|
/** A list of users on a channel
|
|
|
|
*/
|
|
|
|
typedef std::map<userrec*,userrec*> CUList;
|
|
|
|
|
2006-04-10 20:38:26 +00:00
|
|
|
/** Shorthand for CUList::iterator
|
|
|
|
*/
|
|
|
|
typedef CUList::iterator CUListIter;
|
2006-08-08 16:47:14 +00:00
|
|
|
|
|
|
|
/** Shorthand for CUList::const_iterator
|
|
|
|
*/
|
2006-04-10 20:38:26 +00:00
|
|
|
typedef CUList::const_iterator CUListConstIter;
|
|
|
|
|
2006-03-08 23:16:18 +00:00
|
|
|
/** A list of custom modes parameters on a channel
|
|
|
|
*/
|
|
|
|
typedef std::map<char,char*> CustomModeList;
|
|
|
|
|
2006-08-08 13:22:30 +00:00
|
|
|
|
|
|
|
/** used to hold a channel and a users modes on that channel, e.g. +v, +h, +o
|
2006-08-08 16:47:14 +00:00
|
|
|
*/
|
2006-08-08 13:22:30 +00:00
|
|
|
enum UserChannelModes {
|
|
|
|
UCMODE_OP = 1,
|
|
|
|
UCMODE_VOICE = 2,
|
|
|
|
UCMODE_HOP = 4
|
|
|
|
};
|
|
|
|
|
|
|
|
/** Holds a user's modes on a channel
|
|
|
|
* This class associates a users privilages with a channel by creating a pointer link between
|
|
|
|
* a userrec and chanrec class. The uc_modes member holds a bitmask of which privilages the user
|
|
|
|
* has on the channel, such as op, voice, etc.
|
|
|
|
*/
|
|
|
|
class ucrec : public classbase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/** Contains a bitmask of the UCMODE_OP ... UCMODE_FOUNDER values.
|
|
|
|
* If this value is zero, the user has no privilages upon the channel.
|
|
|
|
*/
|
|
|
|
char uc_modes;
|
|
|
|
|
|
|
|
/** Points to the channel record where the given modes apply.
|
|
|
|
* If the record is not in use, this value will be NULL.
|
|
|
|
*/
|
|
|
|
chanrec *channel;
|
|
|
|
|
|
|
|
/** Constructor for ucrec
|
|
|
|
*/
|
|
|
|
ucrec() : uc_modes(0), channel(NULL) { /* stub */ }
|
|
|
|
|
|
|
|
/** Destructor for ucrec
|
|
|
|
*/
|
|
|
|
virtual ~ucrec() { /* stub */ }
|
|
|
|
};
|
|
|
|
|
2006-08-09 18:55:52 +00:00
|
|
|
class InspIRCd;
|
|
|
|
|
2006-08-23 20:50:20 +00:00
|
|
|
/** A stored prefix and its rank
|
|
|
|
*/
|
2006-08-23 20:20:41 +00:00
|
|
|
typedef std::pair<char, unsigned int> prefixtype;
|
2006-08-23 20:50:20 +00:00
|
|
|
|
|
|
|
/** A list of prefixes set on a user in a channel
|
|
|
|
*/
|
2006-08-23 20:20:41 +00:00
|
|
|
typedef std::vector<prefixtype> pfxcontainer;
|
2006-08-23 20:50:20 +00:00
|
|
|
|
|
|
|
/** A list of users with zero or more prefixes set on them
|
|
|
|
*/
|
2006-08-23 20:20:41 +00:00
|
|
|
typedef std::map<userrec*, std::vector<prefixtype> > prefixlist;
|
2006-08-08 13:22:30 +00:00
|
|
|
|
2003-01-23 19:45:57 +00:00
|
|
|
/** Holds all relevent information for a channel.
|
|
|
|
* This class represents a channel, and contains its name, modes, time created, topic, topic set time,
|
|
|
|
* etc, and an instance of the BanList type.
|
|
|
|
*/
|
2004-04-29 15:23:20 +00:00
|
|
|
class chanrec : public Extensible
|
2003-01-23 19:45:57 +00:00
|
|
|
{
|
2006-08-08 13:22:30 +00:00
|
|
|
private:
|
|
|
|
|
2006-08-09 18:55:52 +00:00
|
|
|
/** Pointer to creator object
|
|
|
|
*/
|
|
|
|
InspIRCd* ServerInstance;
|
|
|
|
|
2006-08-08 13:22:30 +00:00
|
|
|
/** Connect a chanrec to a userrec
|
|
|
|
*/
|
2006-08-09 18:55:52 +00:00
|
|
|
static chanrec* ForceChan(InspIRCd* Instance, chanrec* Ptr,ucrec *a,userrec* user, int created);
|
2006-08-08 13:22:30 +00:00
|
|
|
|
2006-08-23 20:20:41 +00:00
|
|
|
prefixlist prefixes;
|
|
|
|
|
2003-01-23 19:45:57 +00:00
|
|
|
public:
|
|
|
|
/** The channels name.
|
|
|
|
*/
|
2006-08-08 16:47:14 +00:00
|
|
|
char name[CHANMAX];
|
|
|
|
|
2006-03-12 18:03:02 +00:00
|
|
|
/** Modes for the channel.
|
|
|
|
* This is not a null terminated string! It is a hash where
|
|
|
|
* each item in it represents if a mode is set. For example
|
|
|
|
* for mode +A, index 0. Use modechar-65 to calculate which
|
|
|
|
* field to check.
|
2003-01-23 19:45:57 +00:00
|
|
|
*/
|
2006-03-12 18:03:02 +00:00
|
|
|
char modes[64];
|
2005-04-26 15:14:05 +00:00
|
|
|
|
2006-03-08 23:16:18 +00:00
|
|
|
/** User lists
|
|
|
|
* There are four user lists, one for
|
|
|
|
* all the users, one for the ops, one for
|
|
|
|
* the halfops and another for the voices.
|
2005-04-26 17:01:59 +00:00
|
|
|
*/
|
2006-03-08 18:59:55 +00:00
|
|
|
CUList internal_userlist;
|
2006-08-08 16:47:14 +00:00
|
|
|
|
|
|
|
/** Opped users
|
|
|
|
*/
|
2006-03-08 18:59:55 +00:00
|
|
|
CUList internal_op_userlist;
|
2006-08-08 16:47:14 +00:00
|
|
|
|
|
|
|
/** Halfopped users
|
|
|
|
*/
|
2006-03-08 18:59:55 +00:00
|
|
|
CUList internal_halfop_userlist;
|
2006-08-08 16:47:14 +00:00
|
|
|
|
|
|
|
/** Voiced users
|
|
|
|
*/
|
2006-03-08 18:59:55 +00:00
|
|
|
CUList internal_voice_userlist;
|
2006-02-03 17:20:40 +00:00
|
|
|
|
2006-02-15 20:30:29 +00:00
|
|
|
/** Parameters for custom modes
|
|
|
|
*/
|
2006-03-08 23:16:18 +00:00
|
|
|
CustomModeList custom_mode_params;
|
2006-02-15 20:30:29 +00:00
|
|
|
|
2003-01-23 19:45:57 +00:00
|
|
|
/** Channel topic.
|
|
|
|
* If this is an empty string, no channel topic is set.
|
|
|
|
*/
|
2006-03-08 23:16:18 +00:00
|
|
|
char topic[MAXTOPIC];
|
2003-01-23 19:45:57 +00:00
|
|
|
/** Creation time.
|
|
|
|
*/
|
|
|
|
time_t created;
|
|
|
|
/** Time topic was set.
|
|
|
|
* If no topic was ever set, this will be equal to chanrec::created
|
|
|
|
*/
|
|
|
|
time_t topicset;
|
|
|
|
/** The last user to set the topic.
|
|
|
|
* If this member is an empty string, no topic was ever set.
|
|
|
|
*/
|
|
|
|
char setby[NICKMAX];
|
|
|
|
|
|
|
|
/** Contains the channel user limit.
|
|
|
|
* If this value is zero, there is no limit in place.
|
|
|
|
*/
|
2005-05-12 18:42:06 +00:00
|
|
|
short int limit;
|
2003-01-23 19:45:57 +00:00
|
|
|
|
|
|
|
/** Contains the channel key.
|
|
|
|
* If this value is an empty string, there is no channel key in place.
|
|
|
|
*/
|
|
|
|
char key[32];
|
2006-08-08 16:47:14 +00:00
|
|
|
|
2003-01-23 19:45:57 +00:00
|
|
|
/** The list of all bans set on the channel.
|
|
|
|
*/
|
|
|
|
BanList bans;
|
2004-04-03 15:46:53 +00:00
|
|
|
|
2003-04-19 12:41:44 +00:00
|
|
|
/** Sets or unsets a custom mode in the channels info
|
2005-05-25 22:01:10 +00:00
|
|
|
* @param mode The mode character to set or unset
|
|
|
|
* @param mode_on True if you want to set the mode or false if you want to remove it
|
2003-04-19 12:41:44 +00:00
|
|
|
*/
|
2006-07-08 21:37:16 +00:00
|
|
|
void SetMode(char mode,bool mode_on);
|
2003-04-19 12:41:44 +00:00
|
|
|
|
2004-04-03 15:46:53 +00:00
|
|
|
/** Sets or unsets the parameters for a custom mode in a channels info
|
2005-05-25 22:01:10 +00:00
|
|
|
* @param mode The mode character to set or unset
|
|
|
|
* @param parameter The parameter string to associate with this mode character
|
|
|
|
* @param mode_on True if you want to set the mode or false if you want to remove it
|
2003-04-19 12:41:44 +00:00
|
|
|
*/
|
2006-07-09 16:40:58 +00:00
|
|
|
void SetModeParam(char mode,const char* parameter,bool mode_on);
|
2003-04-19 12:41:44 +00:00
|
|
|
|
2006-03-12 14:49:30 +00:00
|
|
|
/** Returns true if a mode is set on a channel
|
2005-05-25 22:01:10 +00:00
|
|
|
* @param mode The mode character you wish to query
|
|
|
|
* @return True if the custom mode is set, false if otherwise
|
2004-04-04 13:41:01 +00:00
|
|
|
*/
|
2006-03-12 14:49:30 +00:00
|
|
|
bool IsModeSet(char mode);
|
2004-04-04 13:41:01 +00:00
|
|
|
|
|
|
|
/** Returns the parameter for a custom mode on a channel.
|
2005-05-25 22:01:10 +00:00
|
|
|
* @param mode The mode character you wish to query
|
|
|
|
*
|
2004-04-04 13:41:01 +00:00
|
|
|
* For example if "+L #foo" is set, and you pass this method
|
|
|
|
* 'L', it will return '#foo'. If the mode is not set on the
|
|
|
|
* channel, or the mode has no parameters associated with it,
|
|
|
|
* it will return an empty string.
|
2005-05-25 22:01:10 +00:00
|
|
|
*
|
|
|
|
* @return The parameter for this mode is returned, or an empty string
|
2004-04-04 13:41:01 +00:00
|
|
|
*/
|
|
|
|
std::string GetModeParameter(char mode);
|
|
|
|
|
2005-04-26 17:09:25 +00:00
|
|
|
/** Obtain the channel "user counter"
|
|
|
|
* This returns the channel reference counter, which is initialized
|
|
|
|
* to 0 when the channel is created and incremented/decremented
|
|
|
|
* upon joins, parts quits and kicks.
|
2005-05-25 22:01:10 +00:00
|
|
|
*
|
|
|
|
* @return The number of users on this channel
|
2005-04-26 17:09:25 +00:00
|
|
|
*/
|
2005-04-26 15:14:05 +00:00
|
|
|
long GetUserCounter();
|
|
|
|
|
2005-04-26 17:09:25 +00:00
|
|
|
/** Add a user pointer to the internal reference list
|
2006-03-08 23:16:18 +00:00
|
|
|
* @param user The user to add
|
2005-05-25 22:01:10 +00:00
|
|
|
*
|
2005-04-26 17:09:25 +00:00
|
|
|
* The data inserted into the reference list is a table as it is
|
|
|
|
* an arbitary pointer compared to other users by its memory address,
|
|
|
|
* as this is a very fast 32 or 64 bit integer comparison.
|
|
|
|
*/
|
2006-03-08 23:16:18 +00:00
|
|
|
void AddUser(userrec* user);
|
2006-08-08 16:47:14 +00:00
|
|
|
|
|
|
|
/** Add a user pointer to the internal reference list of opped users
|
|
|
|
* @param user The user to add
|
|
|
|
*/
|
2006-03-08 23:16:18 +00:00
|
|
|
void AddOppedUser(userrec* user);
|
2006-08-08 16:47:14 +00:00
|
|
|
|
|
|
|
/** Add a user pointer to the internal reference list of halfopped users
|
|
|
|
* @param user The user to add
|
|
|
|
*/
|
2006-03-08 23:16:18 +00:00
|
|
|
void AddHalfoppedUser(userrec* user);
|
2006-08-08 16:47:14 +00:00
|
|
|
|
|
|
|
/** Add a user pointer to the internal reference list of voiced users
|
|
|
|
* @param user The user to add
|
|
|
|
*/
|
2006-03-08 23:16:18 +00:00
|
|
|
void AddVoicedUser(userrec* user);
|
2005-04-26 17:09:25 +00:00
|
|
|
|
|
|
|
/** Delete a user pointer to the internal reference list
|
2006-03-08 23:16:18 +00:00
|
|
|
* @param user The user to delete
|
2006-08-08 16:47:14 +00:00
|
|
|
* @return number of users left on the channel after deletion of the user
|
2005-04-26 17:09:25 +00:00
|
|
|
*/
|
2006-03-09 11:24:30 +00:00
|
|
|
unsigned long DelUser(userrec* user);
|
2006-08-08 16:47:14 +00:00
|
|
|
|
|
|
|
/** Delete a user pointer to the internal reference list of opped users
|
|
|
|
* @param user The user to delete
|
|
|
|
*/
|
2006-03-08 23:16:18 +00:00
|
|
|
void DelOppedUser(userrec* user);
|
2006-08-08 16:47:14 +00:00
|
|
|
|
|
|
|
/** Delete a user pointer to the internal reference list of halfopped users
|
|
|
|
* @param user The user to delete
|
|
|
|
*/
|
2006-03-08 23:16:18 +00:00
|
|
|
void DelHalfoppedUser(userrec* user);
|
2006-08-08 16:47:14 +00:00
|
|
|
|
|
|
|
/** Delete a user pointer to the internal reference list of voiced users
|
|
|
|
* @param user The user to delete
|
|
|
|
*/
|
2006-03-08 23:16:18 +00:00
|
|
|
void DelVoicedUser(userrec* user);
|
2005-04-26 17:09:25 +00:00
|
|
|
|
2006-03-12 18:03:02 +00:00
|
|
|
/** Obtain the internal reference list
|
2006-03-08 23:16:18 +00:00
|
|
|
* The internal reference list contains a list of userrec*.
|
|
|
|
* These are used for rapid comparison to determine
|
2005-04-26 17:09:25 +00:00
|
|
|
* channel membership for PRIVMSG, NOTICE, QUIT, PART etc.
|
|
|
|
* The resulting pointer to the vector should be considered
|
|
|
|
* readonly and only modified via AddUser and DelUser.
|
2005-05-25 22:01:10 +00:00
|
|
|
*
|
2006-03-08 23:16:18 +00:00
|
|
|
* @return This function returns pointer to a map of userrec pointers (CUList*).
|
2005-04-26 17:09:25 +00:00
|
|
|
*/
|
2006-03-08 23:16:18 +00:00
|
|
|
CUList* GetUsers();
|
2006-08-08 16:47:14 +00:00
|
|
|
|
|
|
|
/** Obtain the internal reference list of opped users
|
|
|
|
* @return This function returns pointer to a map of userrec pointers (CUList*).
|
|
|
|
*/
|
2006-03-08 23:16:18 +00:00
|
|
|
CUList* GetOppedUsers();
|
2006-08-08 16:47:14 +00:00
|
|
|
|
|
|
|
/** Obtain the internal reference list of halfopped users
|
|
|
|
* @return This function returns pointer to a map of userrec pointers (CUList*).
|
|
|
|
*/
|
2006-03-08 23:16:18 +00:00
|
|
|
CUList* GetHalfoppedUsers();
|
2006-08-08 16:47:14 +00:00
|
|
|
|
|
|
|
/** Obtain the internal reference list of voiced users
|
|
|
|
* @return This function returns pointer to a map of userrec pointers (CUList*).
|
|
|
|
*/
|
2006-03-08 23:16:18 +00:00
|
|
|
CUList* GetVoicedUsers();
|
|
|
|
|
2006-03-12 18:03:02 +00:00
|
|
|
/** Returns true if the user given is on the given channel.
|
2006-08-08 16:47:14 +00:00
|
|
|
* @param The user to look for
|
|
|
|
* @return True if the user is on this channel
|
2006-03-12 18:03:02 +00:00
|
|
|
*/
|
2006-03-08 23:16:18 +00:00
|
|
|
bool HasUser(userrec* user);
|
2005-04-26 15:14:05 +00:00
|
|
|
|
2003-01-23 19:45:57 +00:00
|
|
|
/** Creates a channel record and initialises it with default values
|
2006-08-08 16:47:14 +00:00
|
|
|
* @throw Nothing at present.
|
2003-01-23 19:45:57 +00:00
|
|
|
*/
|
2006-08-09 18:55:52 +00:00
|
|
|
chanrec(InspIRCd* Instance);
|
2003-01-23 19:45:57 +00:00
|
|
|
|
2006-08-08 13:22:30 +00:00
|
|
|
/** Make src kick user from this channel with the given reason.
|
2006-08-08 12:20:45 +00:00
|
|
|
* @param src The source of the kick
|
|
|
|
* @param user The user being kicked (must be on this channel)
|
|
|
|
* @param reason The reason for the kick
|
|
|
|
* @return The number of users left on the channel. If this is zero
|
|
|
|
* when the method returns, you MUST delete the chanrec immediately!
|
|
|
|
*/
|
|
|
|
long KickUser(userrec *src, userrec *user, const char* reason);
|
|
|
|
|
2006-08-08 13:22:30 +00:00
|
|
|
/** Make the server kick user from this channel with the given reason.
|
|
|
|
* @param user The user being kicked (must be on this channel)
|
|
|
|
* @param reason The reason for the kick
|
|
|
|
* @param triggerevents True if you wish this kick to trigger module events
|
|
|
|
* @return The number of users left on the channel. If this is zero
|
|
|
|
* when the method returns, you MUST delete the chanrec immediately!
|
2006-08-08 12:20:45 +00:00
|
|
|
*/
|
|
|
|
long ServerKickUser(userrec* user, const char* reason, bool triggerevents);
|
|
|
|
|
2006-08-08 13:22:30 +00:00
|
|
|
/** Part a user from this channel with the given reason.
|
2006-08-08 12:52:24 +00:00
|
|
|
* If the reason field is NULL, no reason will be sent.
|
|
|
|
* @param user The user who is parting (must be on this channel)
|
|
|
|
* @param reason The (optional) part reason
|
|
|
|
* @return The number of users left on the channel. If this is zero
|
|
|
|
* when the method returns, you MUST delete the chanrec immediately!
|
|
|
|
*/
|
|
|
|
long PartUser(userrec *user, const char* reason = NULL);
|
|
|
|
|
2006-08-08 13:22:30 +00:00
|
|
|
/* Join a user to a channel. May be a channel that doesnt exist yet.
|
|
|
|
* @param user The user to join to the channel.
|
|
|
|
* @param cn The channel name to join to. Does not have to exist.
|
|
|
|
* @param key The key of the channel, if given
|
|
|
|
* @param override If true, override all join restrictions such as +bkil
|
|
|
|
* @return A pointer to the chanrec the user was joined to. A new chanrec may have
|
|
|
|
* been created if the channel did not exist before the user was joined to it.
|
|
|
|
* If the user could not be joined to a channel, the return value may be NULL.
|
2006-03-12 18:03:02 +00:00
|
|
|
*/
|
2006-08-09 18:55:52 +00:00
|
|
|
static chanrec* JoinUser(InspIRCd* ServerInstance, userrec *user, const char* cn, bool override, const char* key = "");
|
2003-01-23 19:45:57 +00:00
|
|
|
|
2006-08-08 16:47:14 +00:00
|
|
|
/** Write to a channel, from a user, using va_args for text
|
|
|
|
* @param user User whos details to prefix the line with
|
|
|
|
* @param text A printf-style format string which builds the output line without prefix
|
|
|
|
* @param ... Zero or more POD types
|
|
|
|
*/
|
2006-08-08 14:17:35 +00:00
|
|
|
void WriteChannel(userrec* user, char* text, ...);
|
2006-08-08 16:47:14 +00:00
|
|
|
|
|
|
|
/** Write to a channel, from a user, using std::string for text
|
|
|
|
* @param user User whos details to prefix the line with
|
|
|
|
* @param text A std::string containing the output line without prefix
|
|
|
|
*/
|
2006-08-08 14:17:35 +00:00
|
|
|
void WriteChannel(userrec* user, const std::string &text);
|
2006-08-08 16:47:14 +00:00
|
|
|
|
|
|
|
/** Write to a channel, from a server, using va_args for text
|
|
|
|
* @param ServName Server name to prefix the line with
|
|
|
|
* @param text A printf-style format string which builds the output line without prefi
|
|
|
|
* @param ... Zero or more POD type
|
|
|
|
*/
|
2006-08-08 14:17:35 +00:00
|
|
|
void WriteChannelWithServ(const char* ServName, const char* text, ...);
|
2006-08-08 16:47:14 +00:00
|
|
|
|
|
|
|
/** Write to a channel, from a server, using std::string for text
|
|
|
|
* @param ServName Server name to prefix the line with
|
|
|
|
* @param text A std::string containing the output line without prefix
|
|
|
|
*/
|
2006-08-08 14:17:35 +00:00
|
|
|
void WriteChannelWithServ(const char* ServName, const std::string &text);
|
2006-08-08 16:47:14 +00:00
|
|
|
|
|
|
|
/** Write to all users on a channel except a specific user, using va_args for text
|
|
|
|
* @param user User whos details to prefix the line with, and to omit from receipt of the message
|
|
|
|
* @param status The status of the users to write to, e.g. '@' or '%'. Use a value of 0 to write to everyone
|
|
|
|
* @param text A printf-style format string which builds the output line without prefi
|
|
|
|
* @param ... Zero or more POD type
|
|
|
|
*/
|
2006-08-08 14:17:35 +00:00
|
|
|
void WriteAllExceptSender(userrec* user, char status, char* text, ...);
|
2006-08-08 16:47:14 +00:00
|
|
|
|
|
|
|
/** Write to all users on a channel except a specific user, using std::string for text
|
|
|
|
* @param user User whos details to prefix the line with, and to omit from receipt of the message
|
|
|
|
* @param status The status of the users to write to, e.g. '@' or '%'. Use a value of 0 to write to everyone
|
|
|
|
* @param text A std::string containing the output line without prefix
|
|
|
|
*/
|
2006-08-08 14:17:35 +00:00
|
|
|
void WriteAllExceptSender(userrec* user, char status, const std::string& text);
|
|
|
|
|
2006-08-11 19:17:31 +00:00
|
|
|
/** Returns the maximum number of bans allowed to be set on this channel
|
|
|
|
* @return The maximum number of bans allowed
|
|
|
|
*/
|
2006-08-10 14:43:29 +00:00
|
|
|
long GetMaxBans();
|
|
|
|
|
2006-08-11 19:17:31 +00:00
|
|
|
/** Return the channel's modes with parameters.
|
|
|
|
* @param showkey If this is set to true, the actual key is shown,
|
|
|
|
* otherwise it is replaced with '<KEY>'
|
|
|
|
* @return The channel mode string
|
|
|
|
*/
|
2006-08-10 14:43:29 +00:00
|
|
|
char* ChanModes(bool showkey);
|
|
|
|
|
2006-08-11 19:17:31 +00:00
|
|
|
/** Spool the NAMES list for this channel to the given user
|
|
|
|
* @param The user to spool the NAMES list to
|
|
|
|
*/
|
2006-08-10 14:43:29 +00:00
|
|
|
void UserList(userrec *user);
|
|
|
|
|
2006-08-11 19:17:31 +00:00
|
|
|
/** Get the number of invisible users on this channel
|
|
|
|
* @return Number of invisible users
|
|
|
|
*/
|
2006-08-10 14:43:29 +00:00
|
|
|
int CountInvisible();
|
|
|
|
|
2006-08-11 19:17:31 +00:00
|
|
|
/** Get a users status on this channel
|
|
|
|
* @param The user to look up
|
|
|
|
* @return One of STATUS_OP, STATUS_HOP, STATUS_VOICE, or zero.
|
|
|
|
*/
|
2006-08-10 15:44:03 +00:00
|
|
|
int GetStatus(userrec *user);
|
|
|
|
|
2006-08-11 19:17:31 +00:00
|
|
|
/** Get a users status on this channel in a bitmask
|
|
|
|
* @param The user to look up
|
|
|
|
* @return A bitmask containing zero or more of STATUS_OP, STATUS_HOP, STATUS_VOICE
|
|
|
|
*/
|
2006-08-10 15:44:03 +00:00
|
|
|
int GetStatusFlags(userrec *user);
|
|
|
|
|
2006-08-23 20:50:20 +00:00
|
|
|
/** Get a users prefix on this channel in a string.
|
|
|
|
* @param The user to look up
|
|
|
|
* @return A character array containing the prefix string.
|
|
|
|
* Unlike GetStatus and GetStatusFlags which will only return the
|
|
|
|
* core specified modes @, % and + (op, halfop and voice), GetPrefixChar
|
|
|
|
* will also return module-defined prefixes. If the user has to prefix,
|
|
|
|
* an empty but non-null string is returned. If the user has multiple
|
|
|
|
* prefixes, the highest is returned. If you do not recognise the prefix
|
|
|
|
* character you can get, you can deal with it in a 'proprtional' manner
|
|
|
|
* compared to known prefixes, using GetPrefixValue().
|
|
|
|
*/
|
|
|
|
const char* GetPrefixChar(userrec *user);
|
|
|
|
|
|
|
|
/** Get the value of a users prefix on this channel.
|
2006-08-11 19:17:31 +00:00
|
|
|
* @param The user to look up
|
2006-08-23 20:50:20 +00:00
|
|
|
* @return The module or core-defined value of the users prefix.
|
|
|
|
* The values for op, halfop and voice status are constants in
|
|
|
|
* mode.h, and are OP_VALUE, HALFOP_VALUE, and VOICE_VALUE respectively.
|
|
|
|
* If the value you are given does not match one of these three, it is
|
|
|
|
* a module-defined mode, and it should be compared in proportion to
|
|
|
|
* these three constants. For example a value greater than OP_VALUE
|
|
|
|
* is a prefix of greater 'worth' than ops, and a value less than
|
|
|
|
* VOICE_VALUE is of lesser 'worth' than a voice.
|
|
|
|
*/
|
|
|
|
unsigned int GetPrefixValue(userrec* user);
|
|
|
|
|
|
|
|
/** This method removes all prefix characters from a user.
|
|
|
|
* It will not inform the user or the channel of the removal of prefixes,
|
|
|
|
* and should be used when the user parts or quits.
|
|
|
|
* @param The user to remove all prefixes from
|
2006-08-11 19:17:31 +00:00
|
|
|
*/
|
2006-08-23 20:29:09 +00:00
|
|
|
void RemoveAllPrefixes(userrec* user);
|
|
|
|
|
2006-08-23 20:50:20 +00:00
|
|
|
/** Add a prefix character to a user.
|
|
|
|
* Only the core should call this method, usually from
|
|
|
|
* within the mode parser or when the first user joins
|
|
|
|
* the channel (to grant ops to them)
|
|
|
|
* @param The user to associate the privilage with
|
|
|
|
* @param prefix The prefix character to associate
|
|
|
|
* @param prefix_rank The rank (value) of this prefix character
|
|
|
|
* @param adding True if adding the prefix, false when removing
|
|
|
|
*/
|
2006-08-23 20:20:41 +00:00
|
|
|
void SetPrefix(userrec* user, char prefix, unsigned int prefix_rank, bool adding);
|
|
|
|
|
2006-08-08 13:22:30 +00:00
|
|
|
/** Destructor for chanrec
|
2006-03-12 18:03:02 +00:00
|
|
|
*/
|
2006-08-08 13:22:30 +00:00
|
|
|
virtual ~chanrec() { /* stub */ }
|
2003-01-23 19:45:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|