ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid-8/contrib/m_ojoin.c
Revision: 1268
Committed: Wed Jan 18 08:20:31 2012 UTC (13 years, 7 months ago) by michael
Content type: text/x-csrc
File size: 4799 byte(s)
Log Message:
- get contributed modules to work with new module api

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    
40     /* mo_ojoin()
41     * parv[0] = sender prefix
42     * parv[1] = channels separated by commas
43     */
44     static void
45     mo_ojoin(struct Client *client_p, struct Client *source_p,
46     int parc, char *parv[])
47     {
48     struct Channel *chptr = NULL;
49     const char *prefix = "";
50     char modeletter = '\0';
51     char *name = parv[1];
52     char *t = NULL;
53     unsigned int flags = 0;
54 adx 356 dlink_node *ptr;
55 adx 30
56     /* admins only */
57 michael 1219 if (!HasUMode(source_p, UMODE_ADMIN))
58 adx 30 {
59     sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
60     me.name, source_p->name);
61     return;
62     }
63    
64     for (name = strtoken(&t, name, ","); name;
65     name = strtoken(&t, NULL, ","))
66     {
67     switch (*name)
68     {
69     case '@':
70     prefix = "@";
71     flags = CHFL_CHANOP;
72     modeletter = 'o';
73     ++name;
74     break;
75     #ifdef HALFOPS
76     case '%':
77     prefix = "%";
78     flags = CHFL_HALFOP;
79     modeletter = 'h';
80     ++name;
81     break;
82     #endif
83     case '+':
84     prefix = "+";
85     flags = CHFL_VOICE;
86     modeletter = 'v';
87     ++name;
88     break;
89     case '#':
90     case '&':
91     prefix = "";
92     flags = 0;
93     modeletter = '\0';
94     break;
95    
96     default:
97     sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
98     me.name, source_p->name, name);
99     continue;
100     }
101    
102     /* Error checking here */
103     if ((chptr = hash_find_channel(name)) == NULL)
104     sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
105     me.name, source_p->name, name);
106     else if (IsMember(source_p, chptr))
107     sendto_one(source_p, ":%s NOTICE %s :Please part %s before using OJOIN",
108     me.name, source_p->name, name);
109     else
110     {
111 michael 1268 add_user_to_channel(chptr, source_p, flags, 0);
112 adx 30
113     if (chptr->chname[0] == '#')
114 adx 356 DLINK_FOREACH(ptr, serv_list.head)
115     {
116     struct Client *serv_p = ptr->data;
117 adx 30
118 michael 537 sendto_one(serv_p, ":%s SJOIN %lu %s + :%s%s", ID_or_name(&me, serv_p),
119     (unsigned long)chptr->channelts, chptr->chname,
120     (*prefix == '%' && !IsCapable(serv_p, CAP_HOPS)) ?
121     "@" : prefix, ID_or_name(source_p, serv_p));
122 adx 356 }
123    
124 michael 1268 sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s!%s@%s JOIN %s",
125 adx 30 source_p->name, source_p->username,
126     source_p->host,
127     chptr->chname);
128    
129     if (modeletter != '\0')
130 michael 1268 sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s MODE %s +%c %s",
131 adx 30 me.name, chptr->chname, modeletter, source_p->name);
132    
133     /* send the topic... */
134 michael 1203 if (chptr->topic[0])
135 adx 30 {
136     sendto_one(source_p, form_str(RPL_TOPIC),
137     me.name, source_p->name, chptr->chname,
138     chptr->topic);
139     sendto_one(source_p, form_str(RPL_TOPICWHOTIME),
140     me.name, source_p->name, chptr->chname,
141     chptr->topic_info, chptr->topic_time);
142     }
143    
144     source_p->localClient->last_join_time = CurrentTime;
145     channel_member_names(source_p, chptr, 1);
146     }
147     }
148     }
149 michael 1268
150     static struct Message ojoin_msgtab = {
151     "OJOIN", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
152     { m_unregistered, m_not_oper, m_ignore, m_ignore, mo_ojoin, m_ignore }
153     };
154    
155     static void
156     module_init(void)
157     {
158     mod_add_cmd(&ojoin_msgtab);
159     }
160    
161     static void
162     module_exit(void)
163     {
164     mod_del_cmd(&ojoin_msgtab);
165     }
166    
167     struct module module_entry = {
168     .node = { NULL, NULL, NULL },
169     .name = NULL,
170     .version = "$Revision$",
171     .handle = NULL,
172     .modinit = module_init,
173     .modexit = module_exit,
174     .flags = 0
175     };

Properties

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