/[svn]/ircd-hybrid-7.2/modules/m_topic.c
ViewVC logotype

Contents of /ircd-hybrid-7.2/modules/m_topic.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1011 - (show annotations)
Fri Sep 18 10:14:09 2009 UTC (9 years, 11 months ago) by michael
File MIME type: text/x-chdr
File size: 4687 byte(s)
- move list manipulation routines from tools.c to list.c
- mem_frob() goes to memory.c
- sort out redundant/unneeded header includes

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 "list.h"
27 #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 static void m_topic(struct Client *, struct Client *, int, char *[]);
45
46 struct Message topic_msgtab = {
47 "TOPIC", 0, 0, 2, 0, MFLG_SLOW, 0,
48 {m_unregistered, m_topic, m_topic, m_ignore, m_topic, m_ignore}
49 };
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 const char *_version = "$Revision$";
65 #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 if (EmptyString(parv[1]))
91 {
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 if ((chptr = hash_find_channel(parv[1])) == NULL)
101 {
102 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 {
114 sendto_one(source_p, form_str(ERR_NOTONCHANNEL), from,
115 to, parv[1]);
116 return;
117 }
118
119 if (!(chptr->mode.mode & MODE_TOPICLIMIT) ||
120 has_member_flags(ms, CHFL_CHANOP|CHFL_HALFOP))
121 {
122 char topic_info[USERHOST_REPLYLEN];
123
124 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
128 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 sendto_channel_local(ALL_MEMBERS, 0,
137 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 }
144 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 {
152 if (chptr->topic == NULL)
153 sendto_one(source_p, form_str(RPL_NOTOPIC),
154 from, to, chptr->chname);
155 else
156 {
157 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 }
165 }
166 else
167 sendto_one(source_p, form_str(ERR_NOTONCHANNEL),
168 from, to, chptr->chname);
169 }
170 }

Properties

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

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.26