ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid-8/contrib/m_opme.c
Revision: 1243
Committed: Fri Sep 30 10:47:53 2011 UTC (15 years ago) by michael
Content type: text/x-csrc
File size: 4398 byte(s)
Log Message:
- move content of msg.h, ircd_handler.h and handlers.h into parse.h and
  remove headers accordingly
- killed common.h
- remove m_killhost.c and m_flags.c from contrib/
- sort out unused header includes here and there

File Contents

# User Rev Content
1 adx 30 /*
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 knight 31 * $Id$
23 adx 30 */
24    
25     #include "stdinc.h"
26 michael 1011 #include "list.h"
27 adx 30 #include "channel.h"
28     #include "channel_mode.h"
29     #include "client.h"
30     #include "ircd.h"
31     #include "numeric.h"
32     #include "s_log.h"
33     #include "s_serv.h"
34     #include "send.h"
35     #include "irc_string.h"
36     #include "hash.h"
37     #include "parse.h"
38     #include "modules.h"
39    
40     static void mo_opme(struct Client *, struct Client *, int, char *[]);
41    
42     struct Message opme_msgtab = {
43 michael 1178 "OPME", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
44 adx 30 { m_unregistered, m_not_oper, m_ignore, m_ignore, mo_opme, m_ignore }
45     };
46    
47     void
48     _modinit(void)
49     {
50     mod_add_cmd(&opme_msgtab);
51     }
52    
53     void
54     _moddeinit(void)
55     {
56     mod_del_cmd(&opme_msgtab);
57     }
58    
59 knight 31 const char *_version = "$Revision$";
60 adx 30
61     static int
62     chan_is_opless(const struct Channel *const chptr)
63     {
64     const dlink_node *ptr = NULL;
65    
66     DLINK_FOREACH(ptr, chptr->members.head)
67     if (((struct Membership *)ptr->data)->flags & CHFL_CHANOP)
68 michael 885 return 0;
69 adx 30
70 michael 885 return 1;
71 adx 30 }
72    
73     /*
74     * mo_opme()
75     * parv[0] = sender prefix
76     * parv[1] = channel
77     */
78     static void
79     mo_opme(struct Client *client_p, struct Client *source_p,
80     int parc, char *parv[])
81     {
82     struct Channel *chptr = NULL;
83     struct Membership *member = NULL;
84    
85 michael 1219 if (!HasUMode(source_p, UMODE_ADMIN))
86 adx 30 {
87     sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
88     me.name, source_p->name);
89     return;
90     }
91    
92     if ((chptr = hash_find_channel(parv[1])) == NULL)
93     {
94     sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
95     me.name, source_p->name, parv[1]);
96     return;
97     }
98    
99     if ((member = find_channel_link(source_p, chptr)) == NULL)
100     {
101     sendto_one(source_p, form_str(ERR_NOTONCHANNEL),
102     me.name, source_p->name, chptr->chname);
103     return;
104     }
105    
106 michael 1011 if (!chan_is_opless(chptr))
107 adx 30 {
108     sendto_one(source_p, ":%s NOTICE %s :%s Channel is not opless",
109     me.name, source_p->name, chptr->chname);
110     return;
111     }
112    
113     AddMemberFlag(member, CHFL_CHANOP);
114    
115     if (*parv[1] == '&')
116     {
117     sendto_wallops_flags(UMODE_LOCOPS, &me,
118     "OPME called for [%s] by %s!%s@%s",
119     chptr->chname, source_p->name, source_p->username,
120     source_p->host);
121     }
122     else
123     {
124     sendto_wallops_flags(UMODE_WALLOP, &me,
125     "OPME called for [%s] by %s!%s@%s",
126     chptr->chname, source_p->name, source_p->username,
127     source_p->host);
128 michael 885 sendto_server(NULL, NULL, NOCAPS, NOCAPS,
129 adx 30 ":%s WALLOPS :OPME called for [%s] by %s!%s@%s",
130     me.name, chptr->chname, source_p->name, source_p->username,
131     source_p->host);
132     }
133    
134     ilog(L_NOTICE, "OPME called for [%s] by %s!%s@%s",
135     chptr->chname, source_p->name, source_p->username,
136     source_p->host);
137    
138 michael 885 sendto_server(NULL, chptr, CAP_TS6, NOCAPS,
139     ":%s PART %s", ID(source_p), chptr->chname);
140     sendto_server(NULL, chptr, NOCAPS, CAP_TS6,
141 adx 30 ":%s PART %s", source_p->name, chptr->chname);
142 michael 885
143     sendto_server(NULL, chptr, CAP_TS6, NOCAPS,
144 adx 30 ":%s SJOIN %lu %s + :@%s",
145     me.id, (unsigned long)chptr->channelts,
146     chptr->chname, ID(source_p));
147 michael 885 sendto_server(NULL, chptr, NOCAPS, CAP_TS6,
148 adx 30 ":%s SJOIN %lu %s + :@%s",
149     me.name, (unsigned long)chptr->channelts,
150     chptr->chname, source_p->name);
151    
152 michael 1011 sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s MODE %s +o %s",
153 adx 30 me.name, chptr->chname, source_p->name);
154     }

Properties

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