void _init() {
chanservaddcommand("addchan", QCMD_OPER, 4, csc_doaddchan, "Adds a new channel to the bot.", "Usage: addchan <channel> [<owner> [<flags> [<type>]]]\nAdds the given channel to the bot, where:\nowner - can be either nickname on the network or #authname. If not supplied,\n the channel will belong to the user issuing the ADDCHAN command.\nflags - can be any valid chanflags (see CHANFLAGS). If not specified this \n defaults to +j.\ntype - is a channel type as per old Q and is now obsolete.\n");
chanservaddcommand("adduser", QCMD_AUTHED, 20, csc_doadduser, "Adds one or more users to a channel as +aot.", "Usage: ADDUSER <channel> [<flags>] <user1> [<user2> [<user3> [...]]]\nAdds the named user(s) to the channel, where:\nchannel - the channel to use\nflags - the list of flags to add for each user, introduced by + (for example\n +gv). See CHANLEV for valid flags. If no flags are specified, \n +aot is used. This command cannot be used to add masters (+m) or\n owners (+n).\nuser<n> - either a user's current nickname on the network or #accountname. Up to\n 18 users can be specified.\nADDUSER requires master (+m) access on the named channel.\n");
- chanservaddcommand("autolimit", QCMD_AUTHED, 2, csc_doautolimit, "Shows or changes the autolimit threshold on a channel.", "Usage: AUTOLIMIT <channel> [<threshold>]\nThis command shows or changes the number of free slots to keep on the channel\nwhen autolimit (see CHANFLAGS) is enabled. Where:\nchannel - the channel to use.\nthreshold - specifies the new threshold. If not specified, the current threshold \n is displayed.\nViewing the current threshold requires operator (+o) access on the named channel.\nUpdating the threshold requires master (+m) access on the named channel.\n");
- chanservaddcommand("ban", QCMD_AUTHED | QCMD_ALIAS, 3, csc_dopermban, "Permanently bans a hostmask on a channel.", "Usage: BAN <channel> <hostmask> [<reason>]\nPermanently bans the provided hostmask on the channel. If the ban is\nremoved from the channel e.g. by a channel op or the BANTIMER feature, the\nban will be reapplied if a matching user joins the channel. Bans\nset with the PERMBAN command can be removed via BANCLEAR or BANDEL. Any users\nmatching the hostmask will be kicked from the channel.\nWhere:\nchannel - channel to set a ban on\nhostmask - hostmask (nick!user@host) to ban.\nreason - reason for the ban. This will be used in kick messages when kicking\n users matching the ban. If this is not provided the generic message\n \"Banned.\" will be used.\nBAN requires master (+m) access on the named channel.\nBAN is an alias for PERMBAN.\n");
+ chanservaddcommand("autolimit", QCMD_AUTHED, 2, csc_doautolimit, "Shows or changes the autolimit threshold on a channel.", "Usage: AUTOLIMIT <channel> [<threshold>]\nThe autolimit feature maintains a user limit (+l) on the channel which is\nregularly updated to keep a fixed number of spaces free on the channel for\npeople to join. This is useful since it prevents a large number of \"clones\"\njoining at the same time. However, if the number of free spaces is too small\nit's possible that legitimate users won't be able to join. This command allows\nyou to adjust the number of free spaces to maintain when autolimit is enabled. \nTo actually turn the autolimit feature on or off, see CHANFLAGS. Where:\nchannel - the channel to use.\nthreshold - specifies the new threshold. If not specified, the current threshold \n is displayed.\nViewing the current threshold requires operator (+o) access on the named channel.\nUpdating the threshold requires master (+m) access on the named channel.\n");
+ chanservaddcommand("ban", QCMD_AUTHED | QCMD_ALIAS, 3, csc_dopermban, "Permanently bans a hostmask on a channel.", "Usage: BAN <channel> <hostmask> [<reason>]\nPermanently bans the provided hostmask on the channel. If the ban is\nremoved from the channel e.g. by a channel op or the BANTIMER feature, the\nban will be reapplied if a matching user joins the channel. Bans\nset with the PERMBAN command can be removed with BANCLEAR or BANDEL. Any users\nmatching the hostmask will be kicked from the channel.\nWhere:\nchannel - channel to set a ban on\nhostmask - hostmask (nick!user@host) to ban.\nreason - reason for the ban. This will be used in kick messages when kicking\n users matching the ban. If this is not provided the generic message\n \"Banned.\" will be used.\nBAN requires master (+m) access on the named channel.\nBAN is an alias for PERMBAN.\n");
chanservaddcommand("banclear", QCMD_AUTHED, 1, csc_dobanclear, "Removes all bans from a channel including persistent bans.", "Usage: BANCLEAR <channel>\nRemoves all temporary and persistent bans from a channel, where:\nchannel - the channel to use\nBANCLEAR requires master (+m) access on the named channel.\n");
chanservaddcommand("bandel", QCMD_AUTHED, 2, csc_dobandel, "Removes a single ban from a channel.", "Usage: BANDEL <channel> <ban>\nRemoves the specified persistent or channel ban, where:\nchannel - the channel to use\nban - either a ban mask (nick!user@host), or #number (see BANLIST)\nRemoving channel bans requires operator (+o) access on the named channel.\nRemoving persistent bans requires master (+m) access on the named channel.\n");
chanservaddcommand("banlist", QCMD_AUTHED, 1, csc_dobanlist, "Displays all persistent bans on a channel.", "Usage: BANLIST <channel>\nDisplays a list of persistent and channel bans on the named channel. Each ban\nis identified by a number which can be passed to a subsequent BANDEL command.\nNote that the numbers can change if bans are added to or removed from the \nchennel. Where:\nchannel - the channel to use\nBANLIST requires operator (+o) access on the named channel.\n");
chanservaddcommand("giveowner", QCMD_AUTHED, 3, csc_dogiveowner, "Gives total control over a channel to another user.", "Usage: GIVEOWNER <channel> <user> [<code>]\nGives complete control (+n flag) to the named user on the channel. The new owner\nwill have full control over the channel, including the ability to remove the\nexisting owner(s). As a precaution the named user must already have master (+m) \naccess on the channel. Use this command with extreme caution. Where:\nchannel - channel to use\nuser - user to give owner to, either a nickname on the network or #accountname.\ncode - a unique code used to authorize the operation. If the code is not \n supplied, the appropriate code will be provided together with a \n warning about the dangers of this command. If the wrong code is\n entered owner access will not be granted.\nGIVEOWNER requires owner (+n) access on the named channel.\n");
chanservaddcommand("invite", QCMD_AUTHED, 1, csc_doinvite, "Invites you to a channel.", "Usage: INVITE <channel>\nInvites you to the named channel, where:\nchannel - channel to be invited to.\nINVITE requires you to be known (+k) on the named channel.\n");
chanservaddcommand("op", QCMD_AUTHED, 20, csc_doop, "Ops you or other users on channel(s).", "Usage: OP [<channel> [<user1> [<user2> [...]]]\nOps you on one or more channels, or ops other named users on a given channel.\nThis command cannot be used to op users who are otherwise prevented from getting\nops, e.g. via the +d chanlev flag (see CHANLEV) or bitch mode (see CHANFLAGS).\nWhere:\nchannel - channel to use. If no channel is specified, you will be given ops on\n every channel where you have appropriate access and are not already\n opped.\nuser<n> - user(s) to op instead of yourself. Each user must be specified as the\n current nickname of a user on the named channel.\nOP requires operator access (+o) on the named channel. If this command is used\nto op other users, a notice will be sent to other channel operators on the \nchannel identifying you, unless you have master (+m) access.\n");
- chanservaddcommand("permban", QCMD_AUTHED, 3, csc_dopermban, "Permanently bans a hostmask on a channel.", "Usage: PERMBAN <channel> <hostmask> [<reason>]\nPermanently bans the provided hostmask on the channel. If the ban is\nremoved from the channel e.g. by a channel op or the BANTIMER feature, the\nban will be reapplied if a matching user joins the channel. Bans\nset with the PERMBAN command can be removed via BANCLEAR or BANDEL. Any users\nmatching the hostmask will be kicked from the channel.\nWhere:\nchannel - channel to set a ban on\nhostmask - hostmask (nick!user@host) to ban.\nreason - reason for the ban. This will be used in kick messages when kicking\n users matching the ban. If this is not provided the generic message\n \"Banned.\" will be used.\nPERMBAN requires master (+m) access on the named channel.\n");
+ chanservaddcommand("permban", QCMD_AUTHED, 3, csc_dopermban, "Permanently bans a hostmask on a channel.", "Usage: PERMBAN <channel> <hostmask> [<reason>]\nPermanently bans the provided hostmask on the channel. If the ban is\nremoved from the channel e.g. by a channel op or the BANTIMER feature, the\nban will be reapplied if a matching user joins the channel. Bans\nset with the PERMBAN command can be removed with BANCLEAR or BANDEL. Any users\nmatching the hostmask will be kicked from the channel.\nWhere:\nchannel - channel to set a ban on\nhostmask - hostmask (nick!user@host) to ban.\nreason - reason for the ban. This will be used in kick messages when kicking\n users matching the ban. If this is not provided the generic message\n \"Banned.\" will be used.\nPERMBAN requires master (+m) access on the named channel.\n");
chanservaddcommand("recover", QCMD_AUTHED, 1, csc_dorecover, "Recovers a channel (same as deopall, unbanall, clearchan).", "Usage: RECOVER <channel>\nThis command resets the named channel if undesired modes, bans or ops have been\nset. This has the same effect as DEOPALL followed by UNBANALL followed by\nCLEARCHAN on the channel, where:\nchannel - channel to recover\nRECOVER requires master (+m) access on the named channel.\n");
chanservaddcommand("rejoin", QCMD_OPER, 1, csc_dorejoin, "Makes the bot rejoin a channel.", "");
chanservaddcommand("removeuser", QCMD_AUTHED, 20, csc_doremoveuser, "Removes one or more users from a channel.", "Usage: REMOVEUSER <channel> <user1> [<user2> [<user3> [...]]]\nRemoves any flags the named user(s) have on the channel. This command\ncannot be used to remove owners (+n) from the channel, and cannot be used\nto remove masters (+m) unless the user issuing the command is an owner.\nWhere:\nchannel - channel to use\nuser<n> - a user to remove. Can either be a nickname on the network\n or #authname. Up to 18 users can be specified.\nREMOVEUSER requires master (+m) access on the named channel.\n");
chanservaddcommand("settopic", QCMD_AUTHED, 2, csc_dosettopic, "Changes the topic on a channel.", "Usage: SETTOPIC <channel> [<topic>]\nChanges the topic on the channel, where:\nchannel - channel to use\ntopic - new topic. If no topic is set, the stored topic will be reset (this\n feature is useful if some users can no longer see the topic due to a \n netsplit).\nSETTOPIC requires topic (+t) or master (+m) access on the named channel.\n");
chanservaddcommand("suspendchan", QCMD_OPER, 2, csc_dosuspendchan, "Suspends a channel from the bot.", "");
chanservaddcommand("suspendchanlist", QCMD_HELPER, 1, csc_dosuspendchanlist, "Lists suspended channels.", "");
- chanservaddcommand("tempban", QCMD_AUTHED, 4, csc_dotempban, "Bans a hostmask on a channel for a specified time period.", "Usage: TEMPBAN <channel> <hostmask> <duration> [<reason>]\nTemporarily bans the provided hostmask on the channel. If the ban is\nremoved from the channel e.g. by a channel op or the BANTIMER feature, the\nban will be reapplied if a matching user joins the channel. When the time \nexpires the ban will be removed automatically. Bans set with the TEMPBAN \ncommand can be removed via BANCLEAR or BANDEL. Any users matching the hostmask \nwill be kicked from the channel.\nWhere:\nchannel - channel to set a ban on\nhostmask - hostmask (nick!user@host) to ban.\nduration - length of time to apply the ban for. Suffixes m (minutes), h (hours),\n d (days), w (weeks), M (months) and y (years) can be used to specify \n the duration, for example 3d, 5h, 1h30m, 1M.\nreason - reason for the ban. This will be used in kick messages when kicking\n users matching the ban. If this is not provided the generic message\n \"Banned.\" will be used.\nTEMPBAN requires master (+m) access on the named channel.\n");
+ chanservaddcommand("tempban", QCMD_AUTHED, 4, csc_dotempban, "Bans a hostmask on a channel for a specified time period.", "Usage: TEMPBAN <channel> <hostmask> <duration> [<reason>]\nTemporarily bans the provided hostmask on the channel. If the ban is\nremoved from the channel e.g. by a channel op or the BANTIMER feature, the\nban will be reapplied if a matching user joins the channel. When the time \nexpires the ban will be removed automatically. Bans set with the TEMPBAN \ncommand can be removed before they expire with BANCLEAR or BANDEL. Any users \nmatching the hostmask will be kicked from the channel.\nWhere:\nchannel - channel to set a ban on\nhostmask - hostmask (nick!user@host) to ban.\nduration - length of time to apply the ban for. Suffixes m (minutes), h (hours),\n d (days), w (weeks), M (months) and y (years) can be used to specify \n the duration, for example 3d, 5h, 1h30m, 1M.\nreason - reason for the ban. This will be used in kick messages when kicking\n users matching the ban. If this is not provided the generic message\n \"Banned.\" will be used.\nTEMPBAN requires master (+m) access on the named channel.\n");
chanservaddcommand("unban", QCMD_AUTHED | QCMD_ALIAS, 2, csc_dobandel, "Removes a single ban from a channel.", "Usage: UNBAN <channel> <ban>\nRemoves the specified persistent or channel ban, where:\nchannel - the channel to use\nban - either a ban mask (nick!user@host), or #number (see BANLIST)\nRemoving channel bans requires operator (+o) access on the named channel.\nRemoving persistent bans requires master (+m) access on the named channel.\nUNBAN is an alias for BANDEL.\n");
chanservaddcommand("unbanall", QCMD_AUTHED, 1, csc_dounbanall, "Removes all bans from a channel.", "Usage: UNBANALL <channel>\nRemoves all the channel bans set on the named channel. This does not affect\npersistent bans set via the TEMPBAN and PERMBAN commands, see BANCLEAR or\nBANDEL for more information on removing those bans. Where:\nchannel - channel to use\nUNBANALL requires master (+m) access on the named channel.\n");
chanservaddcommand("unbanmask", QCMD_AUTHED, 2, csc_dounbanmask, "Removes bans matching a particular mask from a channel.", "Usage: UNBANMASK <channel> <mask>\nRemoves any bans on the channel which are overlapped by the named mask. Can\nremove both channel bans and registered bans. Where:\nchannel - channel to use\nmask - mask to remove. Any ban subsumed by this mask will be removed. For\n example, UNBANMASK *!*@*.isp.net would remove *!*@host1.isp.net and \n *!*@host2.isp.net and *!user@*.isp.net.\nUNBANMASK requires operator (+o) access on the named channel.\nRemoving registered bans requires master (+m) access on the named channel.\n");
if (!(rcp=cp->index->exts[chanservext]))
return;
- /* Check for a new timestamp */
- if ((!rcp->ltimestamp) || (cp->timestamp < rcp->ltimestamp)) {
+ /* Check for a new timestamp. But don't do anything stupid if the incoming timestamp is 0 */
+ if (cp->timestamp && ((!rcp->ltimestamp) || (cp->timestamp < rcp->ltimestamp))) {
rcp->ltimestamp=cp->timestamp;
csdb_updatechanneltimestamp(rcp);
}
/*
* Unbans a mask from a channel, including permbans if user has correct privs.
+ *
+ * Return 0 if it works, 1 if it don't.
*/
-void cs_unbanfn(nick *sender, chanindex *cip, UnbanFN fn, void *arg, int removepermbans) {
+int cs_unbanfn(nick *sender, chanindex *cip, UnbanFN fn, void *arg, int removepermbans, int abortonfailure) {
regban **rbh, *rbp;
chanban **cbh, *cbp;
regchan *rcp;
rbh=&(rbp->next);
} else if (!cs_checkaccess(sender, NULL, CA_MASTERPRIV, cip, NULL, 0, 1)) {
chanservstdmessage(sender, QM_NOTREMOVEDPERMBAN, banstr, cip->name->content);
+ if (abortonfailure) return 1; /* Just give up... */
rbh=&(rbp->next);
} else {
chanservstdmessage(sender, QM_REMOVEDPERMBAN, banstr, cip->name->content);
}
localsetmodeflush(&changes,1);
}
+
+ return 0;
}
/* Add entry to channel op history when someone gets ops. */