/[svn]/ircd-hybrid/contrib/m_opme.c
ViewVC logotype

Contents of /ircd-hybrid/contrib/m_opme.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 30 - (show annotations)
Sun Oct 2 20:03:27 2005 UTC (14 years, 2 months ago) by adx
File MIME type: text/x-chdr
File size: 4731 byte(s)
- imported sources
- can be moved later according to the directory/branching scheme,
  but we need the svn up

1 /*
2 * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 * m_opme.c: Regains ops on opless channels
4 *
5 * Copyright (C) 2002 by the past and present ircd coders, and others.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 * USA
21 *
22 * $Id: m_opme.c,v 1.56 2005/07/31 05:32:25 adx Exp $
23 */
24
25 #include "stdinc.h"
26 #include "tools.h"
27 #include "handlers.h"
28 #include "channel.h"
29 #include "channel_mode.h"
30 #include "client.h"
31 #include "ircd.h"
32 #include "numeric.h"
33 #include "s_log.h"
34 #include "s_serv.h"
35 #include "send.h"
36 #include "whowas.h"
37 #include "irc_string.h"
38 #include "hash.h"
39 #include "msg.h"
40 #include "parse.h"
41 #include "modules.h"
42 #include "common.h"
43
44 static void mo_opme(struct Client *, struct Client *, int, char *[]);
45
46 struct Message opme_msgtab = {
47 "OPME", 0, 0, 2, 0, MFLG_SLOW, 0,
48 { m_unregistered, m_not_oper, m_ignore, m_ignore, mo_opme, m_ignore }
49 };
50
51 #ifndef STATIC_MODULES
52 void
53 _modinit(void)
54 {
55 mod_add_cmd(&opme_msgtab);
56 }
57
58 void
59 _moddeinit(void)
60 {
61 mod_del_cmd(&opme_msgtab);
62 }
63
64 const char *_version = "$Revision: 1.56 $";
65 #endif
66
67 static int
68 chan_is_opless(const struct Channel *const chptr)
69 {
70 const dlink_node *ptr = NULL;
71
72 DLINK_FOREACH(ptr, chptr->members.head)
73 if (((struct Membership *)ptr->data)->flags & CHFL_CHANOP)
74 return(0);
75
76 return(1);
77 }
78
79 /*
80 * mo_opme()
81 * parv[0] = sender prefix
82 * parv[1] = channel
83 */
84 static void
85 mo_opme(struct Client *client_p, struct Client *source_p,
86 int parc, char *parv[])
87 {
88 struct Channel *chptr = NULL;
89 struct Membership *member = NULL;
90
91 if (!IsAdmin(source_p))
92 {
93 sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
94 me.name, source_p->name);
95 return;
96 }
97
98 /* XXX - we might not have CBURSTed this channel if we are a lazylink
99 * yet. */
100 if ((chptr = hash_find_channel(parv[1])) == NULL)
101 {
102 sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
103 me.name, source_p->name, parv[1]);
104 return;
105 }
106
107 if ((member = find_channel_link(source_p, chptr)) == NULL)
108 {
109 sendto_one(source_p, form_str(ERR_NOTONCHANNEL),
110 me.name, source_p->name, chptr->chname);
111 return;
112 }
113
114 if (chan_is_opless(chptr) == 0)
115 {
116 sendto_one(source_p, ":%s NOTICE %s :%s Channel is not opless",
117 me.name, source_p->name, chptr->chname);
118 return;
119 }
120
121 AddMemberFlag(member, CHFL_CHANOP);
122
123 if (*parv[1] == '&')
124 {
125 sendto_wallops_flags(UMODE_LOCOPS, &me,
126 "OPME called for [%s] by %s!%s@%s",
127 chptr->chname, source_p->name, source_p->username,
128 source_p->host);
129 }
130 else
131 {
132 sendto_wallops_flags(UMODE_WALLOP, &me,
133 "OPME called for [%s] by %s!%s@%s",
134 chptr->chname, source_p->name, source_p->username,
135 source_p->host);
136 sendto_server(NULL, source_p, NULL, NOCAPS, NOCAPS, LL_ICLIENT,
137 ":%s WALLOPS :OPME called for [%s] by %s!%s@%s",
138 me.name, chptr->chname, source_p->name, source_p->username,
139 source_p->host);
140 }
141
142 ilog(L_NOTICE, "OPME called for [%s] by %s!%s@%s",
143 chptr->chname, source_p->name, source_p->username,
144 source_p->host);
145
146 sendto_server(NULL, source_p, chptr, CAP_TS6, NOCAPS, NOFLAGS,
147 ":%s PART %s", ID(source_p), chptr->chname);
148 sendto_server(NULL, source_p, chptr, NOCAPS, CAP_TS6, NOFLAGS,
149 ":%s PART %s", source_p->name, chptr->chname);
150 sendto_server(NULL, source_p, chptr, CAP_TS6, NOCAPS, NOFLAGS,
151 ":%s SJOIN %lu %s + :@%s",
152 me.id, (unsigned long)chptr->channelts,
153 chptr->chname, ID(source_p));
154 sendto_server(NULL, source_p, chptr, NOCAPS, CAP_TS6, NOFLAGS,
155 ":%s SJOIN %lu %s + :@%s",
156 me.name, (unsigned long)chptr->channelts,
157 chptr->chname, source_p->name);
158
159 sendto_channel_local(ALL_MEMBERS, NO, chptr, ":%s MODE %s +o %s",
160 me.name, chptr->chname, source_p->name);
161 }

Properties

Name Value
svn:eol-style native
svn:keywords "Id Revision"

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.26