Changeset a33ee0f for root_commands.c
- Timestamp:
- 2016-09-20T03:39:05Z (8 years ago)
- Branches:
- master
- Children:
- 725f942
- Parents:
- 67ea361
- git-author:
- jgeboski <jgeboski@…> (22-06-16 18:54:52)
- git-committer:
- jgeboski <jgeboski@…> (20-09-16 03:39:05)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
root_commands.c
r67ea361 ra33ee0f 1218 1218 1219 1219 if (g_strcasecmp(cmd[1], "add") == 0) { 1220 char *channel, *s; 1220 bee_chat_info_t *ci; 1221 char *channel, *room, *s; 1221 1222 struct irc_channel *ic; 1223 guint i; 1222 1224 1223 1225 MIN_ARGS(3); … … 1231 1233 } 1232 1234 1235 if (cmd[3][0] == '!') { 1236 if (!acc->prpl->chat_list) { 1237 irc_rootmsg(irc, "Listing chatrooms not supported on that account."); 1238 return; 1239 } 1240 1241 i = g_ascii_strtoull(cmd[3] + 1, NULL, 10); 1242 ci = g_slist_nth_data(acc->ic->chatlist, i - 1); 1243 1244 if (ci == NULL) { 1245 irc_rootmsg(irc, "Invalid chatroom index"); 1246 return; 1247 } 1248 1249 room = ci->title; 1250 } else { 1251 room = cmd[3]; 1252 } 1253 1233 1254 if (cmd[4] == NULL) { 1234 channel = g_strdup( cmd[3]);1255 channel = g_strdup(room); 1235 1256 if ((s = strchr(channel, '@'))) { 1236 1257 *s = 0; … … 1252 1273 set_setstr(&ic->set, "chat_type", "room") && 1253 1274 set_setstr(&ic->set, "account", cmd[2]) && 1254 set_setstr(&ic->set, "room", cmd[3])) {1275 set_setstr(&ic->set, "room", room)) { 1255 1276 irc_rootmsg(irc, "Chatroom successfully added."); 1256 1277 } else { … … 1262 1283 } 1263 1284 g_free(channel); 1285 } else if (g_strcasecmp(cmd[1], "list") == 0) { 1286 MIN_ARGS(2); 1287 1288 if (!(acc = account_get(irc->b, cmd[2]))) { 1289 irc_rootmsg(irc, "Invalid account"); 1290 return; 1291 } else if (!acc->prpl->chat_list) { 1292 irc_rootmsg(irc, "Listing chatrooms not supported on that account."); 1293 return; 1294 } 1295 1296 acc->prpl->chat_list(acc->ic, cmd[3]); 1264 1297 } else if (g_strcasecmp(cmd[1], "with") == 0) { 1265 1298 irc_user_t *iu; … … 1276 1309 irc_rootmsg(irc, "Can't open a groupchat with %s.", cmd[2]); 1277 1310 } 1278 } else if (g_strcasecmp(cmd[1], "list") == 0 || 1279 g_strcasecmp(cmd[1], "set") == 0 || 1311 } else if (g_strcasecmp(cmd[1], "set") == 0 || 1280 1312 g_strcasecmp(cmd[1], "del") == 0) { 1281 1313 irc_rootmsg(irc, … … 1287 1319 cmd[1]); 1288 1320 } 1321 } 1322 1323 void cmd_chat_list_finish(struct im_connection *ic) 1324 { 1325 account_t *acc = ic->acc; 1326 bee_chat_info_t *ci; 1327 char *hformat, *iformat, *topic; 1328 GSList *l; 1329 guint i = 0; 1330 irc_t *irc = ic->bee->ui_data; 1331 1332 if (ic->chatlist == NULL) { 1333 irc_rootmsg(irc, "No existing chatrooms"); 1334 return; 1335 } 1336 1337 if (strchr(irc->umode, 'b') != NULL) { 1338 hformat = "%s\t%s\t%s"; 1339 iformat = "%u\t%s\t%s"; 1340 } else { 1341 hformat = "%s %-20s %s"; 1342 iformat = "%5u %-20.20s %s"; 1343 } 1344 1345 irc_rootmsg(irc, hformat, "Index", "Title", "Topic"); 1346 1347 for (l = ic->chatlist; l; l = l->next) { 1348 ci = l->data; 1349 topic = ci->topic ? ci->topic : ""; 1350 irc_rootmsg(irc, iformat, ++i, ci->title, topic); 1351 } 1352 1353 irc_rootmsg(irc, "%u %s chatrooms", i, acc->tag); 1289 1354 } 1290 1355
Note: See TracChangeset
for help on using the changeset viewer.