Changeset 7a9d968 for root_commands.c


Ignore:
Timestamp:
2018-03-10T11:30:39Z (6 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Children:
5447c59
Parents:
3f44e43 (diff), 4a9c6b0 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into HEAD

File:
1 edited

Legend:

Unmodified
Added
Removed
  • root_commands.c

    r3f44e43 r7a9d968  
    10721072                format = "%s\t%s\t%s";
    10731073        } else {
    1074                 format = "%-16.16s  %-40.40s  %s";
     1074                format = "%-24.24s  %-40.40s  %s";
    10751075        }
    10761076
     
    11721172}
    11731173
     1174static void cmd_plugins_info(irc_t *irc, char **cmd)
     1175{
     1176        GList *l;
     1177        struct plugin_info *info;
     1178
     1179        MIN_ARGS(2);
     1180
     1181        for (l = get_plugins(); l; l = l->next) {
     1182                info = l->data;
     1183                if (g_strcasecmp(cmd[2], info->name) == 0) {
     1184                        break;
     1185                }
     1186        }
     1187
     1188        if (!l) {
     1189                return;
     1190        }
     1191
     1192        irc_rootmsg(irc, "%s:", info->name);
     1193        irc_rootmsg(irc, "  Version: %s", info->version);
     1194
     1195        if (info->description) {
     1196                irc_rootmsg(irc, "  Description: %s", info->description);
     1197        }
     1198
     1199        if (info->author) {
     1200                irc_rootmsg(irc, "  Author: %s", info->author);
     1201        }
     1202
     1203        if (info->url) {
     1204                irc_rootmsg(irc, "  URL: %s", info->url);
     1205        }
     1206}
     1207
    11741208static void cmd_plugins(irc_t *irc, char **cmd)
    11751209{
    11761210        GList *prpls;
    11771211        GString *gstr;
     1212
     1213        if (cmd[1] && g_strcasecmp(cmd[1], "info") == 0) {
     1214                cmd_plugins_info(irc, cmd);
     1215                return;
     1216        }
    11781217
    11791218#ifdef WITH_PLUGINS
    11801219        GList *l;
    11811220        struct plugin_info *info;
     1221        char *format;
     1222
     1223        if (strchr(irc->umode, 'b') != NULL) {
     1224                format = "%s\t%s";
     1225        } else {
     1226                format = "%-30s  %s";
     1227        }
     1228
     1229        irc_rootmsg(irc, format, "Plugin", "Version");
    11821230
    11831231        for (l = get_plugins(); l; l = l->next) {
     1232                char *c;
    11841233                info = l->data;
    1185                 irc_rootmsg(irc, "%s:", info->name);
    1186                 irc_rootmsg(irc, "  Version: %s", info->version);
    1187 
    1188                 if (info->description) {
    1189                         irc_rootmsg(irc, "  Description: %s", info->description);
    1190                 }
    1191 
    1192                 if (info->author) {
    1193                         irc_rootmsg(irc, "  Author: %s", info->author);
    1194                 }
    1195 
    1196                 if (info->url) {
    1197                         irc_rootmsg(irc, "  URL: %s", info->url);
    1198                 }
    1199 
    1200                 irc_rootmsg(irc, "");
     1234
     1235                /* some purple plugins like to include several versions separated by newlines... */
     1236                if ((c = strchr(info->version, '\n'))) {
     1237                        char *version = g_strndup(info->version, c - info->version);
     1238                        irc_rootmsg(irc, format, info->name, version);
     1239                        g_free(version);
     1240                } else {
     1241                        irc_rootmsg(irc, format, info->name, info->version);
     1242                }
    12011243        }
    12021244#endif
     1245
     1246        irc_rootmsg(irc, "");
    12031247
    12041248        gstr = g_string_new(NULL);
     
    13461390        } else if (g_strcasecmp(cmd[1], "set") == 0 ||
    13471391                   g_strcasecmp(cmd[1], "del") == 0) {
    1348                 irc_rootmsg(irc,
    1349                             "Warning: The \002chat\002 command was mostly replaced with the \002channel\002 command.");
    1350                 cmd_channel(irc, cmd);
     1392                irc_rootmsg(irc, "Unknown command: chat %s. Did you mean \002channel %s\002?", cmd[1], cmd[1]);
    13511393        } else {
    13521394                irc_rootmsg(irc,
     
    14061448                topic = ci->topic ? ci->topic : "";
    14071449
    1408                 padded = str_pad_and_truncate(ci->title, title_len, "[...]");
     1450                padded = str_pad_and_truncate(ci->title ? ci->title : "", title_len, "[...]");
    14091451                irc_rootmsg(irc, iformat, ++i, padded, topic);
    14101452                g_free(padded);
Note: See TracChangeset for help on using the changeset viewer.