aboutsummaryrefslogtreecommitdiffstats
path: root/root_commands.c
diff options
context:
space:
mode:
Diffstat (limited to 'root_commands.c')
-rw-r--r--root_commands.c108
1 files changed, 103 insertions, 5 deletions
diff --git a/root_commands.c b/root_commands.c
index 9acc30f0..bc11746f 100644
--- a/root_commands.c
+++ b/root_commands.c
@@ -654,6 +654,23 @@ static void cmd_channel(irc_t *irc, char **cmd)
"channels you're still in cannot be deleted).",
irc->default_channel->name);
}
+ } else if (len >= 1 && g_strncasecmp(cmd[2], "rename", len) == 0) {
+ if (strlen(cmd[3]) < 1) {
+ irc_rootmsg(irc, "You have to specify new name.");
+ } else if (!(ic->flags & IRC_CHANNEL_JOINED) &&
+ ic != ic->irc->default_channel) {
+ if (irc_channel_name_hint(ic, cmd[3])) {
+ irc_rootmsg(irc, "Channel %s renamed to %s.",
+ cmd[1], cmd[3]);
+ } else {
+ irc_rootmsg(irc, "Failed to rename channel %s to %s.",
+ cmd[1], cmd[3]);
+ }
+ } else {
+ irc_rootmsg(irc, "Couldn't rename channel (main channel %s or "
+ "channels you're still in cannot be renamed).",
+ irc->default_channel->name);
+ }
} else {
irc_rootmsg(irc,
"Unknown command: %s [...] %s. Please use \x02help commands\x02 to get a list of available commands.", "channel",
@@ -1217,8 +1234,10 @@ static void cmd_chat(irc_t *irc, char **cmd)
account_t *acc;
if (g_strcasecmp(cmd[1], "add") == 0) {
- char *channel, *s;
+ bee_chat_info_t *ci;
+ char *channel, *room, *s;
struct irc_channel *ic;
+ guint i;
MIN_ARGS(3);
@@ -1230,8 +1249,30 @@ static void cmd_chat(irc_t *irc, char **cmd)
return;
}
+ if (cmd[3][0] == '!') {
+ if (!acc->ic || !(acc->ic->flags & OPT_LOGGED_IN)) {
+ irc_rootmsg(irc, "Not logged in to account.");
+ return;
+ } else if (!acc->prpl->chat_list) {
+ irc_rootmsg(irc, "Listing chatrooms not supported on that account.");
+ return;
+ }
+
+ i = g_ascii_strtoull(cmd[3] + 1, NULL, 10);
+ ci = g_slist_nth_data(acc->ic->chatlist, i - 1);
+
+ if (ci == NULL) {
+ irc_rootmsg(irc, "Invalid chatroom index");
+ return;
+ }
+
+ room = ci->title;
+ } else {
+ room = cmd[3];
+ }
+
if (cmd[4] == NULL) {
- channel = g_strdup(cmd[3]);
+ channel = g_strdup(room);
if ((s = strchr(channel, '@'))) {
*s = 0;
}
@@ -1251,7 +1292,7 @@ static void cmd_chat(irc_t *irc, char **cmd)
set_setstr(&ic->set, "type", "chat") &&
set_setstr(&ic->set, "chat_type", "room") &&
set_setstr(&ic->set, "account", cmd[2]) &&
- set_setstr(&ic->set, "room", cmd[3])) {
+ set_setstr(&ic->set, "room", room)) {
irc_rootmsg(irc, "Chatroom successfully added.");
} else {
if (ic) {
@@ -1261,6 +1302,21 @@ static void cmd_chat(irc_t *irc, char **cmd)
irc_rootmsg(irc, "Could not add chatroom.");
}
g_free(channel);
+ } else if (g_strcasecmp(cmd[1], "list") == 0) {
+ MIN_ARGS(2);
+
+ if (!(acc = account_get(irc->b, cmd[2]))) {
+ irc_rootmsg(irc, "Invalid account");
+ return;
+ } else if (!acc->ic || !(acc->ic->flags & OPT_LOGGED_IN)) {
+ irc_rootmsg(irc, "Not logged in to account.");
+ return;
+ } else if (!acc->prpl->chat_list) {
+ irc_rootmsg(irc, "Listing chatrooms not supported on that account.");
+ return;
+ }
+
+ acc->prpl->chat_list(acc->ic, cmd[3]);
} else if (g_strcasecmp(cmd[1], "with") == 0) {
irc_user_t *iu;
@@ -1275,8 +1331,7 @@ static void cmd_chat(irc_t *irc, char **cmd)
} else {
irc_rootmsg(irc, "Can't open a groupchat with %s.", cmd[2]);
}
- } else if (g_strcasecmp(cmd[1], "list") == 0 ||
- g_strcasecmp(cmd[1], "set") == 0 ||
+ } else if (g_strcasecmp(cmd[1], "set") == 0 ||
g_strcasecmp(cmd[1], "del") == 0) {
irc_rootmsg(irc,
"Warning: The \002chat\002 command was mostly replaced with the \002channel\002 command.");
@@ -1288,6 +1343,39 @@ static void cmd_chat(irc_t *irc, char **cmd)
}
}
+void cmd_chat_list_finish(struct im_connection *ic)
+{
+ account_t *acc = ic->acc;
+ bee_chat_info_t *ci;
+ char *hformat, *iformat, *topic;
+ GSList *l;
+ guint i = 0;
+ irc_t *irc = ic->bee->ui_data;
+
+ if (ic->chatlist == NULL) {
+ irc_rootmsg(irc, "No existing chatrooms");
+ return;
+ }
+
+ if (strchr(irc->umode, 'b') != NULL) {
+ hformat = "%s\t%s\t%s";
+ iformat = "%u\t%s\t%s";
+ } else {
+ hformat = "%s %-20s %s";
+ iformat = "%5u %-20.20s %s";
+ }
+
+ irc_rootmsg(irc, hformat, "Index", "Title", "Topic");
+
+ for (l = ic->chatlist; l; l = l->next) {
+ ci = l->data;
+ topic = ci->topic ? ci->topic : "";
+ irc_rootmsg(irc, iformat, ++i, ci->title, topic);
+ }
+
+ irc_rootmsg(irc, "%u %s chatrooms", i, acc->tag);
+}
+
static void cmd_group(irc_t *irc, char **cmd)
{
GSList *l;
@@ -1400,6 +1488,13 @@ static void cmd_nick(irc_t *irc, char **cmd)
irc_rootmsg(irc, "This command is deprecated. Try: account %s set display_name", cmd[1]);
}
+#ifdef WITH_GNUTLS
+static void cmd_certfp(irc_t *irc, char **cmd)
+{
+ irc_rootmsg(irc, "Show current/set new certfp");
+}
+#endif
+
/* Maybe this should be a stand-alone command as well? */
static void bitlbee_whatsnew(irc_t *irc)
{
@@ -1451,6 +1546,9 @@ command_t root_commands[] = {
{ "set", 0, cmd_set, 0 },
{ "transfer", 0, cmd_transfer, 0 },
{ "yes", 0, cmd_yesno, 0 },
+#ifdef WITH_GNUTLS
+ { "certfp", 1, cmd_certfp, 0 },
+#endif
/* Not expecting too many plugins adding root commands so just make a
dumb array with some empty entried at the end. */
{ NULL },