Anope IRC Services  Version 1.8
os_oline.c
Go to the documentation of this file.
1 /* OperServ 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 static int do_operoline(User * u);
17 
18 static void myOperServHelp(User * u);
19 
26 int AnopeInit(int argc, char **argv)
27 {
28  Command *c;
29 
30  moduleAddAuthor("Anope");
31  moduleAddVersion(VERSION_STRING);
33 
35  OPER_HELP_OLINE, -1, -1, -1, -1);
37 
39 
40  if (!ircd->omode) {
41  return MOD_STOP;
42  }
43  return MOD_CONT;
44 }
45 
49 void AnopeFini(void)
50 {
51 
52 }
53 
54 
59 static void myOperServHelp(User * u)
60 {
61  if (is_services_admin(u) && u->isSuperAdmin) {
62  notice_lang(s_OperServ, u, OPER_HELP_CMD_OLINE);
63  }
64 }
65 
71 static int do_operoline(User * u)
72 {
73  char *nick = strtok(NULL, " ");
74  char *flags = strtok(NULL, "");
75  User *u2 = NULL;
76 
77  /* Only allow this if SuperAdmin is enabled */
78  if (!u->isSuperAdmin) {
79  notice_lang(s_OperServ, u, OPER_SUPER_ADMIN_ONLY);
80  return MOD_CONT;
81  }
82 
83  if (!nick || !flags) {
84  syntax_error(s_OperServ, u, "OLINE", OPER_OLINE_SYNTAX);
85  return MOD_CONT;
86  } else {
87  /* let's check whether the user is online */
88  if (!(u2 = finduser(nick))) {
89  notice_lang(s_OperServ, u, NICK_X_NOT_IN_USE, nick);
90  } else if (u2 && flags[0] == '+') {
91  anope_cmd_svso(s_OperServ, nick, flags);
92  common_svsmode(u2, "+o", NULL);
93  notice_lang(s_OperServ, u2, OPER_OLINE_IRCOP);
94  notice_lang(s_OperServ, u, OPER_OLINE_SUCCESS, flags, nick);
95  anope_cmd_global(s_OperServ, "\2%s\2 used OLINE for %s",
96  u->nick, nick);
97  } else if (u2 && flags[0] == '-') {
98  anope_cmd_svso(s_OperServ, nick, flags);
99  notice_lang(s_OperServ, u, OPER_OLINE_SUCCESS, flags, nick);
100  anope_cmd_global(s_OperServ, "\2%s\2 used OLINE for %s",
101  u->nick, nick);
102  } else
103  syntax_error(s_OperServ, u, "OLINE", OPER_OLINE_SYNTAX);
104  }
105  return MOD_CONT;
106 }
char nick[NICKMAX]
Definition: services.h:875
E IRCDVar * ircd
Definition: extern.h:39
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
E int is_services_root(User *u)
Definition: operserv.c:577
#define OPERSERV
Definition: modules.h:62
E char * s_OperServ
Definition: extern.h:289
#define MOD_STOP
Definition: modules.h:53
E User * finduser(const char *nick)
Definition: users.c:323
int AnopeInit(int argc, char **argv)
Definition: os_oline.c:26
MDE void moduleAddVersion(const char *version)
Definition: modules.c:1760
static void myOperServHelp(User *u)
Definition: os_oline.c:59
Command * c
Definition: ns_recover.c:17
static int do_operoline(User *u)
Definition: os_oline.c:71
MDE void moduleSetOperHelp(void(*func)(User *u))
Definition: modules.c:2126
#define MOD_CONT
Definition: modules.h:54
E void anope_cmd_svso(char *source, char *nick, char *flag)
Definition: ircd.c:534
E int is_services_admin(User *u)
Definition: operserv.c:591
int omode
Definition: services.h:341
void AnopeFini(void)
Definition: os_oline.c:49
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 common_svsmode(User *u, char *modes, char *arg)
Definition: actions.c:228
MDE int moduleAddCommand(CommandHash *cmdTable[], Command *c, int pos)
Definition: modules.c:1082
#define MOD_UNIQUE
Definition: module.h:11
E void anope_cmd_global(char *source, const char *fmt,...)
Definition: ircd.c:506