unrealircd- supernets unrealircd source & configuration |
git clone git://git.acid.vegas/unrealircd.git |
Log | Files | Refs | Archive | README | LICENSE |
setident.c (3094B)
1 /* 2 * IRC - Internet Relay Chat, src/modules/setident.c 3 * (C) 1999-2001 Carsten Munk (Techie/Stskeeps) <stskeeps@tspre.org> 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_SETIDENT "SETIDENT" /* set ident */ 26 27 CMD_FUNC(cmd_setident); 28 29 ModuleHeader MOD_HEADER 30 = { 31 "setident", /* Name of module */ 32 "5.0", /* Version */ 33 "/setident", /* Short description of module */ 34 "UnrealIRCd Team", 35 "unrealircd-6", 36 }; 37 38 MOD_INIT() 39 { 40 CommandAdd(modinfo->handle, MSG_SETIDENT, cmd_setident, MAXPARA, CMD_USER); 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 /* cmd_setident - 12/05/1999 - Stskeeps 56 * :prefix SETIDENT newident 57 * parv[1] - newident 58 * D: This will set your username to be <x> (like (/setident Root)) 59 * (if you are IRCop) **efg* 60 * Cloning of cmd_sethost at some points - so same authors ;P 61 */ 62 CMD_FUNC(cmd_setident) 63 { 64 const char *vident, *s; 65 66 if ((parc < 2) || BadPtr(parv[1])) 67 { 68 if (MyConnect(client)) 69 sendnotice(client, "*** Syntax: /SETIDENT <new ident>"); 70 return; 71 } 72 73 vident = parv[1]; 74 75 switch (UHOST_ALLOWED) 76 { 77 case UHALLOW_ALWAYS: 78 break; 79 case UHALLOW_NEVER: 80 if (MyUser(client)) 81 { 82 sendnotice(client, "*** /SETIDENT is disabled"); 83 return; 84 } 85 break; 86 case UHALLOW_NOCHANS: 87 if (MyUser(client) && client->user->joined) 88 { 89 sendnotice(client, "*** /SETIDENT cannot be used while you are on a channel"); 90 return; 91 } 92 break; 93 case UHALLOW_REJOIN: 94 /* dealt with later */ 95 break; 96 } 97 98 if (strlen(vident) > USERLEN) 99 { 100 if (MyConnect(client)) 101 sendnotice(client, "*** /SETIDENT Error: Usernames are limited to %i characters.", USERLEN); 102 return; 103 } 104 105 /* Check if the new ident contains illegal characters */ 106 if (!valid_username(vident)) 107 { 108 sendnotice(client, "*** /SETIDENT Error: A username may contain a-z, A-Z, 0-9, '-', '~' & '.'."); 109 return; 110 } 111 112 userhost_save_current(client); 113 114 strlcpy(client->user->username, vident, sizeof(client->user->username)); 115 116 sendto_server(client, 0, 0, NULL, ":%s SETIDENT %s", client->id, parv[1]); 117 118 userhost_changed(client); 119 120 if (MyConnect(client)) 121 { 122 sendnotice(client, "Your nick!user@host-mask is now (%s!%s@%s)", 123 client->name, client->user->username, GetHost(client)); 124 } 125 }