Changeset b9e020a
- Timestamp:
- 2010-03-27T03:04:35Z (15 years ago)
- Branches:
- master
- Children:
- 63a520b
- Parents:
- 4be8239
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
irc.h
r4be8239 rb9e020a 142 142 /* irc_channel.c */ 143 143 irc_channel_t *irc_channel_new( irc_t *irc, const char *name ); 144 irc_channel_t *irc_channel_by_name( irc_t *irc, const char *name ); 144 145 int irc_channel_add_user( irc_channel_t *ic, irc_user_t *iu ); 145 146 int irc_channel_del_user( irc_channel_t *ic, irc_user_t *iu ); -
irc_channel.c
r4be8239 rb9e020a 45 45 } 46 46 47 irc_channel_t *irc_channel_by_name( irc_t *irc, const char *name ) 48 { 49 GSList *l; 50 51 for( l = irc->channels; l; l = l->next ) 52 { 53 irc_channel_t *ic = l->data; 54 55 if( name[0] == ic->name[0] && nick_cmp( name + 1, ic->name + 1 ) == 0 ) 56 return ic; 57 } 58 59 return NULL; 60 } 61 47 62 int irc_channel_add_user( irc_channel_t *ic, irc_user_t *iu ) 48 63 { -
irc_commands.c
r4be8239 rb9e020a 108 108 } 109 109 110 static void irc_cmd_join( irc_t *irc, char **cmd ) 111 { 112 irc_channel_t *ic; 113 114 if( ( ic = irc_channel_by_name( irc, cmd[1] ) ) == NULL ) 115 ic = irc_channel_new( irc, cmd[1] ); 116 117 if( ic == NULL ) 118 irc_send_num( irc, 479, "%s :Invalid channel name", cmd[1] ); 119 120 if( ic->flags & IRC_CHANNEL_JOINED ) 121 return; /* Dude, you're already there... 122 RFC doesn't have any reply for that though? */ 123 124 irc_channel_add_user( ic, irc->user ); 125 } 126 127 static void irc_cmd_names( irc_t *irc, char **cmd ) 128 { 129 irc_channel_t *ic; 130 131 if( cmd[1] && ( ic = irc_channel_by_name( irc, cmd[1] ) ) ) 132 irc_send_names( ic ); 133 /* With no args, we should show /names of all chans. Make the code 134 below work well if necessary. 135 else 136 { 137 GSList *l; 138 139 for( l = irc->channels; l; l = l->next ) 140 irc_send_names( l->data ); 141 } 142 */ 143 } 144 145 static void irc_cmd_part( irc_t *irc, char **cmd ) 146 { 147 irc_channel_t *ic; 148 149 if( ( ic = irc_channel_by_name( irc, cmd[1] ) ) == NULL ) 150 { 151 irc_send_num( irc, 403, "%s :No such channel", cmd[1] ); 152 } 153 else if( !irc_channel_del_user( ic, irc->user ) ) 154 { 155 irc_send_num( irc, 442, "%s :You're not on that channel", cmd[1] ); 156 } 157 } 158 110 159 #if 0 160 //#if 0 111 161 static void irc_cmd_oper( irc_t *irc, char **cmd ) 112 162 { … … 150 200 else 151 201 irc_send_num( irc, 502, ":Don't touch their modes" ); 152 }153 }154 155 static void irc_cmd_names( irc_t *irc, char **cmd )156 {157 irc_names( irc, cmd[1]?cmd[1]:irc->channel );158 }159 160 static void irc_cmd_part( irc_t *irc, char **cmd )161 {162 struct groupchat *c;163 164 if( g_strcasecmp( cmd[1], irc->channel ) == 0 )165 {166 user_t *u = user_find( irc, irc->nick );167 168 /* Not allowed to leave control channel */169 irc_part( irc, u, irc->channel );170 irc_join( irc, u, irc->channel );171 }172 else if( ( c = irc_chat_by_channel( irc, cmd[1] ) ) )173 {174 user_t *u = user_find( irc, irc->nick );175 176 irc_part( irc, u, c->channel );177 178 if( c->ic )179 {180 c->joined = 0;181 c->ic->acc->prpl->chat_leave( c );182 }183 }184 else185 {186 irc_send_num( irc, 403, "%s :No such channel", cmd[1] );187 }188 }189 190 static void irc_cmd_join( irc_t *irc, char **cmd )191 {192 if( g_strcasecmp( cmd[1], irc->channel ) == 0 )193 ; /* Dude, you're already there...194 RFC doesn't have any reply for that though? */195 else if( cmd[1] )196 {197 struct chat *c;198 199 if( strchr( CTYPES, cmd[1][0] ) == NULL || cmd[1][1] == 0 )200 irc_send_num( irc, 479, "%s :Invalid channel name", cmd[1] );201 else if( ( c = chat_bychannel( irc, cmd[1] ) ) && c->acc && c->acc->ic )202 chat_join( irc, c, cmd[2] );203 else204 irc_send_num( irc, 403, "%s :No such channel", cmd[1] );205 202 } 206 203 } … … 583 580 { "quit", 0, irc_cmd_quit, 0 }, 584 581 { "ping", 0, irc_cmd_ping, 0 }, 582 { "join", 1, irc_cmd_join, IRC_CMD_LOGGED_IN }, 583 { "names", 1, irc_cmd_names, IRC_CMD_LOGGED_IN }, 584 { "part", 1, irc_cmd_part, IRC_CMD_LOGGED_IN }, 585 585 #if 0 586 586 { "oper", 2, irc_cmd_oper, IRC_CMD_LOGGED_IN }, 587 587 { "mode", 1, irc_cmd_mode, IRC_CMD_LOGGED_IN }, 588 { "names", 0, irc_cmd_names, IRC_CMD_LOGGED_IN },589 { "part", 1, irc_cmd_part, IRC_CMD_LOGGED_IN },590 { "join", 1, irc_cmd_join, IRC_CMD_LOGGED_IN },591 588 { "invite", 2, irc_cmd_invite, IRC_CMD_LOGGED_IN }, 592 589 { "privmsg", 1, irc_cmd_privmsg, IRC_CMD_LOGGED_IN },
Note: See TracChangeset
for help on using the changeset viewer.