unrealircd

- supernets unrealircd source & configuration
git clone git://git.acid.vegas/unrealircd.git
Log | Files | Refs | Archive | README | LICENSE

bot.c (2594B)

      1 /*
      2  * Bot user mode (User mode +B)
      3  * (C) Copyright 2000-.. Bram Matthys (Syzop) and the UnrealIRCd team
      4  *
      5  * This program is free software; you can redistribute it and/or modify
      6  * it under the terms of the GNU General Public License as published by
      7  * the Free Software Foundation; either version 1, or (at your option)
      8  * any later version.
      9  *
     10  * This program is distributed in the hope that it will be useful,
     11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13  * GNU General Public License for more details.
     14  *
     15  * You should have received a copy of the GNU General Public License
     16  * along with this program; if not, write to the Free Software
     17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     18  */
     19 
     20 #include "unrealircd.h"
     21 
     22 #define IsBot(cptr)    (cptr->umodes & UMODE_BOT)
     23 
     24 /* Module header */
     25 ModuleHeader MOD_HEADER
     26   = {
     27 	"usermodes/bot",
     28 	"4.2",
     29 	"User Mode +B",
     30 	"UnrealIRCd Team",
     31 	"unrealircd-6",
     32     };
     33 
     34 /* Global variables */
     35 long UMODE_BOT = 0L;
     36 
     37 /* Forward declarations */
     38 int bot_whois(Client *client, Client *acptr, NameValuePrioList **list);
     39 int bot_who_status(Client *client, Client *acptr, Channel *channel, Member *cm, const char *status, int cansee);
     40 int bot_umode_change(Client *client, long oldmode, long newmode);
     41 
     42 MOD_TEST()
     43 {
     44 	return MOD_SUCCESS;
     45 }
     46 
     47 MOD_INIT()
     48 {
     49 	UmodeAdd(modinfo->handle, 'B', UMODE_GLOBAL, 0, NULL, &UMODE_BOT);
     50 	ISupportAdd(modinfo->handle, "BOT", "B");
     51 	
     52 	HookAdd(modinfo->handle, HOOKTYPE_WHOIS, 0, bot_whois);
     53 	HookAdd(modinfo->handle, HOOKTYPE_WHO_STATUS, 0, bot_who_status);
     54 	HookAdd(modinfo->handle, HOOKTYPE_UMODE_CHANGE, 0, bot_umode_change);
     55 	
     56 	MARK_AS_OFFICIAL_MODULE(modinfo);
     57 	return MOD_SUCCESS;
     58 }
     59 
     60 MOD_LOAD()
     61 {
     62 	return MOD_SUCCESS;
     63 }
     64 
     65 MOD_UNLOAD()
     66 {
     67 	return MOD_SUCCESS;
     68 }
     69 
     70 int bot_whois(Client *client, Client *target, NameValuePrioList **list)
     71 {
     72 	char buf[512];
     73 
     74 	if (!IsBot(target))
     75 		return 0;
     76 
     77 	if (whois_get_policy(client, target, "bot") == WHOIS_CONFIG_DETAILS_NONE)
     78 		return 0;
     79 
     80 	add_nvplist_numeric(list, 0, "bot", client, RPL_WHOISBOT, target->name, NETWORK_NAME);
     81 
     82 	return 0;
     83 }
     84 
     85 int bot_who_status(Client *client, Client *target, Channel *channel, Member *cm, const char *status, int cansee)
     86 {
     87 	if (IsBot(target))
     88 		return 'B';
     89 	
     90 	return 0;
     91 }
     92 
     93 int bot_umode_change(Client *client, long oldmode, long newmode)
     94 {
     95 	if ((newmode & UMODE_BOT) && !(oldmode & UMODE_BOT) && MyUser(client))
     96 	{
     97 		/* now +B */
     98 		const char *parv[2];
     99 		parv[0] = client->name;
    100 		parv[1] = NULL;
    101 		do_cmd(client, NULL, "BOTMOTD", 1, parv);
    102 	}
    103 
    104 	return 0;
    105 }