ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/modules/m_topic.c
Revision: 470
Committed: Fri Feb 17 05:07:43 2006 UTC (18 years, 2 months ago) by db
Content type: text/x-csrc
File size: 4815 byte(s)
Log Message:
- fix compile errors with moved modules.h
- fix a few missing includes, msg.h and parse.h


File Contents

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

Properties

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