Anope IRC Services  Version 1.8
ns_logout.c
Go to the documentation of this file.
1 /* NickServ core functions
2  *
3  * (C) 2003-2014 Anope Team
4  * Contact us at team@anope.org
5  *
6  * Please read COPYING and README for further details.
7  *
8  * Based on the original code of Epona by Lara.
9  * Based on the original code of Services by Andy Church.
10  *
11  *
12  */
13 /*************************************************************************/
14 
15 #include "module.h"
16 
17 #define TO_COLLIDE 0 /* Collide the user with this nick */
18 #define TO_RELEASE 1 /* Release a collided nick */
19 
20 static int do_logout(User * u);
21 static void myNickServHelp(User * u);
22 
29 int AnopeInit(int argc, char **argv)
30 {
31  Command *c;
32 
33  moduleAddAuthor("Anope");
34  moduleAddVersion(VERSION_STRING);
36 
37  c = createCommand("LOGOUT", do_logout, NULL, -1, NICK_HELP_LOGOUT, -1,
38  NICK_SERVADMIN_HELP_LOGOUT,
39  NICK_SERVADMIN_HELP_LOGOUT);
41 
43 
44  return MOD_CONT;
45 }
46 
50 void AnopeFini(void)
51 {
52 
53 }
54 
55 
56 
61 static void myNickServHelp(User * u)
62 {
63  notice_lang(s_NickServ, u, NICK_HELP_CMD_LOGOUT);
64 }
65 
71 static int do_logout(User * u)
72 {
73  char *nick = strtok(NULL, " ");
74  char *param = strtok(NULL, " ");
75  struct u_chaninfolist *ci, *ci2;
76  User *u2;
77 
78  if (!is_services_admin(u) && nick) {
79  syntax_error(s_NickServ, u, "LOGOUT", NICK_LOGOUT_SYNTAX);
80  } else if (!(u2 = (nick ? finduser(nick) : u))) {
81  notice_lang(s_NickServ, u, NICK_X_NOT_IN_USE, nick);
82  } else if (!u2->na) {
83  if (nick)
84  notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick);
85  else
86  notice_lang(s_NickServ, u, NICK_NOT_REGISTERED);
87  } else if (u2->na->status & NS_VERBOTEN) {
88  notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, u2->na->nick);
89  } else if (!nick && !nick_identified(u)) {
90  notice_lang(s_NickServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ);
91  } else if (nick && is_services_admin(u2)) {
92  notice_lang(s_NickServ, u, NICK_LOGOUT_SERVICESADMIN, nick);
93  } else {
94  if (nick && param && !stricmp(param, "REVALIDATE")) {
95  cancel_user(u2);
96  validate_user(u2);
97  } else {
98  u2->na->status &= ~(NS_IDENTIFIED | NS_RECOGNIZED);
99  }
100 
101  if (ircd->modeonreg) {
102  common_svsmode(u2, ircd->modeonunreg, "1");
103  }
104 
105  u2->isSuperAdmin = 0; /* Dont let people logout and remain a SuperAdmin */
106  alog("%s: %s!%s@%s logged out nickname %s", s_NickServ, u->nick,
107  u->username, u->host, u2->nick);
108 
109  if (nick)
110  notice_lang(s_NickServ, u, NICK_LOGOUT_X_SUCCEEDED, nick);
111  else
112  notice_lang(s_NickServ, u, NICK_LOGOUT_SUCCEEDED);
113 
114  /* remove founderstatus from this user in all channels */
115  ci = u2->founder_chans;
116  while (ci) {
117  ci2 = ci->next;
118  free(ci);
119  ci = ci2;
120  }
121  u2->founder_chans = NULL;
122 
123 
124  /* Stop nick tracking if enabled */
125  if (NSNickTracking)
126  nsStopNickTracking(u2);
127 
128  /* Clear any timers again */
129  if (u2->na->nc->flags & NI_KILLPROTECT) {
131  }
132 
133  /* Send out an event */
135  }
136  return MOD_CONT;
137 }
char nick[NICKMAX]
Definition: services.h:875
struct user_::u_chaninfolist * founder_chans
E IRCDVar * ircd
Definition: extern.h:39
void AnopeFini(void)
Definition: ns_logout.c:50
E int nick_identified(User *u)
Definition: nickserv.c:1111
E void send_event(const char *name, int argc,...)
Definition: events.c:37
E void del_ns_timeout(NickAlias *na, int type)
Definition: nickserv.c:1831
E int NSNickTracking
Definition: extern.h:399
E int stricmp(const char *s1, const char *s2)
Definition: compat.c:58
static void myNickServHelp(User *u)
Definition: ns_logout.c:61
#define NS_RECOGNIZED
Definition: services.h:1276
#define NS_VERBOTEN
Definition: services.h:1273
char * modeonreg
Definition: services.h:307
#define NI_KILLPROTECT
Definition: services.h:1290
int isSuperAdmin
Definition: services.h:896
MDE void moduleAddAuthor(const char *author)
Definition: modules.c:1772
E void syntax_error(char *service, User *u, const char *command, int msgnum)
Definition: language.c:295
E void notice_lang(char *source, User *dest, int message,...)
Definition: send.c:169
MDE void moduleSetType(MODType type)
Definition: modules.c:818
NickCore * nc
Definition: services.h:533
struct u_chaninfolist * next
Definition: services.h:905
E User * finduser(const char *nick)
Definition: users.c:323
uint16 status
Definition: services.h:532
MDE void moduleAddVersion(const char *version)
Definition: modules.c:1760
Command * c
Definition: ns_recover.c:17
E void alog(const char *fmt,...) FORMAT(printf
#define MOD_CONT
Definition: modules.h:54
E void cancel_user(User *u)
Definition: nickserv.c:1067
E int is_services_admin(User *u)
Definition: operserv.c:591
static int do_logout(User *u)
Definition: ns_logout.c:71
char * nick
Definition: services.h:526
E int validate_user(User *u)
Definition: nickserv.c:990
MDE void moduleSetNickHelp(void(*func)(User *u))
Definition: modules.c:2078
Definition: modules.h:99
MDE Command * createCommand(const char *name, int(*func)(User *u), int(*has_priv)(User *u), int help_all, int help_reg, int help_oper, int help_admin, int help_root)
Definition: modules.c:987
E void nsStopNickTracking(User *u)
Definition: nickserv.c:1984
int AnopeInit(int argc, char **argv)
Definition: ns_logout.c:29
#define NS_IDENTIFIED
Definition: services.h:1275
uint32 flags
Definition: services.h:548
E void common_svsmode(User *u, char *modes, char *arg)
Definition: actions.c:228
E char * s_NickServ
Definition: extern.h:284
MDE int moduleAddCommand(CommandHash *cmdTable[], Command *c, int pos)
Definition: modules.c:1082
#define EVENT_NICK_LOGOUT
Definition: events.h:67
char * modeonunreg
Definition: services.h:311
#define NICKSERV
Definition: modules.h:59
NickAlias * na
Definition: services.h:892
#define MOD_UNIQUE
Definition: module.h:11
#define TO_COLLIDE
Definition: ns_logout.c:17