Add PC_TOPIC flag to prepare_command() for topic-change commands.
Clean up e_topic(), splitting out untopic() and using prepare_command() to check for ops. git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@136 13b04d17-f746-0410-82c6-800466cd88b0
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
[Changes 1.2c01]
|
[Changes 1.2c01]
|
||||||
|
|
||||||
|
* Add half-op support to /topic and /untopic. (caf)
|
||||||
|
|
||||||
* Tidy up the URL grabber, fixing a memory leak. (caf)
|
* Tidy up the URL grabber, fixing a memory leak. (caf)
|
||||||
|
|
||||||
* Cleanup the /BHELP code, fixing a potential crash. Apply updates to
|
* Cleanup the /BHELP code, fixing a potential crash. Apply updates to
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ extern void cd (char *, char *, char *, char *);
|
|||||||
extern void e_wall (char *, char *, char *, char *);
|
extern void e_wall (char *, char *, char *, char *);
|
||||||
extern void send_2comm (char *, char *, char *, char *);
|
extern void send_2comm (char *, char *, char *, char *);
|
||||||
extern void send_comm (char *, char *, char *, char *);
|
extern void send_comm (char *, char *, char *, char *);
|
||||||
|
extern void untopic (char *, char *, char *, char *);
|
||||||
extern void e_topic (char *, char *, char *, char *);
|
extern void e_topic (char *, char *, char *, char *);
|
||||||
extern void send_kick (char *, char *, char *, char *);
|
extern void send_kick (char *, char *, char *, char *);
|
||||||
extern void send_channel_com (char *, char *, char *, char *);
|
extern void send_channel_com (char *, char *, char *, char *);
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ enum color_attributes {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#define DONT_CARE 3
|
#define DONT_CARE 3
|
||||||
|
#define PC_TOPIC 2
|
||||||
#define NEED_OP 1
|
#define NEED_OP 1
|
||||||
#define NO_OP 0
|
#define NO_OP 0
|
||||||
|
|
||||||
|
|||||||
@@ -690,7 +690,7 @@ IrcCommand irc_command[] =
|
|||||||
{ "UNSHIT", "UnShit", add_shit, 0, "%Y<%nnick%Y> <%nchannel%Y>%n" },
|
{ "UNSHIT", "UnShit", add_shit, 0, "%Y<%nnick%Y> <%nchannel%Y>%n" },
|
||||||
#endif
|
#endif
|
||||||
{ "UNTIL", "UNTIL", whilecmd, 0, scripting_command },
|
{ "UNTIL", "UNTIL", whilecmd, 0, scripting_command },
|
||||||
{ "UNTOPIC", "UNTOPIC", e_topic, 0, "- Unsets a channel topic" },
|
{ "UNTOPIC", "UNTOPIC", untopic, 0, "- Unsets a channel topic" },
|
||||||
#ifdef WANT_USERLIST
|
#ifdef WANT_USERLIST
|
||||||
{ "UNUSER", "UnUser", add_user, 0, "%Y<%nnick%W|%nnick!user@hostname%Y> <%n#channel%W|%n*%Y>%n" },
|
{ "UNUSER", "UnUser", add_user, 0, "%Y<%nnick%W|%nnick!user@hostname%Y> <%n#channel%W|%n*%Y>%n" },
|
||||||
#endif
|
#endif
|
||||||
@@ -3532,46 +3532,47 @@ char *str = NULL;
|
|||||||
send_to_server("%s %s %s", command, new_flag, serv);
|
send_to_server("%s %s %s", command, new_flag, serv);
|
||||||
}
|
}
|
||||||
|
|
||||||
BUILT_IN_COMMAND(e_topic)
|
BUILT_IN_COMMAND(untopic)
|
||||||
{
|
{
|
||||||
char *arg = NULL;
|
char *channel = NULL;
|
||||||
char *arg2;
|
|
||||||
ChannelList *chan;
|
ChannelList *chan;
|
||||||
int server;
|
int server;
|
||||||
int unset = 0;
|
|
||||||
|
|
||||||
|
args = sindex(args, "^ ");
|
||||||
|
|
||||||
arg = next_arg(args, &args);
|
if (is_channel(args))
|
||||||
if (!my_stricmp(command, "UNTOPIC"))
|
channel = next_arg(args, &args);
|
||||||
unset = 1;
|
|
||||||
if (!(chan = prepare_command(&server, arg?(is_channel(arg)?arg:NULL):NULL, NO_OP)))
|
if (!(chan = prepare_command(&server, channel, PC_TOPIC)))
|
||||||
return;
|
return;
|
||||||
if (unset)
|
|
||||||
{
|
|
||||||
my_send_to_server(server, "TOPIC %s :", chan->channel);
|
my_send_to_server(server, "TOPIC %s :", chan->channel);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (arg && (!(chan->mode & MODE_TOPIC) || chan->have_op))
|
|
||||||
|
BUILT_IN_COMMAND(e_topic)
|
||||||
{
|
{
|
||||||
if (is_channel(arg))
|
char *channel = NULL;
|
||||||
|
ChannelList *chan;
|
||||||
|
int server;
|
||||||
|
|
||||||
|
args = sindex(args, "^ ");
|
||||||
|
|
||||||
|
if (is_channel(args))
|
||||||
|
{
|
||||||
|
channel = next_arg(args, &args);
|
||||||
|
args = sindex(args, "^ ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(chan = prepare_command(&server, channel, args ? PC_TOPIC : NO_OP)))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (args)
|
||||||
{
|
{
|
||||||
add_last_type(&last_sent_topic[0], 1, NULL, NULL, chan->channel, args);
|
add_last_type(&last_sent_topic[0], 1, NULL, NULL, chan->channel, args);
|
||||||
if ((arg2 = next_arg(args, &args)))
|
my_send_to_server(server, "TOPIC %s :%s", chan->channel, args);
|
||||||
my_send_to_server(server, "%s %s :%s %s", command, chan->channel, arg2, args);
|
|
||||||
else
|
|
||||||
my_send_to_server(server, "%s %s", command, chan->channel);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
my_send_to_server(server, "TOPIC %s", chan->channel);
|
||||||
char *p = NULL;
|
|
||||||
p = m_sprintf("%s%s%s", arg, arg?space:empty_string, args?args:empty_string);
|
|
||||||
my_send_to_server(server, "%s %s :%s%s%s", command, chan->channel, arg, args?space:empty_string, args?args:empty_string);
|
|
||||||
add_last_type(&last_sent_topic[0], 1, NULL, NULL, chan->channel, p);
|
|
||||||
new_free(&p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
my_send_to_server(server, "%s %s", command, chan->channel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* MTOPIC by singe_ stolen from an idea by MHacker
|
/* MTOPIC by singe_ stolen from an idea by MHacker
|
||||||
@@ -3593,7 +3594,7 @@ BUILT_IN_COMMAND(do_mtopic)
|
|||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
if (!count)
|
if (!count)
|
||||||
bitchsay("Your not an op on any channels");
|
bitchsay("You're not an op on any channels");
|
||||||
} else
|
} else
|
||||||
bitchsay("No server for this window");
|
bitchsay("No server for this window");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4831,16 +4831,17 @@ int matchmcommand(char *origline,int count)
|
|||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
ChannelList *BX_prepare_command(int *active_server, char *channel, int need_op)
|
ChannelList *BX_prepare_command(int *active_server, char *channel, int flags)
|
||||||
{
|
{
|
||||||
int server = 0;
|
int server = 0;
|
||||||
ChannelList *chan = NULL;
|
ChannelList *chan = NULL;
|
||||||
|
int need_op;
|
||||||
|
|
||||||
if (!channel) {
|
if (!channel) {
|
||||||
channel = get_current_channel_by_refnum(0);
|
channel = get_current_channel_by_refnum(0);
|
||||||
|
|
||||||
if (!channel) {
|
if (!channel) {
|
||||||
if (need_op != 3) {
|
if (flags != 3) {
|
||||||
if (current_window)
|
if (current_window)
|
||||||
message_to(current_window->refnum);
|
message_to(current_window->refnum);
|
||||||
bitchsay("You're not on a channel!");
|
bitchsay("You're not on a channel!");
|
||||||
@@ -4853,7 +4854,7 @@ ChannelList *chan = NULL;
|
|||||||
*active_server = server;
|
*active_server = server;
|
||||||
if (!(chan = lookup_channel(channel, server, 0)))
|
if (!(chan = lookup_channel(channel, server, 0)))
|
||||||
{
|
{
|
||||||
if (need_op != 3) {
|
if (flags != 3) {
|
||||||
if (current_window)
|
if (current_window)
|
||||||
message_to(current_window->refnum);
|
message_to(current_window->refnum);
|
||||||
bitchsay("You're not on the channel: %s", channel);
|
bitchsay("You're not on the channel: %s", channel);
|
||||||
@@ -4861,7 +4862,9 @@ ChannelList *chan = NULL;
|
|||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (need_op == NEED_OP && chan && !chan->have_op && !chan->hop)
|
|
||||||
|
need_op = flags == NEED_OP || (flags == PC_TOPIC && (chan->mode & MODE_TOPIC));
|
||||||
|
if (need_op && !chan->have_op && !chan->hop)
|
||||||
{
|
{
|
||||||
error_not_opped(chan->channel);
|
error_not_opped(chan->channel);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
Reference in New Issue
Block a user