static int msg_google(const char *replyto, struct userlist *user, char *data) { char *message; char *begin_web = "http://www.google.it/search?hl=it&q="; char *end_web = "&btnG=Cerca&meta="; char *begin_img = "http://images.google.it/images?q="; char *end_img = "&um=1&ie=UTF-8&sa=N&tab=wi"; char *begin_news = "http://news.google.it/news?hl=it&q="; char *end_news = "&um=1&ie=UTF-8&sa=N&tab=in"; int i; if (data == NULL) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "Syntax error: google <text>"); return(0); } message = strtok(data, ""); info_log("Google \"%s\" on %s by %s\n", message, replyto, unick(user)); for (i = 0; i < strlen(message); i++) { if (*(message + i) == ' ') { *(message + i) = '+'; } } send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "Google Web: %s%s%s", begin_web, message, end_web); send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "Google Immagini: %s%s%s", begin_img, message, end_img); send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "Google News: %s%s%s", begin_news, message, end_news); return(0); }
static int msg_youtube(const char *replyto, struct userlist *user, char *data) { char *message; char *begin = "http://www.youtube.com/results?search_query="; char *end = "&search_type=&aq=-1&oq="; int i; if (data == NULL) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "Syntax error: YouTube <text>"); return(0); } message = strtok(data, ""); info_log("YouTube \"%s\" on %s by %s\n", message, replyto, unick(user)); for (i = 0; i < strlen(message); i++) { if (*(message + i) == ' ') { *(message + i) = '+'; } } send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "%s%s%s", begin, message, end); return(0); }
/* static int msg_part(const char *replyto, struct userlist *user, const char *data) { if (data == NULL) { msgreply(user, replyto, "Syntax error: part <channel>"); return(0); } if(ExitChannel(data, user->userinfo->server)==-1) { msgreply(user, replyto, "I can't part a channel that I'm not in"); } else { msgreply(user, replyto, "Parting %s", data); info_log("Parted %s by %s\n", data, user->userinfo->nick); } return (0); } static int msg_ctcp(const char *replyto, struct userlist *user, const char *data) { if (data == NULL) { if (botinfo->ctcp == 1) { msgreply(user, replyto, "CTCP ON"); } else { msgreply(user, replyto, "CTCP OFF"); } return(0); } if (strcaseeq("off", data)) { botinfo->ctcp = 0; msgreply(user, replyto, "CTCP OFF"); return(0); } if (strcaseeq("on", data)) { botinfo->ctcp = 1; msgreply(user, replyto, "CTCP ON"); return(0); } msgreply(user, replyto, "Syntax error: ctcp <on/off>"); return(0); } */ static int msg_part(const char *replyto, struct userlist *user, char *data) { char *channel, *message; if (data == NULL) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "Syntax error: part <channel> [text]"); return(0); } channel = strtok(data, " "); message = strtok(NULL, ""); if (message == NULL) { privmsg(usinfo(user), channel, "Bye!"); } else { privmsg(usinfo(user), channel, "%s", message); } if (ExitChannel(data, user->userinfo->server) == -1) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "I can't part a channel that I'm not in"); } else { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "Parting %s", data); info_log("Parted %s by %s\n", data, user->userinfo->nick); } return(0); }
static int msg_porn(const char *replyto, struct userlist *user, char *data) { char *message; char *begin_yp = "http://www.youporn.com/search?query="; char *end_yp = "&type=straight"; char *begin_rt = "http://www.redtube.com/?search="; char *begin_pt = "http://www.porntube.com/search?q="; char *end_pt = "&Submit=Go"; int i; if (data == NULL) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "Syntax error: P**n <text>"); return(0); } message = strtok(data, ""); info_log("YouPorn \"%s\" on %s by %s\n", message, replyto, unick(user)); info_log("PornTube \"%s\" on %s by %s\n", message, replyto, unick(user)); info_log("RedTube \"%s\" on %s by %s\n", message, replyto, unick(user)); for (i = 0; i < strlen(message); i++) { if (*(message + i) == ' ') { *(message + i) = '+'; } } send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "YouPorn: %s%s%s", begin_yp, message, end_yp); send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "RedTube: %s%s", begin_rt, message); send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "PornTube: %s%s%s", begin_pt, message, end_pt); return(0); }
static int msg_meteo(const char *replyto, struct userlist *user, char *data) { char *message; char *begin_meteo = "http://www.google.it/search?hl=it&q=meteo+"; char *end_meteo = "&btnG=Cerca+con+Google&meta="; int i; if (data == NULL) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "Syntax error: meteo <city>"); return(0); } message = strtok(data, ""); info_log("Meteo \"%s\" on %s by %s\n", message, replyto, unick(user)); for (i = 0; i < strlen(message); i++) { if (*(message + i) == ' ') { *(message + i) = '+'; } } send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "Meteo Web: %s%s%s", begin_meteo, message, end_meteo); return(0); }
void ctcp_reply(struct userlist *user, const char *format, ...) { static char output[1000]; va_list args; va_start(args, format); vsnprintf(output,1000, format, args); va_end(args); send_notice(user->userinfo->server->sinfo, user->userinfo->nick,"%c%s%c",CTCP_DELIM_CHAR, output, CTCP_DELIM_CHAR); }
/* * Notifies lockd specified by name that state has changed for this server. */ void sm_notify_svc(stat_chge *ntfp) { rw_rdlock(&thr_rwlock); if (debug) (void) printf("sm_notify: %s state =%d\n", ntfp->mon_name, ntfp->state); send_notice(ntfp->mon_name, ntfp->state); rw_unlock(&thr_rwlock); }
void send_ctcp(struct socket_info *sinfo, const char *sendto, const char *format, ...) { static char output[1000]; va_list args; va_start(args, format); vsnprintf(output,1000, format, args); va_end(args); send_notice(sinfo, sendto,"%c%s%c",CTCP_DELIM_CHAR, output, CTCP_DELIM_CHAR); }
static int msg_help(const char *replyto, struct userlist *user, const char *UNUSED(data)) { time_t time_cur; struct tm tm_cur; time_cur = time(NULL); tm_cur = *(struct tm *) localtime(&time_cur); if (help_timeout != -1 && tm_cur.tm_min < help_timeout) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "Bot busy...try again in a few seconds...\n"); return(0); } help_timeout = tm_cur.tm_min + 2; info_log("Help by %s\n", unick(user)); msguser(user, " *** Bot help: ***\n"); msguser(user, "!access Show your access level\n"); msguser(user, "!action <text> Action message\n"); msguser(user, "!botuptime Show bot's uptime\n"); msguser(user, "!sysuptime Show system's uptime\n"); msguser(user, "!time Show bot's time machine\n"); msguser(user, "!hu [nick] Hu message\n"); msguser(user, "!freshair [nick] Freshair message\n"); msguser(user, "!freshhu [nick] Freshhu message\n"); msguser(user, "!say [nick] <text> Say text to nick (Nick is not required)\n"); msguser(user, "!peluche [nick] Don't ask...for peluche\n"); msguser(user, "!google <key> Search on Google Web, Image and News\n"); msguser(user, "!youtube <key> Search on YouTube\n"); msguser(user, "!meteo <city> Search city's meteo\n"); msguser(user, "!ansa <key | list> Search key from www.ansa.it or print list possible key\n"); msguser(user, "!p**n <key> Self-Explicative VM.18\n"); msguser(user, "!utf8 Show how to change charset to utf-8 in X-Chat\n"); msguser(user, "!version Show bot's version\n"); msguser(user, "!help This help\n"); msguser(user, " *** Admin only commands: ***\n"); msguser(user, "!ctcp <on | off> CTCP message mode\n"); msguser(user, "!identify [password] Identify you in\n"); msguser(user, "!join <channel> [key] Join other channel (key if required)\n"); msguser(user, "!kick <nick> [message] Kick nickname\n"); msguser(user, "!nick <nick> Change nickname\n"); msguser(user, "!part <channel> [text] Exit from channel\n"); msguser(user, "!raw <command> Parse your commands\n"); msguser(user, "!reload Reload Log and User file\n"); msguser(user, "!shutdown Shutdown the bot\n"); return(0); }
static int msg_ctcp(const char *replyto, struct userlist *user, const char *data) { if (data == NULL) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "Syntax error: ctcp <on/off>"); return(0); } if (strcaseeq("off", data)) { botinfo->ctcp = 0; send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "CTCP OFF"); return(0); } else if (strcaseeq("on", data)) { botinfo->ctcp = 1; send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "CTCP ON"); return(0); } send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "Syntax error: ctcp <on/off>"); return(0); }
static int msg_raw(const char *replyto, struct userlist *user, const char *data) { if (data == NULL) { msgreply(user, replyto, "Syntax error: raw <command>"); return(0); } if (strcaseeq(data, "QUIT")) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "Error: use shutdown instead"); return (0); } info_log("RAW: %s by %s\n", data, unick(user)); msguser(user, "Sending raw message> %s", data); irc_sprintf(usinfo(user),"%s\n", data); return(0); }
//mela version static int msg_action(const char *replyto, struct userlist *user, char *data) { char *message; if (data == NULL) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "Syntax error: action <text>"); return(0); } message = strtok(data, ""); info_log("Action %s on %s by %s\n", message, replyto, unick(user)); irc_sprintf(usinfo(user), "PRIVMSG %s :%cACTION %s%c\n", replyto, CTCP_DELIM_CHAR, message, CTCP_DELIM_CHAR); return(0); }
void ProcOnWho(BN_PInfo I, const char Channel[], const char *Info[], const int Count) { int i; IRCChannel_t *channel; IRCServer_t *server; char *nick; server = (IRCServer_t *)I->User; channel = FindChannel(server, Channel); if( !channel ) { LogPrint( LOG_NOTICE, "Channel %s on %s not found in ProcOnWho!", Channel, server->server ); return; } if( verbose ) { LogPrint( LOG_DEBUG, "Who infos for channel (%s)", Channel); } db_nick_history( channel, "", HIST_START ); for (i = 0; i < (Count * WHO_INFO_COUNT); i += WHO_INFO_COUNT) { if( verbose ) { LogPrint( LOG_DEBUG, "\t%s,%s,%s,%s,%s,%s", Info[i + 0], Info[i + 1], Info[i + 2], Info[i + 3], Info[i + 4], Info[i + 5]); } nick = (char *)Info[i + 0]; db_update_nick( channel, nick, true, false ); db_nick_history( channel, nick, HIST_INITIAL ); if( strcmp( channel->url, "" ) && db_check_nick_notify( channel, nick, channel->notifywindow ) ) { send_notice( channel, nick ); } } if( verbose ) { LogPrint( LOG_DEBUG, "End of Who for (%s)", Channel); } }
void ProcOnJoin(BN_PInfo I, const char Chan[], const char Who[]) { char *string; IRCChannel_t *channel; char nick[256]; string = (char *)malloc(MAX_STRING_LENGTH); BN_ExtractNick(Who, nick, 256); sprintf(string, "%s (%s) has joined %s\n", nick, Who, Chan); channel = FindChannel((IRCServer_t *)I->User, Chan); db_add_logentry( channel, nick, TYPE_JOIN, string, false ); db_update_nick( channel, nick, true, false ); db_nick_history( channel, nick, HIST_JOIN ); if( strcmp( channel->url, "" ) && db_check_nick_notify( channel, nick, channel->notifywindow ) ) { send_notice( channel, nick ); } free( string ); }
static int msg_kick(const char *replyto, struct userlist *user, char *data) { char *nick, *message; if (data == NULL) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "Syntax error: kick <nick> [message]"); return(0); } nick = strtok(data, " "); message = strtok(NULL, ""); info_log("KICK to %s on %s\n", nick, replyto); if (message == NULL) { irc_sprintf(usinfo(user),"KICK %s %s :Addio!\n", replyto, nick); } else { irc_sprintf(usinfo(user),"KICK %s %s :%s\n", replyto, nick, message); } return(0); }
int input_login(DESC_DATA *d, const char *data, int plen) { const int PACKET_LENGTH = 4; if (plen < PACKET_LENGTH) return 0; DWORD account_id = decode_4bytes((const BYTE*)data); // sys_log("LOGIN: %u", account_id); /* 기존 정보가 있으면 접속을 끊으라고 알려줌 */ CONN_DATA *conn = conn_find(account_id); if (conn) { send_force_logout(conn); //conn_delete(GET_ID(conn)); // 새로운 접속자도 접속을 끊는다. { PACKET_DATA *buf = &d->packet_buffer; packet_header(buf, HEADER_TG_FORCE_LOGOUT, d->desc_num); packet(buf, GET_LOGIN(conn), MAX_LOGIN_LEN); } return PACKET_LENGTH; } conn = (CONN_DATA*) calloc(1, sizeof(CONN_DATA)); GET_ID(conn) = account_id; GET_DESC(conn) = d; GET_EVENT(conn) = NULL; int login_succ = FALSE; if (teen_all_flag) login_succ = account_login_teen_all(account_id, conn); else login_succ = account_login(account_id, conn); if (FALSE==login_succ) { //conn_delete(GET_ID(conn)); SAFE_FREE(conn); return PACKET_LENGTH; } conn_insert(conn); if (YES==GET_TEENAGE(conn)) { conn_event_info *info = (conn_event_info*) calloc(1, sizeof(conn_event_info)); info->conn = conn; GET_EVENT(conn) = event_create(conn_event_func, info, (CHECK_TIME_SEC * PASSES_PER_SEC)); } else { GET_EVENT(conn) = NULL; } if (YES==GET_TEENAGE(conn)) { send_login_notice(conn); set_notice_step(conn); send_notice(conn); } sys_log("CONN_INSERT : %u, %s", GET_ID(conn), GET_LOGIN(conn)); return PACKET_LENGTH; } /* end of input_login() */
static int msg_ansa(const char *replyto, struct userlist *user, char *data) { char *message; if (data == NULL) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "Syntax error: ansa <key | list>"); return(0); } message = strtok(data, ""); info_log("Ansa \"%s\" on %s by %s\n", message, replyto, unick(user)); /* List possible key */ if (strcaseeq("list", message)) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "Ansa key"); send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "General: top, english, italia, mondo, sport, calcio, economia, cultura, scienza, internet, spettacolo, moda, musica, cinema."); send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "Regions: abruzzo, basilicata, calabria, campania, emilia romagna, friuli venezia giulia, lazio, liguria, lombardia, marche, molise, piemonte, puglia, sardegna, sicilia, toscana, trentino alto adige, umbria, valle d'aosta, veneto.\n"); /* General */ } else if (strcaseeq("top", message)) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "http://www.ansa.it/site/notizie/awnplus/topnews/topnews.html"); } else if (strcaseeq("english", message)) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "http://www.ansa.it/site/notizie/awnplus/english/english.html"); } else if (strcaseeq("italia", message)) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "http://www.ansa.it/site/notizie/awnplus/italia/italia.html"); } else if (strcaseeq("mondo", message)) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "http://www.ansa.it/site/notizie/awnplus/mondo/mondo.html"); } else if (strcaseeq("sport", message)) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "http://www.ansa.it/site/notizie/awnplus/sport/sport.html"); } else if (strcaseeq("calcio", message)) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "http://www.ansa.it/site/notizie/awnplus/calcio/calcio.html"); } else if (strcaseeq("economia", message)) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "http://www.ansa.it/site/notizie/awnplus/economia/economia.html"); } else if (strcaseeq("cultura", message)) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "http://www.ansa.it/site/notizie/awnplus/cultura/cultura.html"); } else if (strcaseeq("scienza", message)) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "http://www.ansa.it/site/notizie/awnplus/scienza/scienza.html"); } else if (strcaseeq("internet", message)) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "http://www.ansa.it/site/notizie/awnplus/internet/internet.html"); } else if (strcaseeq("spettacolo", message)) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "http://www.ansa.it/site/notizie/awnplus/spettacolo/spettacolo.html"); } else if (strcaseeq("moda", message)) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "http://www.ansa.it/site/notizie/awnplus/moda/moda.html"); } else if (strcaseeq("musica", message)) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "http://www.ansa.it/site/notizie/awnplus/musica/musica.html"); } else if (strcaseeq("cinema", message)) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "http://www.ansa.it/site/notizie/awnplus/cinema/cinema.html"); /* Regions */ } else if (strcaseeq("abruzzo", message)) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "http://www.ansa.it/site/notizie/regioni/abruzzo/abruzzo.html"); } else if (strcaseeq("basilicata", message)) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "http://www.ansa.it/site/notizie/regioni/basilicata/basilicata.html"); } else if (strcaseeq("calabria", message)) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "http://www.ansa.it/site/notizie/regioni/calabria/calabria.html"); } else if (strcaseeq("campania", message)) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "http://www.ansa.it/site/notizie/regioni/campania/campania.html"); } else if (strcaseeq("emilia romagna", message)) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "http://www.ansa.it/site/notizie/regioni/emiliaromagna/emiliaromagna.html"); } else if (strcaseeq("friuli venezia giulia", message)) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "http://www.ansa.it/site/notizie/regioni/friulivgiulia/friulivgiulia.html"); } else if (strcaseeq("lazio", message)) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "http://www.ansa.it/site/notizie/regioni/lazio/lazio.html"); } else if (strcaseeq("liguria", message)) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "http://www.ansa.it/site/notizie/regioni/liguria/liguria.html"); } else if (strcaseeq("lombardia", message)) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "http://www.ansa.it/site/notizie/regioni/lombardia/lombardia.html"); } else if (strcaseeq("marche", message)) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "http://www.ansa.it/site/notizie/regioni/marche/marche.html"); } else if (strcaseeq("molise", message)) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "http://www.ansa.it/site/notizie/regioni/molise/molise.html"); } else if (strcaseeq("piemonte", message)) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "http://www.ansa.it/site/notizie/regioni/piemonte/piemonte.html"); } else if (strcaseeq("puglia", message)) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "http://www.ansa.it/site/notizie/regioni/puglia/puglia.html"); } else if (strcaseeq("sardegna", message)) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "http://www.ansa.it/site/notizie/regioni/sardegna/sardegna.html"); } else if (strcaseeq("sicilia", message)) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "http://www.ansa.it/site/notizie/regioni/sicilia/sicilia.html"); } else if (strcaseeq("toscana", message)) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "http://www.ansa.it/site/notizie/regioni/toscana/toscana.html"); } else if (strcaseeq("trentino alto adige", message)) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "http://www.ansa.it/site/notizie/regioni/trentino/trentino.html"); } else if (strcaseeq("umbria", message)) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "http://www.ansa.it/site/notizie/regioni/umbria/umbria.html"); } else if (strcaseeq("valle d'aosta", message) || strcaseeq("valle d`aosta", message)) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "http://www.ansa.it/site/notizie/regioni/valledaosta/valledaosta.html"); } else if (strcaseeq("veneto", message)) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "http://www.ansa.it/site/notizie/regioni/veneto/veneto.html"); } else { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "Key not found, use ansa list"); } return(0); }
/* void delusrcommand(void *module, const char *command) { usercommandlist=delcommand(module, usercommandlist, command); } void delusrcommandmodule(void *module) { usercommandlist=delcommandmodule(module, usercommandlist); } */ int access_too_low(struct userlist *user, const char *replyto) { send_notice(user->userinfo->server->sinfo, user->userinfo->nick, "Your access is too low to use this command."); return(0); }