ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/contrib/m_ojoin.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: 4825 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_ojoin.c: Allows opers join channels with @%+ modes
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 "client.h"
29     #include "ircd.h"
30     #include "numeric.h"
31     #include "send.h"
32     #include "hash.h"
33     #include "msg.h"
34     #include "s_serv.h"
35     #include "modules.h"
36     #include "channel_mode.h"
37     #include "common.h"
38    
39     static void mo_ojoin(struct Client *, struct Client *, int, char *[]);
40    
41     struct Message ojoin_msgtab = {
42     "OJOIN", 0, 0, 2, 0, MFLG_SLOW, 0,
43     { m_unregistered, m_not_oper, m_ignore, m_ignore, mo_ojoin, m_ignore }
44     };
45    
46     #ifndef STATIC_MODULES
47     void
48     _modinit(void)
49     {
50     mod_add_cmd(&ojoin_msgtab);
51     }
52    
53     void
54     _moddeinit(void)
55     {
56     mod_del_cmd(&ojoin_msgtab);
57     }
58    
59 knight 31 const char *_version = "$Revision$";
60 adx 30 #endif
61    
62     /* mo_ojoin()
63     * parv[0] = sender prefix
64     * parv[1] = channels separated by commas
65     */
66     static void
67     mo_ojoin(struct Client *client_p, struct Client *source_p,
68     int parc, char *parv[])
69     {
70     struct Channel *chptr = NULL;
71     const char *prefix = "";
72     char modeletter = '\0';
73     char *name = parv[1];
74     char *t = NULL;
75     unsigned int flags = 0;
76    
77     /* admins only */
78     if (!IsAdmin(source_p))
79     {
80     sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
81     me.name, source_p->name);
82     return;
83     }
84    
85     for (name = strtoken(&t, name, ","); name;
86     name = strtoken(&t, NULL, ","))
87     {
88     switch (*name)
89     {
90     case '@':
91     prefix = "@";
92     flags = CHFL_CHANOP;
93     modeletter = 'o';
94     ++name;
95     break;
96     #ifdef HALFOPS
97     case '%':
98     prefix = "%";
99     flags = CHFL_HALFOP;
100     modeletter = 'h';
101     ++name;
102     break;
103     #endif
104     case '+':
105     prefix = "+";
106     flags = CHFL_VOICE;
107     modeletter = 'v';
108     ++name;
109     break;
110     case '#':
111     case '&':
112     prefix = "";
113     flags = 0;
114     modeletter = '\0';
115     break;
116    
117     default:
118     sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
119     me.name, source_p->name, name);
120     continue;
121     }
122    
123     /* Error checking here */
124     if ((chptr = hash_find_channel(name)) == NULL)
125     {
126     sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
127     me.name, source_p->name, name);
128     }
129     else if (IsMember(source_p, chptr))
130     {
131     sendto_one(source_p, ":%s NOTICE %s :Please part %s before using OJOIN",
132     me.name, source_p->name, name);
133     }
134     else
135     {
136     add_user_to_channel(chptr, source_p, flags, NO);
137    
138     if (chptr->chname[0] == '#')
139     {
140     sendto_server(client_p, source_p, chptr, CAP_TS6, NOCAPS, LL_ICLIENT,
141     ":%s SJOIN %lu %s + :%s%s",
142     me.id, (unsigned long)chptr->channelts, chptr->chname,
143     prefix, source_p->id);
144     sendto_server(client_p, source_p, chptr, NOCAPS, CAP_TS6, LL_ICLIENT,
145     ":%s SJOIN %lu %s + :%s%s",
146     me.name, (unsigned long)chptr->channelts, chptr->chname,
147     prefix, source_p->name);
148     }
149    
150     sendto_channel_local(ALL_MEMBERS, NO, chptr, ":%s!%s@%s JOIN %s",
151     source_p->name, source_p->username,
152     source_p->host,
153     chptr->chname);
154    
155     if (modeletter != '\0')
156     sendto_channel_local(ALL_MEMBERS, NO, chptr, ":%s MODE %s +%c %s",
157     me.name, chptr->chname, modeletter, source_p->name);
158    
159     /* send the topic... */
160     if (chptr->topic != NULL)
161     {
162     sendto_one(source_p, form_str(RPL_TOPIC),
163     me.name, source_p->name, chptr->chname,
164     chptr->topic);
165     sendto_one(source_p, form_str(RPL_TOPICWHOTIME),
166     me.name, source_p->name, chptr->chname,
167     chptr->topic_info, chptr->topic_time);
168     }
169    
170     source_p->localClient->last_join_time = CurrentTime;
171     channel_member_names(source_p, chptr, 1);
172     }
173     }
174     }

Properties

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