| 42 |
|
#include "packet.h" |
| 43 |
|
#include "common.h" |
| 44 |
|
|
| 45 |
< |
static void m_topic(struct Client *, struct Client *, int, char **); |
| 46 |
< |
static void ms_topic(struct Client *, struct Client *, int, char **); |
| 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, ms_topic, m_ignore, m_topic, m_ignore} |
| 49 |
> |
{m_unregistered, m_topic, m_topic, m_ignore, m_topic, m_ignore} |
| 50 |
|
}; |
| 51 |
|
|
| 52 |
|
#ifndef STATIC_MODULES |
| 75 |
|
int parc, char *parv[]) |
| 76 |
|
{ |
| 77 |
|
struct Channel *chptr = NULL; |
| 79 |
– |
char *p; |
| 80 |
– |
struct Membership *ms; |
| 78 |
|
const char *from, *to; |
| 79 |
|
|
| 80 |
|
if (!MyClient(source_p) && IsCapable(source_p->from, CAP_TS6) && HasID(source_p)) |
| 88 |
|
to = source_p->name; |
| 89 |
|
} |
| 90 |
|
|
| 94 |
– |
if ((p = strchr(parv[1], ',')) != NULL) |
| 95 |
– |
*p = '\0'; |
| 96 |
– |
|
| 91 |
|
if (EmptyString(parv[1])) |
| 92 |
|
{ |
| 93 |
|
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), |
| 98 |
|
if (MyClient(source_p) && !IsFloodDone(source_p)) |
| 99 |
|
flood_endgrace(source_p); |
| 100 |
|
|
| 101 |
< |
if (IsChanPrefix(*parv[1])) |
| 108 |
< |
{ |
| 109 |
< |
if ((chptr = hash_find_channel(parv[1])) == NULL) |
| 110 |
< |
{ |
| 111 |
< |
sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL), |
| 112 |
< |
from, to, parv[1]); |
| 113 |
< |
return; |
| 114 |
< |
} |
| 115 |
< |
|
| 116 |
< |
/* setting topic */ |
| 117 |
< |
if (parc > 2) |
| 118 |
< |
{ |
| 119 |
< |
if ((ms = find_channel_link(source_p, chptr)) == NULL) |
| 120 |
< |
{ |
| 121 |
< |
sendto_one(source_p, form_str(ERR_NOTONCHANNEL), from, |
| 122 |
< |
to, parv[1]); |
| 123 |
< |
return; |
| 124 |
< |
} |
| 125 |
< |
|
| 126 |
< |
if ((chptr->mode.mode & MODE_TOPICLIMIT) == 0 || |
| 127 |
< |
has_member_flags(ms, CHFL_CHANOP|CHFL_HALFOP)) |
| 128 |
< |
{ |
| 129 |
< |
char topic_info[USERHOST_REPLYLEN]; |
| 130 |
< |
ircsprintf(topic_info, "%s!%s@%s", |
| 131 |
< |
source_p->name, source_p->username, source_p->host); |
| 132 |
< |
set_channel_topic(chptr, parv[2], topic_info, CurrentTime); |
| 133 |
< |
|
| 134 |
< |
sendto_server(client_p, chptr, CAP_TS6, NOCAPS, |
| 135 |
< |
":%s TOPIC %s :%s", |
| 136 |
< |
ID(source_p), chptr->chname, |
| 137 |
< |
chptr->topic == NULL ? "" : chptr->topic); |
| 138 |
< |
sendto_server(client_p, chptr, NOCAPS, CAP_TS6, |
| 139 |
< |
":%s TOPIC %s :%s", |
| 140 |
< |
source_p->name, chptr->chname, |
| 141 |
< |
chptr->topic == NULL ? "" : chptr->topic); |
| 142 |
< |
sendto_channel_local(ALL_MEMBERS, NO, |
| 143 |
< |
chptr, ":%s!%s@%s TOPIC %s :%s", |
| 144 |
< |
source_p->name, |
| 145 |
< |
source_p->username, |
| 146 |
< |
source_p->host, |
| 147 |
< |
chptr->chname, chptr->topic == NULL ? |
| 148 |
< |
"" : chptr->topic); |
| 149 |
< |
} |
| 150 |
< |
else |
| 151 |
< |
sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED), |
| 152 |
< |
from, to, chptr->chname); |
| 153 |
< |
} |
| 154 |
< |
else /* only asking for topic */ |
| 155 |
< |
{ |
| 156 |
< |
if (!SecretChannel(chptr) || IsMember(source_p, chptr)) |
| 157 |
< |
{ |
| 158 |
< |
if (chptr->topic == NULL) |
| 159 |
< |
sendto_one(source_p, form_str(RPL_NOTOPIC), |
| 160 |
< |
from, to, chptr->chname); |
| 161 |
< |
else |
| 162 |
< |
{ |
| 163 |
< |
sendto_one(source_p, form_str(RPL_TOPIC), |
| 164 |
< |
from, to, |
| 165 |
< |
chptr->chname, chptr->topic); |
| 166 |
< |
|
| 167 |
< |
sendto_one(source_p, form_str(RPL_TOPICWHOTIME), |
| 168 |
< |
from, to, chptr->chname, |
| 169 |
< |
chptr->topic_info, |
| 170 |
< |
chptr->topic_time); |
| 171 |
< |
} |
| 172 |
< |
} |
| 173 |
< |
else |
| 174 |
< |
{ |
| 175 |
< |
sendto_one(source_p, form_str(ERR_NOTONCHANNEL), |
| 176 |
< |
from, to, chptr->chname); |
| 177 |
< |
return; |
| 178 |
< |
} |
| 179 |
< |
} |
| 180 |
< |
} |
| 181 |
< |
else |
| 101 |
> |
if ((chptr = hash_find_channel(parv[1])) == NULL) |
| 102 |
|
{ |
| 103 |
|
sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL), |
| 104 |
|
from, to, parv[1]); |
| 185 |
– |
} |
| 186 |
– |
} |
| 187 |
– |
|
| 188 |
– |
/* |
| 189 |
– |
* ms_topic |
| 190 |
– |
* parv[0] = sender prefix |
| 191 |
– |
* parv[1] = channel name |
| 192 |
– |
* parv[2] = topic_info |
| 193 |
– |
* parv[3] = topic_info time |
| 194 |
– |
* parv[4] = new channel topic |
| 195 |
– |
* |
| 196 |
– |
* Let servers always set a topic |
| 197 |
– |
*/ |
| 198 |
– |
static void |
| 199 |
– |
ms_topic(struct Client *client_p, struct Client *source_p, |
| 200 |
– |
int parc, char *parv[]) |
| 201 |
– |
{ |
| 202 |
– |
struct Channel *chptr = NULL; |
| 203 |
– |
|
| 204 |
– |
if (!IsServer(source_p)) |
| 205 |
– |
{ |
| 206 |
– |
m_topic(client_p, source_p, parc, parv); |
| 105 |
|
return; |
| 106 |
|
} |
| 107 |
|
|
| 108 |
< |
if (parc < 5) |
| 109 |
< |
return; |
| 212 |
< |
|
| 213 |
< |
if (parv[1] && IsChanPrefix(*parv[1])) |
| 108 |
> |
/* setting topic */ |
| 109 |
> |
if (parc > 2) |
| 110 |
|
{ |
| 111 |
< |
if ((chptr = hash_find_channel(parv[1])) == NULL) |
| 216 |
< |
return; |
| 111 |
> |
struct Membership *ms; |
| 112 |
|
|
| 113 |
< |
set_channel_topic(chptr, parv[4], parv[2], atoi(parv[3])); |
| 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 (ConfigServerHide.hide_servers) |
| 120 |
> |
if (!(chptr->mode.mode & MODE_TOPICLIMIT) || |
| 121 |
> |
has_member_flags(ms, CHFL_CHANOP|CHFL_HALFOP)) |
| 122 |
|
{ |
| 123 |
< |
sendto_channel_local(ALL_MEMBERS, NO, chptr, ":%s TOPIC %s :%s", |
| 223 |
< |
me.name, chptr->chname, |
| 224 |
< |
chptr->topic == NULL ? "" : chptr->topic); |
| 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 |
< |
sendto_channel_local(ALL_MEMBERS, NO, chptr, ":%s TOPIC %s :%s", |
| 154 |
< |
source_p->name, chptr->chname, |
| 155 |
< |
chptr->topic == NULL ? "" : chptr->topic); |
| 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 |
|
} |