00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 static void cmd_servers(struct userrec *u, int idx, char *par)
00027 {
00028 struct server_list *x = serverlist;
00029 int i;
00030 char s[1024];
00031
00032 putlog(LOG_CMDS, "*", "#%s# servers", dcc[idx].nick);
00033 if (!x) {
00034 dprintf(idx, "There are no servers in the server list.\n");
00035 } else {
00036 dprintf(idx, "Server list:\n");
00037 i = 0;
00038 for (; x; x = x->next) {
00039 if ((i == curserv) && realservername)
00040 egg_snprintf(s, sizeof s, " %s:%d (%s) <- I am here", x->name,
00041 x->port ? x->port : default_port, realservername);
00042 else
00043 egg_snprintf(s, sizeof s, " %s:%d %s", x->name,
00044 x->port ? x->port : default_port,
00045 (i == curserv) ? "<- I am here" : "");
00046 dprintf(idx, "%s\n", s);
00047 i++;
00048 }
00049 dprintf(idx, "End of server list.\n");
00050 }
00051 }
00052
00053 static void cmd_dump(struct userrec *u, int idx, char *par)
00054 {
00055 if (!(isowner(dcc[idx].nick)) && (must_be_owner == 2)) {
00056 dprintf(idx, MISC_NOSUCHCMD);
00057 return;
00058 }
00059 if (!par[0]) {
00060 dprintf(idx, "Usage: dump <server stuff>\n");
00061 return;
00062 }
00063 putlog(LOG_CMDS, "*", "#%s# dump %s", dcc[idx].nick, par);
00064 dprintf(DP_SERVER, "%s\n", par);
00065 }
00066
00067 static void cmd_jump(struct userrec *u, int idx, char *par)
00068 {
00069 char *other;
00070 int port;
00071
00072 if (par[0]) {
00073 other = newsplit(&par);
00074 port = atoi(newsplit(&par));
00075 if (!port)
00076 port = default_port;
00077 putlog(LOG_CMDS, "*", "#%s# jump %s %d %s", dcc[idx].nick, other,
00078 port, par);
00079 strncpyz(newserver, other, sizeof newserver);
00080 newserverport = port;
00081 strncpyz(newserverpass, par, sizeof newserverpass);
00082 } else
00083 putlog(LOG_CMDS, "*", "#%s# jump", dcc[idx].nick);
00084 dprintf(idx, "%s...\n", IRC_JUMP);
00085 cycle_time = 0;
00086 nuke_server("changing servers");
00087 }
00088
00089 static void cmd_clearqueue(struct userrec *u, int idx, char *par)
00090 {
00091 int msgs;
00092
00093 if (!par[0]) {
00094 dprintf(idx, "Usage: clearqueue <mode|server|help|all>\n");
00095 return;
00096 }
00097 if (!egg_strcasecmp(par, "all")) {
00098 msgs = modeq.tot + mq.tot + hq.tot;
00099 msgq_clear(&modeq);
00100 msgq_clear(&mq);
00101 msgq_clear(&hq);
00102 double_warned = burst = 0;
00103 dprintf(idx, "Removed %d message%s from all queues.\n", msgs,
00104 (msgs != 1) ? "s" : "");
00105 } else if (!egg_strcasecmp(par, "mode")) {
00106 msgs = modeq.tot;
00107 msgq_clear(&modeq);
00108 if (mq.tot == 0)
00109 burst = 0;
00110 double_warned = 0;
00111 dprintf(idx, "Removed %d message%s from the mode queue.\n", msgs,
00112 (msgs != 1) ? "s" : "");
00113 } else if (!egg_strcasecmp(par, "help")) {
00114 msgs = hq.tot;
00115 msgq_clear(&hq);
00116 double_warned = 0;
00117 dprintf(idx, "Removed %d message%s from the help queue.\n", msgs,
00118 (msgs != 1) ? "s" : "");
00119 } else if (!egg_strcasecmp(par, "server")) {
00120 msgs = mq.tot;
00121 msgq_clear(&mq);
00122 if (modeq.tot == 0)
00123 burst = 0;
00124 double_warned = 0;
00125 dprintf(idx, "Removed %d message%s from the server queue.\n", msgs,
00126 (msgs != 1) ? "s" : "");
00127 } else {
00128 dprintf(idx, "Usage: clearqueue <mode|server|help|all>\n");
00129 return;
00130 }
00131 putlog(LOG_CMDS, "*", "#%s# clearqueue %s", dcc[idx].nick, par);
00132 }
00133
00134 static cmd_t C_dcc_serv[] = {
00135 {"dump", "m", (IntFunc) cmd_dump, NULL},
00136 {"jump", "m", (IntFunc) cmd_jump, NULL},
00137 {"servers", "o", (IntFunc) cmd_servers, NULL},
00138 {"clearqueue", "m", (IntFunc) cmd_clearqueue, NULL},
00139 {NULL, NULL, NULL, NULL}
00140 };