ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid-8/modules/m_topic.c
Revision: 1028
Committed: Sun Nov 8 13:03:38 2009 UTC (16 years, 8 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid/modules/m_topic.c
File size: 4687 byte(s)
Log Message:
- move ircd-hybrid-7.2 to trunk

File Contents

# User Rev Content
1 adx 30 /*
2     * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3     * m_topic.c: Sets a channel topic.
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 "handlers.h"
28     #include "channel.h"
29     #include "channel_mode.h"
30     #include "client.h"
31     #include "hash.h"
32     #include "irc_string.h"
33     #include "sprintf_irc.h"
34     #include "ircd.h"
35     #include "numeric.h"
36     #include "send.h"
37     #include "s_conf.h"
38     #include "s_serv.h"
39     #include "msg.h"
40     #include "parse.h"
41     #include "modules.h"
42     #include "packet.h"
43    
44 michael 895 static void m_topic(struct Client *, struct Client *, int, char *[]);
45 adx 30
46     struct Message topic_msgtab = {
47     "TOPIC", 0, 0, 2, 0, MFLG_SLOW, 0,
48 michael 895 {m_unregistered, m_topic, m_topic, m_ignore, m_topic, m_ignore}
49 adx 30 };
50    
51     #ifndef STATIC_MODULES
52     void
53     _modinit(void)
54     {
55     mod_add_cmd(&topic_msgtab);
56     }
57    
58     void
59     _moddeinit(void)
60     {
61     mod_del_cmd(&topic_msgtab);
62     }
63    
64 knight 31 const char *_version = "$Revision$";
65 adx 30 #endif
66    
67     /* m_topic()
68     * parv[0] = sender prefix
69     * parv[1] = channel name
70     * parv[2] = new topic, if setting topic
71     */
72     static void
73     m_topic(struct Client *client_p, struct Client *source_p,
74     int parc, char *parv[])
75     {
76     struct Channel *chptr = NULL;
77     const char *from, *to;
78    
79     if (!MyClient(source_p) && IsCapable(source_p->from, CAP_TS6) && HasID(source_p))
80     {
81     from = me.id;
82     to = source_p->id;
83     }
84     else
85     {
86     from = me.name;
87     to = source_p->name;
88     }
89    
90 michael 885 if (EmptyString(parv[1]))
91 adx 30 {
92     sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
93     from, to, "TOPIC");
94     return;
95     }
96    
97     if (MyClient(source_p) && !IsFloodDone(source_p))
98     flood_endgrace(source_p);
99    
100 michael 895 if ((chptr = hash_find_channel(parv[1])) == NULL)
101 adx 30 {
102 michael 895 sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
103     from, to, parv[1]);
104     return;
105     }
106    
107     /* setting topic */
108     if (parc > 2)
109     {
110     struct Membership *ms;
111    
112     if ((ms = find_channel_link(source_p, chptr)) == NULL)
113 adx 30 {
114 michael 895 sendto_one(source_p, form_str(ERR_NOTONCHANNEL), from,
115     to, parv[1]);
116 michael 885 return;
117 adx 30 }
118    
119 michael 895 if (!(chptr->mode.mode & MODE_TOPICLIMIT) ||
120     has_member_flags(ms, CHFL_CHANOP|CHFL_HALFOP))
121 adx 30 {
122 michael 895 char topic_info[USERHOST_REPLYLEN];
123 michael 885
124 michael 895 ircsprintf(topic_info, "%s!%s@%s", source_p->name,
125     source_p->username, source_p->host);
126     set_channel_topic(chptr, parv[2], topic_info, CurrentTime);
127 adx 30
128 michael 895 sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
129     ":%s TOPIC %s :%s",
130     ID(source_p), chptr->chname,
131     chptr->topic == NULL ? "" : chptr->topic);
132     sendto_server(client_p, chptr, NOCAPS, CAP_TS6,
133     ":%s TOPIC %s :%s",
134     source_p->name, chptr->chname,
135     chptr->topic == NULL ? "" : chptr->topic);
136 michael 1011 sendto_channel_local(ALL_MEMBERS, 0,
137 michael 895 chptr, ":%s!%s@%s TOPIC %s :%s",
138     source_p->name,
139     source_p->username,
140     source_p->host,
141     chptr->chname, chptr->topic == NULL ?
142     "" : chptr->topic);
143 adx 30 }
144 michael 895 else
145     sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
146     from, to, chptr->chname);
147     }
148     else /* only asking for topic */
149     {
150     if (!SecretChannel(chptr) || IsMember(source_p, chptr))
151 adx 30 {
152 michael 895 if (chptr->topic == NULL)
153     sendto_one(source_p, form_str(RPL_NOTOPIC),
154     from, to, chptr->chname);
155 adx 30 else
156     {
157 michael 895 sendto_one(source_p, form_str(RPL_TOPIC),
158     from, to,
159     chptr->chname, chptr->topic);
160     sendto_one(source_p, form_str(RPL_TOPICWHOTIME),
161     from, to, chptr->chname,
162     chptr->topic_info,
163     chptr->topic_time);
164 adx 30 }
165     }
166     else
167 michael 895 sendto_one(source_p, form_str(ERR_NOTONCHANNEL),
168     from, to, chptr->chname);
169 adx 30 }
170     }

Properties

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