ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/releases/8.1.0beta1/modules/m_topic.c
Revision: 1121
Committed: Sun Jan 9 11:03:03 2011 UTC (14 years, 7 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid-7.3/modules/m_topic.c
File size: 4657 byte(s)
Log Message:
- removed all instances of STATIC_MODULES since we don't have
  static modules anymore
- removed m_mkpasswd module from contrib

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     void
52     _modinit(void)
53     {
54     mod_add_cmd(&topic_msgtab);
55     }
56    
57     void
58     _moddeinit(void)
59     {
60     mod_del_cmd(&topic_msgtab);
61     }
62    
63 knight 31 const char *_version = "$Revision$";
64 adx 30
65     /* m_topic()
66     * parv[0] = sender prefix
67     * parv[1] = channel name
68     * parv[2] = new topic, if setting topic
69     */
70     static void
71     m_topic(struct Client *client_p, struct Client *source_p,
72     int parc, char *parv[])
73     {
74     struct Channel *chptr = NULL;
75     const char *from, *to;
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 michael 885 if (EmptyString(parv[1]))
89 adx 30 {
90     sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
91     from, to, "TOPIC");
92     return;
93     }
94    
95     if (MyClient(source_p) && !IsFloodDone(source_p))
96     flood_endgrace(source_p);
97    
98 michael 895 if ((chptr = hash_find_channel(parv[1])) == NULL)
99 adx 30 {
100 michael 895 sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
101     from, to, parv[1]);
102     return;
103     }
104    
105     /* setting topic */
106     if (parc > 2)
107     {
108     struct Membership *ms;
109    
110     if ((ms = find_channel_link(source_p, chptr)) == NULL)
111 adx 30 {
112 michael 895 sendto_one(source_p, form_str(ERR_NOTONCHANNEL), from,
113     to, parv[1]);
114 michael 885 return;
115 adx 30 }
116    
117 michael 895 if (!(chptr->mode.mode & MODE_TOPICLIMIT) ||
118     has_member_flags(ms, CHFL_CHANOP|CHFL_HALFOP))
119 adx 30 {
120 michael 895 char topic_info[USERHOST_REPLYLEN];
121 michael 885
122 michael 895 ircsprintf(topic_info, "%s!%s@%s", source_p->name,
123     source_p->username, source_p->host);
124     set_channel_topic(chptr, parv[2], topic_info, CurrentTime);
125 adx 30
126 michael 895 sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
127     ":%s TOPIC %s :%s",
128     ID(source_p), chptr->chname,
129     chptr->topic == NULL ? "" : chptr->topic);
130     sendto_server(client_p, chptr, NOCAPS, CAP_TS6,
131     ":%s TOPIC %s :%s",
132     source_p->name, chptr->chname,
133     chptr->topic == NULL ? "" : chptr->topic);
134 michael 1011 sendto_channel_local(ALL_MEMBERS, 0,
135 michael 895 chptr, ":%s!%s@%s TOPIC %s :%s",
136     source_p->name,
137     source_p->username,
138     source_p->host,
139     chptr->chname, chptr->topic == NULL ?
140     "" : chptr->topic);
141 adx 30 }
142 michael 895 else
143     sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
144     from, to, chptr->chname);
145     }
146     else /* only asking for topic */
147     {
148     if (!SecretChannel(chptr) || IsMember(source_p, chptr))
149 adx 30 {
150 michael 895 if (chptr->topic == NULL)
151     sendto_one(source_p, form_str(RPL_NOTOPIC),
152     from, to, chptr->chname);
153 adx 30 else
154     {
155 michael 895 sendto_one(source_p, form_str(RPL_TOPIC),
156     from, to,
157     chptr->chname, chptr->topic);
158     sendto_one(source_p, form_str(RPL_TOPICWHOTIME),
159     from, to, chptr->chname,
160     chptr->topic_info,
161     chptr->topic_time);
162 adx 30 }
163     }
164     else
165 michael 895 sendto_one(source_p, form_str(ERR_NOTONCHANNEL),
166     from, to, chptr->chname);
167 adx 30 }
168     }

Properties

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