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

Properties

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