Fix /cycle command

- Uses the correct channelkey when called from another tab
- Allows it to be used from any tab in the same server
- Verifies it's a channel you are in
This commit is contained in:
TingPing 2013-09-23 17:17:35 -04:00
parent 04dbcdffc0
commit 9c4112cda7
1 changed files with 14 additions and 4 deletions

View File

@ -742,15 +742,25 @@ cmd_country (struct session *sess, char *tbuf, char *word[], char *word_eol[])
static int static int
cmd_cycle (struct session *sess, char *tbuf, char *word[], char *word_eol[]) cmd_cycle (struct session *sess, char *tbuf, char *word[], char *word_eol[])
{ {
char *key = sess->channelkey; char *key = NULL;
char *chan = word[2]; char *chan = word[2];
session *chan_sess;
if (!*chan) if (!*chan)
chan = sess->channel; chan = sess->channel;
if (*chan && sess->type == SESS_CHANNEL)
if (chan)
{ {
sess->server->p_cycle (sess->server, chan, key); chan_sess = find_channel (sess->server, chan);
return TRUE;
if (chan_sess && chan_sess->type == SESS_CHANNEL)
{
key = chan_sess->channelkey;
sess->server->p_cycle (sess->server, chan, key);
return TRUE;
}
} }
return FALSE; return FALSE;
} }