ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/contrib/m_opme.c
Revision: 76
Committed: Tue Oct 4 19:38:49 2005 UTC (20 years, 10 months ago) by adx
Content type: text/x-csrc
File size: 4616 byte(s)
Log Message:
- fixed contrib #includes

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

Properties

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