unrealircd

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

tline.c (2115B)

      1 /*
      2  *   IRC - Internet Relay Chat, src/modules/tline.c
      3  *   (C) 2022 Noisytoot & The UnrealIRCd Team
      4  *
      5  *   See file AUTHORS in IRC package for additional names of
      6  *   the programmers.
      7  *
      8  *   This program is free software; you can redistribute it and/or modify
      9  *   it under the terms of the GNU General Public License as published by
     10  *   the Free Software Foundation; either version 1, or (at your option)
     11  *   any later version.
     12  *
     13  *   This program is distributed in the hope that it will be useful,
     14  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     15  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16  *   GNU General Public License for more details.
     17  *
     18  *   You should have received a copy of the GNU General Public License
     19  *   along with this program; if not, write to the Free Software
     20  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     21  */
     22 
     23 #include "unrealircd.h"
     24 
     25 #define MSG_TLINE "TLINE"
     26 
     27 CMD_FUNC(cmd_tline);
     28 
     29 ModuleHeader MOD_HEADER
     30   = {
     31 	"tline",
     32 	"1.0",
     33 	"TLINE command to show amount of clients matching a server ban mask",
     34 	"UnrealIRCd team",
     35 	"unrealircd-6",
     36 	};
     37 
     38 MOD_INIT()
     39 {
     40 	CommandAdd(modinfo->handle, MSG_TLINE, cmd_tline, 1, CMD_OPER);
     41 	MARK_AS_OFFICIAL_MODULE(modinfo);
     42 	return MOD_SUCCESS;
     43 }
     44 
     45 MOD_LOAD()
     46 {
     47 	return MOD_SUCCESS;
     48 }
     49 
     50 MOD_UNLOAD()
     51 {
     52 	return MOD_SUCCESS;
     53 }
     54 
     55 /*
     56 ** cmd_tline
     57 **	parv[1] = mask to test
     58 */
     59 CMD_FUNC(cmd_tline)
     60 {
     61 	Client *acptr;
     62 	int matching_lclients = 0;
     63 	int matching_clients = 0;
     64 
     65 	if ((parc < 1) || BadPtr(parv[1]))
     66 	{
     67 		sendnumeric(client, ERR_NEEDMOREPARAMS, MSG_TLINE);
     68 		return;
     69 	}
     70 
     71 	list_for_each_entry(acptr, &client_list, client_node)
     72 	{
     73 		if (match_user(parv[1], acptr, MATCH_CHECK_REAL))
     74 		{
     75 			if (MyUser(acptr))
     76 				matching_lclients++;
     77 			matching_clients++;
     78 		}
     79 	}
     80 
     81 	sendnotice(client,
     82 	    "*** TLINE: Users matching mask '%s': global: %d/%d (%.2f%%), local: %d/%d (%.2f%%).",
     83 	    parv[1], matching_clients, irccounts.clients,
     84 	    (double)matching_clients / irccounts.clients * 100,
     85 	    matching_lclients, irccounts.me_clients,
     86 	    (double)matching_lclients / irccounts.me_clients * 100);
     87 }