Anope IRC Services  Version 1.8
ns_status.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 static int do_status(User * u);
18 static void myNickServHelp(User * u);
19 
26 int AnopeInit(int argc, char **argv)
27 {
28  Command *c;
29 
30  moduleAddAuthor("Anope");
31  moduleAddVersion(VERSION_STRING);
33 
34  c = createCommand("STATUS", do_status, NULL, NICK_HELP_STATUS, -1, -1,
35  -1, -1);
37 
39 
40  return MOD_CONT;
41 }
42 
46 void AnopeFini(void)
47 {
48 
49 }
50 
55 static void myNickServHelp(User * u)
56 {
57  notice_lang(s_NickServ, u, NICK_HELP_CMD_STATUS);
58 }
59 
65 static int do_status(User * u)
66 {
67  User *u2;
68  NickAlias *na = NULL;
69  int i = 0;
70  char *nick = strtok(NULL, " ");
71 
72  /* If no nickname is given, we assume that the user
73  * is asking for himself */
74  if (!nick)
75  nick = u->nick;
76 
77  while (nick && (i++ < 16)) {
78  if (!(u2 = finduser(nick))) /* Nick is not online */
79  notice_lang(s_NickServ, u, NICK_STATUS_0, nick);
80  else if (nick_identified(u2)) /* Nick is identified */
81  notice_lang(s_NickServ, u, NICK_STATUS_3, nick);
82  else if (nick_recognized(u2)) /* Nick is recognised, but NOT identified */
83  notice_lang(s_NickServ, u, NICK_STATUS_2, nick);
84  else if ((na = findnick(nick)) == NULL) /* Nick is online, but NOT a registered */
85  notice_lang(s_NickServ, u, NICK_STATUS_0, nick);
86  else
87  notice_lang(s_NickServ, u, NICK_STATUS_1, nick);
88 
89  /* Get the next nickname */
90  nick = strtok(NULL, " ");
91  }
92  return MOD_CONT;
93 }
void AnopeFini(void)
Definition: ns_status.c:46
char nick[NICKMAX]
Definition: services.h:875
E NickAlias * findnick(const char *nick)
Definition: db-merger.c:1857
E int nick_identified(User *u)
Definition: nickserv.c:1111
static int do_status(User *u)
Definition: ns_status.c:65
MDE void moduleAddAuthor(const char *author)
Definition: modules.c:1772
E void notice_lang(char *source, User *dest, int message,...)
Definition: send.c:169
MDE void moduleSetType(MODType type)
Definition: modules.c:818
E int nick_recognized(User *u)
Definition: nickserv.c:1131
E User * finduser(const char *nick)
Definition: users.c:323
MDE void moduleAddVersion(const char *version)
Definition: modules.c:1760
Command * c
Definition: ns_recover.c:17
#define MOD_CONT
Definition: modules.h:54
int AnopeInit(int argc, char **argv)
Definition: ns_status.c:26
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
static void myNickServHelp(User *u)
Definition: ns_status.c:55
E char * s_NickServ
Definition: extern.h:284
MDE int moduleAddCommand(CommandHash *cmdTable[], Command *c, int pos)
Definition: modules.c:1082
#define NICKSERV
Definition: modules.h:59
#define MOD_UNIQUE
Definition: module.h:11