aboutsummaryrefslogtreecommitdiffstats
path: root/irc_commands.c
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2010-03-27 10:31:03 -0400
committerWilmer van der Gaast <wilmer@gaast.net>2010-03-27 10:31:03 -0400
commitb91936398b8ada486e246f769f1f8b8836fa3f43 (patch)
treeb6e0067faa86490295f74083d15bc886ad56d83d /irc_commands.c
parent9b69eb789bdcb3667c4cc4ac74f3404ae3f60869 (diff)
Mode stuff. Also disallow unsetting +R umode which was possible so far
(and shouldn't be).
Diffstat (limited to 'irc_commands.c')
-rw-r--r--irc_commands.c50
1 files changed, 27 insertions, 23 deletions
diff --git a/irc_commands.c b/irc_commands.c
index 36807c54..5f9ae39f 100644
--- a/irc_commands.c
+++ b/irc_commands.c
@@ -183,29 +183,15 @@ static void irc_cmd_motd( irc_t *irc, char **cmd )
irc_send_motd( irc );
}
-#if 0
-//#if 0
-static void irc_cmd_oper( irc_t *irc, char **cmd )
-{
- if( global.conf->oper_pass &&
- ( strncmp( global.conf->oper_pass, "md5:", 4 ) == 0 ?
- md5_verify_password( cmd[2], global.conf->oper_pass + 4 ) == 0 :
- strcmp( cmd[2], global.conf->oper_pass ) == 0 ) )
- {
- irc_umode_set( irc, "+o", 1 );
- irc_send_num( irc, 381, ":Password accepted" );
- }
- else
- {
- irc_send_num( irc, 432, ":Incorrect password" );
- }
-}
-
static void irc_cmd_mode( irc_t *irc, char **cmd )
{
- if( strchr( CTYPES, *cmd[1] ) )
+ if( irc_channel_name_ok( cmd[1] ) )
{
- if( cmd[2] )
+ irc_channel_t *ic;
+
+ if( ( ic = irc_channel_by_name( irc, cmd[1] ) ) == NULL )
+ irc_send_num( irc, 403, "%s :No such channel", cmd[1] );
+ else if( cmd[2] )
{
if( *cmd[2] == '+' || *cmd[2] == '-' )
irc_send_num( irc, 477, "%s :Can't change channel modes", cmd[1] );
@@ -213,11 +199,11 @@ static void irc_cmd_mode( irc_t *irc, char **cmd )
irc_send_num( irc, 368, "%s :No bans possible", cmd[1] );
}
else
- irc_send_num( irc, 324, "%s +%s", cmd[1], CMODE );
+ irc_send_num( irc, 324, "%s +%s", cmd[1], ic->mode );
}
else
{
- if( nick_cmp( cmd[1], irc->nick ) == 0 )
+ if( nick_cmp( cmd[1], irc->user->nick ) == 0 )
{
if( cmd[2] )
irc_umode_set( irc, cmd[2], 0 );
@@ -229,6 +215,24 @@ static void irc_cmd_mode( irc_t *irc, char **cmd )
}
}
+#if 0
+//#if 0
+static void irc_cmd_oper( irc_t *irc, char **cmd )
+{
+ if( global.conf->oper_pass &&
+ ( strncmp( global.conf->oper_pass, "md5:", 4 ) == 0 ?
+ md5_verify_password( cmd[2], global.conf->oper_pass + 4 ) == 0 :
+ strcmp( cmd[2], global.conf->oper_pass ) == 0 ) )
+ {
+ irc_umode_set( irc, "+o", 1 );
+ irc_send_num( irc, 381, ":Password accepted" );
+ }
+ else
+ {
+ irc_send_num( irc, 432, ":Incorrect password" );
+ }
+}
+
static void irc_cmd_invite( irc_t *irc, char **cmd )
{
char *nick = cmd[1], *channel = cmd[2];
@@ -565,9 +569,9 @@ static const command_t irc_commands[] = {
{ "whois", 1, irc_cmd_whois, IRC_CMD_LOGGED_IN },
{ "whowas", 1, irc_cmd_whowas, IRC_CMD_LOGGED_IN },
{ "motd", 0, irc_cmd_motd, IRC_CMD_LOGGED_IN },
+ { "mode", 1, irc_cmd_mode, IRC_CMD_LOGGED_IN },
#if 0
{ "oper", 2, irc_cmd_oper, IRC_CMD_LOGGED_IN },
- { "mode", 1, irc_cmd_mode, IRC_CMD_LOGGED_IN },
{ "invite", 2, irc_cmd_invite, IRC_CMD_LOGGED_IN },
{ "privmsg", 1, irc_cmd_privmsg, IRC_CMD_LOGGED_IN },
{ "notice", 1, irc_cmd_privmsg, IRC_CMD_LOGGED_IN },