/* 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); }
//mela actions :) static int msg_peluche(const char *replyto, struct userlist *user, char *data) { char *message, *msg; int i; if (data != NULL) { message = strtok(data, ""); if (*(message + strlen(message) - 1) == ' ') *(message + strlen(message) - 1) = '\0'; msg = malloc(sizeof(char) * strlen(data) + 1); for (i = 0; i < strlen(data); i++) *(msg + i) = '='; *(msg + strlen(data)) = '\0'; info_log("Peluche %s on %s by %s\n", message, replyto, unick(user)); privmsg(usinfo(user), replyto, "%s: 8%sD", message, msg); free(msg); } else { info_log("Peluche on %s by %s\n", replyto, unick(user)); privmsg(usinfo(user), replyto, "8=============D"); } return (0); }
static int msg_kick(const char *replyto, struct userlist *user, char *data) { char *channel, *nick, *message ; struct userlist *target; int user_access; /* syntax: kick <channel> <nick> */ channel = strtok(data, " "); nick = strtok(NULL, " "); message = strtok(NULL, ""); if (channel == NULL || nick == NULL) { msgreply(user, replyto, "Syntax error: kick <channel> <nickname>"); return (0); } if (strcaseeq(nick, user->userinfo->server->nick)) { info_log("%s tried to make me kick myself\n", unick(user)); irc_sprintf(usinfo(user), "KICK %s %s :Try to make me kick myself eh?\n", channel, unick(user)); return (0); } user_access = GetChannelAccess(user, channel); if (user_access < 0) return (access_too_low(user, replyto)); target = GetFromChannel(nick, channel, user->userinfo->server); if (target == NULL) msgreply(user, replyto, "I don't see that user in the channel"); if ((target->access >= 0) && (user_access > target->access)) { privmsg(usinfo(user), unick(target), "%s tried to kick you!", unick(user) ); privmsg(usinfo(user), replyto, "attempt to kick user with higher access denied"); return (0); } info_log("KICK %s %s\n", channel, unick(target)); msgreply(user, replyto, "Kicking %s on %s", nick, channel); if (message == NULL) { irc_sprintf(usinfo(user), "KICK %s %s\n", channel, nick); return (0); } else { irc_sprintf(usinfo(user), "KICK %s %s :%s\n", channel, nick, message); return (0); } }
static int ctcp_CHAT(char *nick, char *uhost, struct userrec *u, char *object, char *keyword, char *text) { if (!ischanhub()) return BIND_RET_LOG; if (u_pass_match(u, "-")) { strlcat(ctcp_reply, "\001ERROR no password set\001", sizeof(ctcp_reply)); return BIND_RET_BREAK; } int ix = -1, i = 0; for (i = 0; i < dcc_total; i++) { if (dcc[i].type && (dcc[i].type->flags & DCT_LISTEN) && (!strcmp(dcc[i].nick, "(telnet)"))) ix = i; } if (!iptolong(getmyip())) { simple_snprintf(&ctcp_reply[strlen(ctcp_reply)], sizeof(ctcp_reply) - strlen(ctcp_reply), "\001ERROR no ipv4 ip defined. Use /dcc chat %s\001", botname); } else if (dcc_total == max_dcc || (ix < 0 && (ix = listen_all(0, 0, 0)) < 0)) strlcat(ctcp_reply, "\001ERROR no telnet port\001", sizeof(ctcp_reply)); else { if (listen_time <= 2) listen_time++; /* do me a favour and don't change this back to a CTCP reply, * CTCP replies are NOTICE's this has to be a PRIVMSG * -poptix 5/1/1997 */ bd::String msg; msg = bd::String::printf("\001DCC CHAT chat %lu %u\001", iptolong(getmyip()), dcc[ix].port); privmsg(nick, msg.c_str(), DP_SERVER); } return BIND_RET_BREAK; }
void executeCommand(enum Commands command, User *bot, ...) { va_list a_list; va_start(a_list, bot); char *sender, *cmdStr; char **parameters; switch (command) { case PONG: pong(bot); break; case PRIVMSG: sender = va_arg(a_list, char *); cmdStr = va_arg(a_list, char *); parameters = va_arg(a_list, char **); if (strcmp("speak", cmdStr) == 0 && strcmp("Anthony`", sender) == 0) privmsg(bot, sender, parameters[0]); else if (strcmp("rolldice", cmdStr) == 0) rolldice(bot, sender, atoi(parameters[0])); else if (strcmp("die", cmdStr) == 0 && strcmp("Anthony`", sender) == 0) killBot(bot); else if (strcmp("coolmeter", cmdStr) == 0) coolmeter(bot, sender, parameters[0]); else if (strcmp("fight", cmdStr) == 0) fight(bot, sender, parameters[0], parameters[1]); else if (strcmp("getlatestpost", cmdStr) == 0) getLatestRlPost(bot, sender); break; } va_end(a_list); }
void alog(const char *fmt, ...) { va_list args; char *buf; int errno_save = errno; char str[BUFSIZE]; checkday(); if (!fmt) { return; } va_start(args, fmt); vsnprintf(str, sizeof(str), fmt, args); va_end(args); buf = log_gettimestamp(); if (logfile) { fprintf(logfile, "%s %s\n", buf, str); } if (nofork) { fprintf(stderr, "%s %s\n", buf, str); } if (LogChannel && logchan && !debug && findchan(LogChannel)) { privmsg(s_GlobalNoticer, LogChannel, "%s", str); } errno = errno_save; }
static int msg_authstart(char *nick, char *host, struct userrec *u, char *par) { if (!u) return 0; if (match_my_nick(nick)) return BIND_RET_BREAK; if (u && u->bot) return BIND_RET_BREAK; if (!ischanhub()) { putlog(LOG_WARN, "*", STR("(%s!%s) !%s! Attempted AUTH? (I'm not a chathub (+c))"), nick, host, u->handle); return BIND_RET_BREAK; } putlog(LOG_CMDS, "*", STR("(%s!%s) !%s! AUTH?"), nick, host, u->handle); Auth *auth = Auth::Find(host); if (auth) { if (auth->Authed()) { notice(nick, "You are already authed.", DP_HELP); return 0; } } else auth = new Auth(nick, host, u); /* Send "auth." if they are recognized, otherwise "auth!" */ auth->Status(AUTH_PASS); bd::String msg; msg = bd::String::printf(STR("auth%s %s"), u ? "." : "!", conf.bot->nick); privmsg(nick, msg.c_str(), DP_HELP); return BIND_RET_BREAK; }
static void say_my_name(void) { static const char trigger = '.'; static const char *const hello_cmd = "hello"; const char *target = NULL; /* +1 to remove the : */ char *tofree, *message; tofree = message = xstrdup(bot.msg->params+1); /* Wasn't a PM to us nor was it an in channel trigger */ if (message[0] == trigger && !bot.msg->target_is_channel) { xfree(message); return; } /* Get the first word from the message */ char *command = fox_strsep(&message, " "); /* Command prefix was used */ if (bot.msg->target_is_channel) { memmove(command, command+1, strlen(command)); target = bot.msg->target; } else { target = bot.msg->from->nick; } if (strcmp(command, hello_cmd) == 0) { privmsg(target, "Hi %s! My name is %s!", bot.msg->from->nick, bot.user->nick); } xfree(tofree); }
static void parsein(char *s) { char c, *p; if(s[0] == '\0') return; skip(s, '\n'); if(s[0] != ':') { privmsg(channel, s); return; } c = *++s; if(c != '\0' && isspace(s[1])) { p = s + 2; switch(c) { case 'j': sout("JOIN %s", p); if(channel[0] == '\0') strlcpy(channel, p, sizeof channel); return; case 'l': s = eat(p, isspace, 1); p = eat(s, isspace, 0); if(!*s) s = channel; if(*p) *p++ = '\0'; if(!*p) p = "sic - 250 LOC are too much!"; sout("PART %s :%s", s, p); return; case 'm': s = eat(p, isspace, 1); p = eat(s, isspace, 0); if(*p) *p++ = '\0'; privmsg(s, p); return; case 's': strlcpy(channel, p, sizeof channel); return; } } sout("%s", s); }
int pub_proc(char *which, char *str, char **unused) { char *loc, *nick, *chan, *cmd, *serv; unsigned short port = 0; if(qbx_on == 0) return 1; loc = LOCAL_COPY(str); nick = next_arg(loc, &loc); chan = next_arg(loc, &loc); cmd = next_arg(loc, &loc); if(cmd && *cmd != '!') return 1; if(my_stricmp(cmd, Q3A_COMMAND) && my_stricmp(cmd, Q2_COMMAND) && my_stricmp(cmd, QW_COMMAND)) return 1; serv = next_arg(loc, &loc); if(serv == NULL) { privmsg(chan, "%s: Give me a server to query", nick); return 1; } if(querying == 1) { privmsg(chan, "%s: A query is already in progress", nick); return 1; } if(strchr(serv, ':')) { serv = strtok(serv, ":"); port = atoi(strtok(NULL, "")); } else port = 0; strncpy(q_chan, chan, 256); if(!my_stricmp(cmd, Q3A_COMMAND)) { /* quake3 server (my fav =) */ if(port == 0) port = Q3A_GAME_PORT; query_q_server(serv, port, 3); return 1; } else if(!my_stricmp(cmd, Q2_COMMAND)) { /* quake2 server */ if(port == 0) port = Q2_GAME_PORT; query_q_server(serv, port, 2); return 1; } else if(!my_stricmp(cmd, QW_COMMAND)) { /* quakeworld server */ if(port == 0) port = QW_GAME_PORT; query_q_server(serv, port, 1); return 1; } return 1; }
void irc::identify() { std::string identify; if (_nspass == "" || _nickserv == "") return; identify = "IDENTIFY " + _nspass; privmsg(_nickserv, identify); }
static int msg_bewm(char *nick, char *host, struct userrec *u, char *par) { struct chanset_t *chan = NULL; if (!homechan[0] || !(chan = findchan_by_dname(homechan))) return BIND_RET_BREAK; if (!channel_active(chan)) return BIND_RET_BREAK; if (match_my_nick(nick)) return BIND_RET_BREAK; bd::String msg; if (!u) { msg = bd::String::printf(STR("---- (%s!%s) attempted to gain secure invite, but is not a recognized user."), nick, host); privmsg(chan->name, msg.c_str(), DP_SERVER); putlog(LOG_CMDS, "*", STR("(%s!%s) !*! BEWM"), nick, host); return BIND_RET_BREAK; } if (u->bot) return BIND_RET_BREAK; struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0 }; get_user_flagrec(u, &fr, chan->dname, chan); if (!chk_op(fr, chan)) { putlog(LOG_CMDS, "*", STR("(%s!%s) !%s! !BEWM"), nick, host, u->handle); msg = bd::String::printf(STR("---- %s (%s!%s) attempted to gain secure invite, but is missing a flag."), u->handle, nick, host); privmsg(chan->name, msg.c_str(), DP_SERVER); return BIND_RET_BREAK; } msg = bd::String::printf("\001ACTION has invited \002%s\002 (%s!%s) to %s.\001", u->handle, nick, host, chan->dname); privmsg(chan->name, msg.c_str(), DP_SERVER); cache_invite(chan, nick, host, u->handle, 0, 0); putlog(LOG_CMDS, "*", STR("(%s!%s) !%s! BEWM"), nick, host, u->handle); return BIND_RET_BREAK; }
void send_action(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); privmsg(sinfo, sendto,"%cACTION %s%c",CTCP_DELIM_CHAR, output, CTCP_DELIM_CHAR); }
void do_geoip(User *u) /*la colocamos en extern.h y asi la llamamos desde oper*/ { char *cmd; cmd = strtok(NULL, " "); if ((!cmd) || ((!stricmp(cmd, "ON") == 0) && (!stricmp(cmd, "OFF") == 0)&& (!stricmp(cmd, "STATUS") == 0))) { notice_lang(s_GeoIP, u, GEOIP_HELP); return; } if ((stricmp(cmd, "ON") == 0)) { if (!is_services_oper(u)) { notice_lang(s_GeoIP, u, PERMISSION_DENIED); return; } autogeoip=1; canaladmins(s_GeoIP, "2ACTIVADO por 12%s",u->nick); privmsg(s_GeoIP, u->nick, "Servicio GeoIP 2ACTIVADO"); } if ((stricmp(cmd, "OFF") == 0)) { if (!is_services_oper(u)) { notice_lang(s_GeoIP, u, PERMISSION_DENIED); return; } autogeoip=0; canaladmins(s_GeoIP, "4DESACTIVADO por 12%s",u->nick); privmsg(s_GeoIP, u->nick, "Servicio GeoIP 5DESACTIVADO"); } if ((stricmp(cmd, "STATUS") == 0)) { if (!is_services_oper(u)) { notice_lang(s_GeoIP, u, PERMISSION_DENIED); return; } if (autogeoip) privmsg(s_GeoIP, u->nick, "Estado Servicio GeoIP 2ACTIVADO"); else privmsg(s_GeoIP, u->nick, "Estado Servicio GeoIP 5DESACTIVADO"); } }
void alog(int type, const char *fmt, ...) { va_list args; int errno_save = errno; char str[BUFSIZE]; char *buf; *str = '\0'; if (!fmt) { return; } if ((type == LOG_DEBUG || type == LOG_EXTRADEBUG || type == LOG_NONEXISTANT) && !denora->debug) { return; } if ((type == LOG_PROTOCOL) && !denora->protocoldebug) { return; } if (type == LOG_SQLDEBUG && !denora->sqldebug) { return; } if (LOG_EXTRADEBUG == type && denora->debug <= 1) { return; } if ((type == LOG_DEBUGSOCK || type == LOG_ADNS) && !denora->socketdebug) { return; } checkday(); va_start(args, fmt); ircvsnprintf(str, sizeof(str), fmt, args); va_end(args); buf = log_gettimestamp(); if (!NoLogs && logfile) { fprintf(logfile, "%s %s\n", buf, str); } if (denora->nofork) { fprintf(stderr, "%s %s\n", buf, str); } if (!BadPtr(LogChannel) && denora->debug < 2 && findchan(LogChannel)) { if (type == LOG_NORMAL || type == LOG_NONEXISTANT || type == LOG_ERROR) { privmsg(s_StatServ, LogChannel, "%s", str); } } errno = errno_save; }
static int msg_freshhu(const char *replyto, struct userlist *user, char *data) { char *message; if (data == NULL) { privmsg(usinfo(user), replyto, "PRHUUUUUUUUUUUUUU"); return(0); } message = strtok(data, ""); info_log("Freshhing %s on %s by %s\n", message, replyto, unick(user)); if (message[strlen(message) - 1] == ' ') message[strlen(message) - 1] = '\0'; privmsg(usinfo(user), replyto, "%s: PRHUUUUUUUUUUUUUU", message); return(0); }
void Client::on_privmsg(session_t &session) { if (session.params[0] == config.irc_nick_name) { Splitter params(session.trailing, " "); if (params.size() == 0) { return; } std::string command = boost::to_upper_copy(params[0]); if (command == "ENTER") { if (params.size() != 4) { privmsg(session.prefix, "ENTER #channel(,#channel2,#channel3) nick irckey"); return; } Splitter channels(params[1], ","); std::cout << "enter channels " << channels.size() << std::endl; } } }
/* static int msg_say(const char *replyto, struct userlist *user, char *data) { char *channel, *message; if (data == NULL) { msgreply(user, replyto, "Syntax error: say <channel> <text>"); return(0); } channel = strtok(data, " "); message = strtok(NULL, ""); if (channel == NULL || message == NULL) { msgreply(user, replyto, "Syntax error: say <channel> <text>"); return(0); } if (GetChannelAccess(user, channel) < 0) { return (access_too_low(user, replyto)); } info_log("Say %s on %s by %s\n", message, channel, unick(user)); msguser(user, "Saying message on %s", channel); privmsg(usinfo(user),channel, "%s", message); return(0); } */ static int msg_say(const char *replyto, struct userlist *user, char *data) { char *message; if (data == NULL) { return(0); } message = strtok(data, ""); info_log("Say %s on %s by %s\n", message, replyto, unick(user)); privmsg(usinfo(user), replyto, "%s", message); return(0); }
static int msg_auth(char *nick, char *host, struct userrec *u, char *par) { char *pass = NULL; if (match_my_nick(nick)) return BIND_RET_BREAK; if (u && u->bot) return BIND_RET_BREAK; Auth *auth = Auth::Find(host); if (!auth || auth->Status() != AUTH_PASS) return BIND_RET_BREAK; pass = newsplit(&par); if (u_pass_match(u, pass) && !u_pass_match(u, "-")) { auth->user = u; if (strlen(auth_key) && get_user(&USERENTRY_SECPASS, u)) { putlog(LOG_CMDS, "*", STR("(%s!%s) !%s! AUTH"), nick, host, u->handle); auth->Status(AUTH_HASH); auth->MakeHash(); bd::String msg; msg = bd::String::printf(STR("-Auth %s %s"), auth->rand, conf.bot->nick); privmsg(nick, msg.c_str(), DP_HELP); } else { /* no auth_key and/or no SECPASS for the user, don't require a hash auth */ AuthFinish(auth); } } else { putlog(LOG_CMDS, "*", STR("(%s!%s) !%s! failed AUTH"), nick, host, u->handle); delete auth; } return BIND_RET_BREAK; }
void *handle_privmsg_queue(void *ptr) { static time_t last_message_times[HISTORY_SIZE] = { 0 }; while(1) { if (msg_count > 0) pthread_mutex_lock(&global_msglist_mutex); while(msg_count == 0) pthread_cond_wait(&condition, &global_msglist_mutex); time_t time_now = 0; time_t avarage_timestamp = 0; for (int i = 0; i < HISTORY_SIZE; i++) avarage_timestamp += last_message_times[i]; avarage_timestamp /= HISTORY_SIZE; struct timeval tv; gettimeofday(&tv, NULL); time_now = (tv.tv_sec) * 1000 + (tv.tv_usec) / 1000; if (time_now - avarage_timestamp <= 300000) //TODO: Do this better { if (!msg_list[0]->drop) { bcirc_printf("Will sleep\n"); usleep(12500); privmsg(msg_list[0]->msg, msg_list[0]->target, msg_list[0]->srv); } else bcirc_printf("Dropped message \"%s\" to target %s\n", msg_list[0]->msg, msg_list[0]->target); } else privmsg(msg_list[0]->msg, msg_list[0]->target, msg_list[0]->srv); msg_count--; free(msg_list[0]->msg); free(msg_list[0]->target); free(msg_list[0]); for (int i = 0; i < msg_count; i++) msg_list[i] = msg_list[i+1]; msg_info **new_msg_list = malloc(msg_count * sizeof(msg_info)); for (int i = 0; i < msg_count; i++) new_msg_list[i] = msg_list[i]; free(msg_list); msg_list = new_msg_list; pthread_mutex_unlock(&global_msglist_mutex); for (int i = HISTORY_SIZE; i > 0; i--) last_message_times[i] = last_message_times[i-1]; gettimeofday(&tv, NULL); last_message_times[0] = (tv.tv_sec) * 1000 + (tv.tv_usec) / 1000; } bcirc_printf("privmsg handler loop stopped.. this should not happen..\n"); exit(EXIT_FAILURE); }
void check_clients(pool *pool) { int i, receiveByteNum; char buf[MAXLINE]; rio_t rio; for(i = 0; (i <= pool->maxi) && (pool->nready > 0); i++) { int conn_fd = pool->clientfd[i]; /* Check if it is ready */ if((conn_fd > 0) && (FD_ISSET(conn_fd, &pool->ready_set))) { pool->nready--; rio = pool->clientrio[i]; if((receiveByteNum = Rio_readlineb(&rio, buf, MAXLINE)) != 0) { byte_cnt += receiveByteNum; printf("Server received %d (%d total) bytes on fd %d\n", receiveByteNum, byte_cnt, conn_fd); Rio_writen(conn_fd, buf, receiveByteNum); char msg[MAX_MSG_LEN]; size_t message_len; if((message_len = get_msg(buf, msg)) < 0) app_error("message too long"); printf("The command you input is: %s\n", msg); char tokens[MAX_MSG_TOKENS][MAX_MSG_LEN+1]; int token_len = tokenize(msg, tokens); int command_type = get_command(tokens, token_len); switch(command_type) { case 1: if(token_len == 2) { nick(conn_fd, tokens[1]); } else { sprintf(buf, "The command should be like: NICK <nickname>.\n"); Write(conn_fd, buf, strlen(buf)); } break; case 2: if(token_len == 4) { user(conn_fd, tokens[1], tokens[2], tokens[3]); } else { sprintf(buf, "ERR_NEEDMOREPARAMS. The command should be like: USER <username> <hostname> <servername> <realname>.\n"); Write(conn_fd, buf, strlen(buf)); } break; case 3: quit(conn_fd); break; case 4: if(token_len == 2) { join(conn_fd, tokens[1]); } else { sprintf(buf, "ERR_NEEDMOREPARAMS. The command should be like: JOIN <channelname>.\n"); Write(conn_fd, buf, strlen(buf)); } break; case 5: if(token_len == 2) { part(conn_fd, tokens[1]); } else { sprintf(buf, "ERR_NEEDMOREPARAMS. The command should be like: PART <channelname>.\n"); Write(conn_fd, buf, strlen(buf)); } break; case 6: list(conn_fd); break; case 7: if(token_len == 3) { privmsg(conn_fd, tokens[1], tokens[2]); } else { sprintf(buf, "ERR_NEEDMOREPARAMS. The command should be like: PRIVMSG <nickname/channelname>.\n"); Write(conn_fd, buf, strlen(buf)); } break; case 8: if(token_len == 2) { who(conn_fd, tokens[1]); } else { sprintf(buf, "ERR_NEEDMOREPARAMS. The command should be like: WHO <nickname/channelname>.\n"); Write(conn_fd, buf, strlen(buf)); } break; default: sprintf(buf, "The command you input %s is not understandable!\n", msg); Write(conn_fd, buf, strlen(buf)); break; } } /* EOF detected, remove descriptor from pool */ else { Close(conn_fd); FD_CLR(conn_fd, &pool->read_set); pool->clientfd[i] = -1; pool->clients[conn_fd].conn_fd = -1; } } } }
static int msg_deop(const char *replyto, struct userlist *user, char *data) { const char *channel, *nick, *snick, *tnick; struct socket_info *sinfo ; struct userlist *target; int user_access; channel = NULL; nick = NULL; if (data != NULL) { /* syntax: deop <channel> <nick> */ channel = strtok(data, " "); nick = strtok(NULL, ""); } if (channel == NULL) { if (replyto[0] == '#') { channel = replyto; } else { msgreply(user, replyto, "Syntax error: deop <channel> <nick>"); return (0); } } user_access = GetChannelAccess(user, channel); if (user_access < 0) { return (access_too_low(user, replyto)); } sinfo = usinfo(user) ; if (nick == NULL) { irc_sprintf(sinfo, "MODE %s -o %s\n", channel, unick(user)); return(0) ; } target = GetFromChannel(nick, channel, user->userinfo->server); tnick = unick(target) ; snick = unick(user) ; if (target == NULL) { msgreply(user, replyto, "I don't see that user in the channel"); return (0); } if ((target->access >= 0) && (user_access > target->access)) { privmsg(sinfo, tnick, "%s tried to deop you!", snick); msgreply(user, replyto, "attempt to deop user with higher access denied"); return (0); } info_log("Deop %s on %s\n", snick, channel); msgreply(user, replyto, "Deopping %s on %s", tnick, channel); irc_sprintf(sinfo, "MODE %s -o %s\n", channel, tnick); return (0); }
void q_timer(int fd) { int i = 0, j = 0, k = 0, type = q_type; int nextpart = 0, num_players = 0, cheats = 0; struct quake_variable variable[50]; struct timeval tv; char status[65507], temp[1024]; char server_hostname[1024], server_maxclients[1024], server_mapname[1024]; char server_fraglimit[1024], server_timelimit[1024], server_game[1024]; /* ick. */ memset(&temp, 0, sizeof(temp)); memset(&server_hostname, 0, sizeof(server_hostname)); memset(&server_maxclients, 0, sizeof(server_maxclients)); memset(&server_mapname, 0, sizeof(server_mapname)); memset(&server_fraglimit, 0, sizeof(server_fraglimit)); memset(&server_timelimit, 0, sizeof(server_timelimit)); memset(&server_game, 0, sizeof(server_game)); /* now we should be expecting something back */ memset(&status, 0, sizeof(status)); if(recv(fd, status, 65507, 0) < 0) { put_it("Error receiving from %s: %s", q_server, strerror(errno)); privmsg(q_chan, "Error receiving from %s: %s", q_server, strerror(errno)); close_socketread(fd); querying = 0; return; } gettimeofday(&tv, NULL); close_socketread(fd); memset(&variable, 0, sizeof(variable)); /* now we have our info, but we still need to decode it! */ if(type == 1) i = 7; else if(type == 2) i = 11; else if(type == 3) i = 20; /* the following while loop copies all the variables from the status message into an array together with their value */ while (status[i] != '\n') { /* check whether it's time for a new variable */ if (status[i] == '\\') { if (nextpart) { nextpart = 0; variable[j].value[k] = '\0'; j++; } else { nextpart = 1; variable[j].name[k] = '\0'; } k = 0; } else { /* put our character in the correct position */ if (nextpart) variable[j].value[k] = status[i]; else variable[j].name[k] = status[i]; k++; } i++; } variable[j].value[k] = '\0'; /* now we can count how many players there are on the server */ i++; put_it(&status[i]); while (i < strlen(status)) { if (status[i] == '\n') { num_players++; } i++; } for (i = 0; i < 50; i++) { if(type != 3) { if(!strcmp("hostname", variable[i].name)) strcpy(server_hostname, variable[i].value); if(!strcmp("maxclients", variable[i].name)) strcpy(server_maxclients, variable[i].value); } else { if(!strcmp("sv_hostname", variable[i].name)) strcpy(server_hostname, variable[i].value); if(!strcmp("sv_maxclients", variable[i].name)) strcpy(server_maxclients, variable[i].value); if(!strcmp("g_gametype", variable[i].name)) { switch(atoi(variable[i].name)) { case 0: strcpy(server_game, "FFA"); break; case 1: strcpy(server_game, "DUEL"); break; case 3: strcpy(server_game, "TEAM DM"); break; case 4: strcpy(server_game, "CTF"); break; default: strcpy(server_game, "UNKNOWN"); break; } } } if(type == 1) { if(!strcmp("map", variable[i].name)) strcpy(server_mapname, variable[i].value); if(!strcmp("*gamedir", variable[i].name)) strcpy(server_game, variable[i].value); if(!strcmp("cheats", variable[i].name)) cheats = 1; } else { if(!strcmp("mapname", variable[i].name)) strcpy(server_mapname, variable[i].value); } if(type == 2) { if(!strcmp("gamename", variable[i].name)) strcpy(server_game, variable[i].value); } if(!strcmp("timelimit", variable[i].name)) strcpy(server_timelimit, variable[i].value); if(!strcmp("fraglimit", variable[i].name)) strcpy(server_fraglimit, variable[i].value); } if(type == 1) { snprintf(temp, 1024, "%s : players: %d/%s, ping: %d, map: %s, timelimit: %s, fraglimit: %s", server_hostname, num_players, server_maxclients, time_delta(&tv, &q_tv), server_mapname, server_timelimit, server_fraglimit); if(server_game[0] != '\0') { char temp2[1024]; snprintf(temp2, 1024, ", game: %s", server_game); strcat(temp, temp2); } if(cheats) strcat(temp, ", cheats enabled"); } if(type == 2) snprintf(temp, 1024, "%s : players: %d/%s, ping: %d, map: %s, timelimit: %s, fraglimit: %s, game: %s", server_hostname, num_players, server_maxclients, time_delta(&tv, &q_tv), server_mapname, server_timelimit, server_fraglimit, server_game); if(type == 3) snprintf(temp, 1024, "%s : players: %d/%s, ping: %d, map: %s, gametype: %s, timelimit: %s, fraglimit: %s", server_hostname, num_players, server_maxclients, time_delta(&tv, &q_tv), server_mapname, server_game, server_timelimit, server_fraglimit); put_it(temp); privmsg(q_chan, temp); querying = 0; }
void q_timeout(int fd) { put_it("No response from %s", q_server); privmsg(q_chan, "No response from %s", q_server); close_socketread(qfd); querying = 0; }
static int msg_op(char *nick, char *host, struct userrec *u, char *par) { struct chanset_t *chan = NULL; char *pass = NULL; struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0 }; if (match_my_nick(nick)) return BIND_RET_BREAK; pass = newsplit(&par); bd::String msg; if (homechan[0]) { struct chanset_t *hchan = NULL; hchan = findchan_by_dname(homechan); if (hchan && channel_active(hchan) && !ismember(hchan, nick)) { putlog(LOG_CMDS, "*", "(%s!%s) !*! failed OP %s (not in %s)", nick, host, par, homechan); if (par[0]) msg = bd::String::printf("---- (%s!%s) attempted to OP for %s but is not currently in %s.", nick, host, par, homechan); else msg = bd::String::printf("---- (%s!%s) attempted to OP but is not currently in %s.", nick, host, homechan); privmsg(homechan, msg.c_str(), DP_SERVER); return BIND_RET_BREAK; } } if (u_pass_match(u, pass)) { if (!u_pass_match(u, "-")) { if (par[0]) { chan = findchan_by_dname(par); if (chan && channel_active(chan)) { get_user_flagrec(u, &fr, par, chan); if (chk_op(fr, chan)) { if (do_op(nick, chan, 0, 1)) { stats_add(u, 0, 1); putlog(LOG_CMDS, "*", "(%s!%s) !%s! OP %s", nick, host, u->handle, par); if (manop_warn && chan->manop) { msg = bd::String::printf("%s is currently set to punish for manual op.", chan->dname); notice(nick, msg.c_str(), DP_HELP); } } } return BIND_RET_BREAK; } } else { int stats = 0; for (chan = chanset; chan; chan = chan->next) { get_user_flagrec(u, &fr, chan->dname, chan); if (chk_op(fr, chan)) { if (do_op(nick, chan, 0, 1)) { stats++; if (manop_warn && chan->manop) { msg = bd::String::printf("%s is currently set to punish for manual op.", chan->dname); notice(nick, msg.c_str(), DP_HELP); } } } } putlog(LOG_CMDS, "*", "(%s!%s) !%s! OP", nick, host, u->handle); if (stats) stats_add(u, 0, 1); return BIND_RET_BREAK; } } } putlog(LOG_CMDS, "*", "(%s!%s) !*! failed OP", nick, host); return BIND_RET_BREAK; }