Bez tytułu

z k4be, 4 lata temu, napisane w C, wyświetlone 354 razy.
URL https://pastebin.k4be.pl/view/deb84e11 Udostępnij
Pobierz wklejkę lub Pokaż surowy tekst
  1. /*
  2.  *   Created by k4be, based on setname.c
  3.  *   IRC - Internet Relay Chat
  4.  *   (c) 1999-2001 Dominick Meglio (codemastr) <codemastr@unrealircd.com>
  5.  *
  6.  *   See file AUTHORS in IRC package for additional names of
  7.  *   the programmers.
  8.  *
  9.  *   This program is free software; you can redistribute it and/or modify
  10.  *   it under the terms of the GNU General Public License as published by
  11.  *   the Free Software Foundation; either version 1, or (at your option)
  12.  *   any later version.
  13.  *
  14.  *   This program is distributed in the hope that it will be useful,
  15.  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17.  *   GNU General Public License for more details.
  18.  *
  19.  *   You should have received a copy of the GNU General Public License
  20.  *   along with this program; if not, write to the Free Software
  21.  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  22.  */
  23.  
  24. /*** <<<MODULE MANAGER START>>>
  25. module
  26. {
  27.         documentation "https://github.com/pirc-pl/unrealircd-modules/blob/master/README.md#setname";
  28.         troubleshooting "In case of problems, contact k4be on irc.pirc.pl.";
  29.         min-unrealircd-version "5.*";
  30.         post-install-text {
  31.                 "The module is installed. Now all you need to do is add a loadmodule line:";
  32.                 "loadmodule \"third/setname\";";
  33.                                 "And /REHASH the IRCd.";
  34.                                 "The module does not need any configuration.";
  35.                                 "Please note that the implemented feature is still \"Work In Progress\".";
  36.         }
  37. }
  38. *** <<<MODULE MANAGER END>>>
  39. */
  40.  
  41. #include "unrealircd.h"
  42.  
  43. CMD_OVERRIDE_FUNC(cmd_setname);
  44. long CAP_SETNAME = 0L;
  45.  
  46. #define MSG_SETNAME     "SETNAME"       /* setname */
  47.  
  48. ModuleHeader MOD_HEADER
  49.   = {
  50.         "third/setname",        /* Name of module */
  51.         "5.0", /* Version */
  52.         "IRCv3-compatible command /setname (CAP draft/setname)", /* Short description of module */
  53.         "k4be@PIRC",
  54.         "unrealircd-5",
  55.     };
  56.  
  57. MOD_INIT(){
  58.         ClientCapabilityInfo cap;
  59.         ClientCapability *c;
  60.  
  61.         memset(&cap, 0, sizeof(cap));
  62.         cap.name = "draft/setname";
  63.         c = ClientCapabilityAdd(modinfo->handle, &cap, &CAP_SETNAME);
  64.  
  65.         return MOD_SUCCESS;
  66. }
  67.  
  68. MOD_LOAD(){
  69.         if(!CommandOverrideAddEx(modinfo->handle, MSG_SETNAME, 0, cmd_setname)){
  70.                 config_error("[%s] Crritical: Failed to request command override for SETNAME: %s", MOD_HEADER.name, ModuleGetErrorStr(modinfo->handle));
  71.         }
  72.         return MOD_SUCCESS;
  73. }
  74.  
  75. MOD_UNLOAD(){
  76.         return MOD_SUCCESS;
  77. }
  78.  
  79. /* cmd_setname - 12/05/1999 - Stskeeps
  80.  * :prefix SETNAME :gecos
  81.  * parv[1] - gecos
  82.  * D: This will set your gecos to be <x> (like (/setname :The lonely wanderer))
  83.    yes it is experimental but anyways ;P
  84.     FREEDOM TO THE USERS! ;)
  85. */
  86. CMD_OVERRIDE_FUNC(cmd_setname){
  87.         int xx;
  88.         char tmpinfo[REALLEN + 1];
  89.         char spamfilter_user[NICKLEN + USERLEN + HOSTLEN + REALLEN + 64];
  90.         ConfigItem_ban *bconf;
  91.  
  92.         if(!HasCapabilityFast(client, CAP_SETNAME)){
  93.                 CallCommandOverride(ovr, client, recv_mtags, parc, parv); // the original command
  94.                 sendto_local_common_channels(client, client, CAP_SETNAME, recv_mtags, ":%s!%s@%s SETNAME :%s", client->name, client->user->username, GetHost(client), parv[1]);
  95.                 return;
  96.         }
  97.  
  98.         if ((parc < 2) || BadPtr(parv[1])){
  99.                 sendnumeric(client, ERR_NEEDMOREPARAMS, "SETNAME");
  100.                 return;
  101.         }
  102.  
  103.         if (strlen(parv[1]) > REALLEN){
  104.                 if (MyConnect(client)){
  105.                         sendto_one(client, recv_mtags, ":%s FAIL SETNAME INVALID_REALNAME :\"Real names\" may maximum be %i characters of length", me.name, REALLEN);
  106.                 }
  107.                 return;
  108.         }
  109.  
  110.         if (MyUser(client)){
  111.                 /* set temp info for spamfilter check*/
  112.                 strcpy(tmpinfo, client->info);
  113.                 /* set the new name before we check, but don't send to servers unless it is ok */
  114.                 strcpy(client->info, parv[1]);
  115.                 spamfilter_build_user_string(spamfilter_user, client->name, client);
  116.                 if (match_spamfilter(client, spamfilter_user, SPAMF_USER, NULL, 0, NULL)){
  117.                         /* Was rejected by spamfilter, restore the realname */
  118.                         strcpy(client->info, tmpinfo);
  119.                         return;
  120.                 }
  121.  
  122.                 /* Check for realname bans here too */
  123.                 if (!ValidatePermissionsForPath("immune:server-ban:ban-realname",client,NULL,NULL,NULL) &&
  124.                     ((bconf = find_ban(NULL, client->info, CONF_BAN_REALNAME)))){
  125.                         banned_client(client, "realname", bconf->reason?bconf->reason:"", 0, 0);
  126.                         return;
  127.                 }
  128.         } else {
  129.                 /* remote user */
  130.                 strcpy(client->info, parv[1]);
  131.         }
  132.  
  133.         sendto_server(client, 0, 0, NULL, ":%s SETNAME :%s", client->id, parv[1]);
  134.  
  135.         if(MyConnect(client)){
  136.                 sendto_one(client, recv_mtags, ":%s!%s@%s SETNAME :%s", client->name, client->user->username, GetHost(client), parv[1]);
  137.         }
  138.         sendto_local_common_channels(client, client, CAP_SETNAME, recv_mtags, ":%s!%s@%s SETNAME :%s", client->name, client->user->username, GetHost(client), parv[1]);
  139. }
  140.  

odpowiedzi na Bez tytułu rss

Tytuł Autor Język Dodano
Bez tytułu k4be c 4 lata temu.

odpowiedź "Bez tytułu"

Tutaj możesz odpowiedzieć na wklejkę z góry

captcha