ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid-7.2/modules/m_topic.c
Revision: 895
Committed: Fri Nov 2 11:15:22 2007 UTC (16 years, 4 months ago) by michael
Content type: text/x-csrc
File size: 4709 byte(s)
Log Message:
- Removed lazylink leftovers

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 "tools.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 #include "common.h"
44
45 static void m_topic(struct Client *, struct Client *, int, char *[]);
46
47 struct Message topic_msgtab = {
48 "TOPIC", 0, 0, 2, 0, MFLG_SLOW, 0,
49 {m_unregistered, m_topic, m_topic, m_ignore, m_topic, m_ignore}
50 };
51
52 #ifndef STATIC_MODULES
53 void
54 _modinit(void)
55 {
56 mod_add_cmd(&topic_msgtab);
57 }
58
59 void
60 _moddeinit(void)
61 {
62 mod_del_cmd(&topic_msgtab);
63 }
64
65 const char *_version = "$Revision$";
66 #endif
67
68 /* m_topic()
69 * parv[0] = sender prefix
70 * parv[1] = channel name
71 * parv[2] = new topic, if setting topic
72 */
73 static void
74 m_topic(struct Client *client_p, struct Client *source_p,
75 int parc, char *parv[])
76 {
77 struct Channel *chptr = NULL;
78 const char *from, *to;
79
80 if (!MyClient(source_p) && IsCapable(source_p->from, CAP_TS6) && HasID(source_p))
81 {
82 from = me.id;
83 to = source_p->id;
84 }
85 else
86 {
87 from = me.name;
88 to = source_p->name;
89 }
90
91 if (EmptyString(parv[1]))
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 struct Membership *ms;
112
113 if ((ms = find_channel_link(source_p, chptr)) == NULL)
114 {
115 sendto_one(source_p, form_str(ERR_NOTONCHANNEL), from,
116 to, parv[1]);
117 return;
118 }
119
120 if (!(chptr->mode.mode & MODE_TOPICLIMIT) ||
121 has_member_flags(ms, CHFL_CHANOP|CHFL_HALFOP))
122 {
123 char topic_info[USERHOST_REPLYLEN];
124
125 ircsprintf(topic_info, "%s!%s@%s", source_p->name,
126 source_p->username, source_p->host);
127 set_channel_topic(chptr, parv[2], topic_info, CurrentTime);
128
129 sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
130 ":%s TOPIC %s :%s",
131 ID(source_p), chptr->chname,
132 chptr->topic == NULL ? "" : chptr->topic);
133 sendto_server(client_p, chptr, NOCAPS, CAP_TS6,
134 ":%s TOPIC %s :%s",
135 source_p->name, chptr->chname,
136 chptr->topic == NULL ? "" : chptr->topic);
137 sendto_channel_local(ALL_MEMBERS, NO,
138 chptr, ":%s!%s@%s TOPIC %s :%s",
139 source_p->name,
140 source_p->username,
141 source_p->host,
142 chptr->chname, chptr->topic == NULL ?
143 "" : chptr->topic);
144 }
145 else
146 sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
147 from, to, chptr->chname);
148 }
149 else /* only asking for topic */
150 {
151 if (!SecretChannel(chptr) || IsMember(source_p, chptr))
152 {
153 if (chptr->topic == NULL)
154 sendto_one(source_p, form_str(RPL_NOTOPIC),
155 from, to, chptr->chname);
156 else
157 {
158 sendto_one(source_p, form_str(RPL_TOPIC),
159 from, to,
160 chptr->chname, chptr->topic);
161 sendto_one(source_p, form_str(RPL_TOPICWHOTIME),
162 from, to, chptr->chname,
163 chptr->topic_info,
164 chptr->topic_time);
165 }
166 }
167 else
168 sendto_one(source_p, form_str(ERR_NOTONCHANNEL),
169 from, to, chptr->chname);
170 }
171 }

Properties

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