now = time(NULL); if (!CHECKAUTH(in->sender, UL_OP) && lastcall > now - 10) { irc_privmsg(to_sender(in), "Please wait a moment"); return 0; } if (!in->tail || !in->tail[0]) return 0; p = config_get("weather.so", "url"); if (!p || (i = strlen(p)) >= sizeof(buf)) return 0; strcpy(buf, p); if (http_escape_str(in->tail, buf + i, sizeof(buf) -i)) return 0; req = http_new(http_cb); if (!req) return 0; http_setptr(req, strdup(to_sender(in))); http_get(req, buf); lastcall = now; } } return 0; } /* TODO: Free all pending requests when unloading module */ PLUGIN_DEF(NULL, NULL, reply, NULL, NULL, PLUGIN_NODEP, PLUGIN_HELP("!weather <region> - Weather forecast"))
} } else { max_delay = MAX_DELAY_DEF; printc("No maximum delay. Use default %lu\n", MAX_DELAY_DEF); } if (max_delay < min_delay) max_delay = min_delay; nexttalk = time(NULL) + min_delay + rrand(max_delay - min_delay); p = config_get("fortune.so", "reqdelay"); if (p) { req_delay = strtoul (p, NULL, 10); if (req_delay == ULONG_MAX && errno == ERANGE) { req_delay = REQ_DELAY_DEF; printc("Illegal request delay. Use default %lu\n", REQ_DELAY_DEF); } } else { req_delay = REQ_DELAY_DEF; printc("No request delay. Use default %lu\n", REQ_DELAY_DEF); } lasttime = 0; return 0; } PLUGIN_DEF(init, NULL, reply, timer, NULL, PLUGIN_NODEP, PLUGIN_HELP("!fortune - behold the eternal wisdom"))
* Boston, MA 02110-1301, USA * */ #include <stdlib.h> #include "irc.h" #include "util.h" int reply(info_t * in) { char *p; int i; if (in->cmd == cmd_privmsg && !tail_cmd(&in->tail,"fut")) { i = config_getcnt("fut.so", "insult"); p = tail_getp(&in->tail); if(p) { irc_privmsg(to_sender(in), "%s: %s", p, i?config_getn("fut.so", "insult", rrand(i)):"Fut"); } else { irc_privmsg(to_sender(in), "%s", i?config_getn("fut.so", "insult", rrand(i)):"Fut"); } } return 0; } PLUGIN_DEF(NULL, NULL, reply, NULL, NULL, PLUGIN_NODEP, PLUGIN_HELP("Tell the people what you think of them."))