/** * Called when user does /ns qlist **/ int mQList(User * u) { NickCore *nc = NULL; int count = 0; char *data; int i; for (i = 0; i < 1024; i++) { for (nc = nclists[i]; nc; nc = nc->next) { /* If we have any info on this user */ if ((data = moduleGetData(&nc->moduleData, "qdbban"))) { if (count == 0) { notice_user(s_NickServ, u, "Users who are banned from submitting to the QDB:"); } notice_user(s_NickServ, u, nc->display); count++; free(data); } } } if (count == 0) { notice_user(s_NickServ, u, "No users are banned from submitting to the QDB"); } return MOD_CONT; }
void send_bot_channels(User * u, BotInfo * bi) { int i; ChannelInfo *ci; char buf[307], *end; *buf = 0; end = buf; for (i = 0; i < 256; i++) { for (ci = chanlists[i]; ci; ci = ci->next) { if (ci->bi == bi) { if (strlen(buf) + strlen(ci->name) > 300) { notice_user(s_BotServ, u, buf); *buf = 0; end = buf; } end += snprintf(end, sizeof(buf) - (end - buf), " %s ", ci->name); } } } if (*buf) notice_user(s_BotServ, u, buf); return; }
int cs_help_saregister(User *u) { notice_user(s_NickServ, u, "Syntax: \2SAREGISTER \37nick\37 \37password\37 \37email\37"); notice_user(s_NickServ, u, " "); notice_user(s_NickServ, u, "Allows services admins to register other nicks"); return MOD_STOP; }
static int do_matchwild(User * u) { char *pat = strtok(NULL, " "); char *str = strtok(NULL, " "); if (pat && str) notice_user(s_OperServ, u, "%d", match_wild(pat, str)); else notice_user(s_OperServ, u, "Syntax error."); return MOD_CONT; }
int os_help_root(User *u) { if (is_superadmin(u)) { notice_user(s_OperServ, u, "Syntax: \2ROOT (ADD|DEL|LIST) [\037nick\037]\2"); notice_user(s_OperServ, u, " "); notice_user(s_OperServ, u, "This command allows superadmins to modify who has services root access to Services."); notice_user(s_OperServ, u, "The access granted or denied with this command is only temporary, you need to modify"); notice_user(s_OperServ, u, "the ServicesRoot directive in the configuration for this to be permanemnt."); } return MOD_CONT; }
/** * Called after an svsadmin does a /ns info nick * @param u The user who requested info * @return MOD_CONT to continue processing commands or MOD_STOP to stop **/ int myNickInfo(User * u) { char *text; char *nick; char *data; NickCore *nc; NickAlias *na; if (is_services_oper(u)) { text = moduleGetLastBuffer(); if (text) { nick = myStrGetToken(text, ' ', 0); if (nick) { if ((na = findnick(nick))) { nc = na->nc; if ((data = moduleGetData(&nc->moduleData, "qdbban"))) { notice_user(s_NickServ, u, "%s is banned from submitting to the QDB", na->nick); } if (data) free(data); } free(nick); } } } return MOD_CONT; }
void os_help(User *u) { if (is_superadmin(u)) { notice_user(s_OperServ, u, " ROOT Control the services root list"); } }
/** * The /ns help command. * @param u The user who issued the command * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing. **/ int do_help(User * u) { char *cmd = strtok(NULL, ""); if (!cmd) { notice_help(s_NickServ, u, NICK_HELP); moduleDisplayHelp(1, u); if (is_services_admin(u)) { notice_help(s_NickServ, u, NICK_SERVADMIN_HELP); } if (NSExpire >= 86400) notice_help(s_NickServ, u, NICK_HELP_EXPIRES, NSExpire / 86400); notice_help(s_NickServ, u, NICK_HELP_FOOTER); } else if (stricmp(cmd, "SET LANGUAGE") == 0) { int i; notice_help(s_NickServ, u, NICK_HELP_SET_LANGUAGE); for (i = 0; i < NUM_LANGS && langlist[i] >= 0; i++) notice_user(s_NickServ, u, " %2d) %s", i + 1, langnames[langlist[i]]); } else { mod_help_cmd(s_NickServ, u, NICKSERV, cmd); } return MOD_CONT; }
/** * The /bs botlist command. * @param u The user who issued the command * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing. **/ int do_botlist(User * u) { int i, count = 0; BotInfo *bi; if (!nbots) { notice_lang(s_BotServ, u, BOT_BOTLIST_EMPTY); return MOD_CONT; } for (i = 0; i < 256; i++) { for (bi = botlists[i]; bi; bi = bi->next) { if (!(bi->flags & BI_PRIVATE)) { if (!count) notice_lang(s_BotServ, u, BOT_BOTLIST_HEADER); count++; notice_user(s_BotServ, u, " %-15s (%s@%s)", bi->nick, bi->user, bi->host); } } } if (is_oper(u) && count < nbots) { notice_lang(s_BotServ, u, BOT_BOTLIST_PRIVATE_HEADER); for (i = 0; i < 256; i++) { for (bi = botlists[i]; bi; bi = bi->next) { if (bi->flags & BI_PRIVATE) { notice_user(s_BotServ, u, " %-15s (%s@%s)", bi->nick, bi->user, bi->host); count++; } } } } if (!count) notice_lang(s_BotServ, u, BOT_BOTLIST_EMPTY); else notice_lang(s_BotServ, u, BOT_BOTLIST_FOOTER, count); return MOD_CONT; }
string remote_tell(string cname, string from, string mud, string to, string msg, int wiz_level) { object ob; string fromid; string no_tell; string can_tell; // mapping conn; //string reject; string tell_out; if (ob = MESSAGE_D->find_user(to)) { if (ob->query("env/invisible")) return "这个人现在不在线上。"; fromid = lower_case(from + "@" + mud); no_tell = ob->query("env/no_tell"); if ((! intp(wiz_level) || wiz_level < 3) && (no_tell == "all" || no_tell == "ALL" || is_sub(fromid, no_tell))) { can_tell = ob->query("env/can_tell"); if (! is_sub(fromid, can_tell)) return "这个人不想听你罗嗦啦。"; } fromid = capitalize(from) + "@" + upper_case(mud); msg = replace_string(msg, "\n", ""); if (cname) tell_out = sprintf(HIG "%s(%s)告诉你:%s\n" NOR, cname, fromid, msg); else { cname = "未知"; tell_out = sprintf(HIG "%s 告诉你:%s\n" NOR, fromid, msg); } to = capitalize(to); if (! notice_user(cname, fromid, ob, tell_out)) msg = sprintf(HIG "你的话没有送到%s(%s@%s)的耳边。\n" NOR, ob->name(1), to, upper_case(INTERMUD_MUD_NAME)); else msg = sprintf(HIG "你告诉%s(%s@%s):%s" NOR, ob->name(1), to, upper_case(INTERMUD_MUD_NAME), msg); return msg; } else return "这个人现在不在线上。"; }
/* shows the Services ignore list */ static int do_ignorelist(User * u, ChannelInfo *ci) { IgnoreData *id; if (!ignore) { notice_lang(ci->bi->nick, u, OPER_IGNORE_LIST_EMPTY); return MOD_CONT; } notice_lang(ci->bi->nick, u, OPER_IGNORE_LIST); for (id = ignore; id; id = id->next) notice_user(ci->bi->nick, u, "%s", id->mask); return MOD_CONT; }
int do_saregister(User *u) { char *buf, *nick, *pass, *email; NickRequest *nr; NickAlias *na; User *user; buf = moduleGetLastBuffer(); nick = myStrGetToken(buf, ' ', 0); pass = myStrGetToken(buf, ' ', 1); email = myStrGetToken(buf, ' ', 2); if (!email) { notice_user(s_NickServ, u, "Syntax: \2SAREGISTER \37nick\37 \37password\37 \37email\37"); notice_lang(s_NickServ, u, MORE_INFO, s_NickServ, "SAREGISTER"); } else if (readonly) { notice_lang(s_NickServ, u, NICK_REGISTRATION_DISABLED); } else if ((nr = findrequestnick(nick))) { notice_lang(s_NickServ, u, NICK_REQUESTED); } else if (!anope_valid_nick(nick)) { notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, nick); } else if ((na = findnick(nick))) { if (na->status & NS_VERBOTEN) notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED, nick); else notice_lang(s_NickServ, u, NICK_ALREADY_REGISTERED, nick); } else if (!MailValidate(email)) { notice_lang(s_NickServ, u, MAIL_X_INVALID, email); } else { na = makenick(nick); if (!na) { alog("%s: makenick(%s) failed", s_NickServ, u->nick); notice_lang(s_NickServ, u, NICK_REGISTRATION_FAILED); } else { user = finduser(nick); enc_encrypt(pass, strlen(pass), na->nc->pass, PASSMAX - 1); na->nc->flags |= NSDefFlags; na->nc->memos.memomax = MSMaxMemos; if (user) na->last_usermask = user->vhost ? sstrdup(user->vhost) : sstrdup(user->host); else na->last_usermask = sstrdup("*@*"); if (user) na->last_realname = sstrdup(user->realname); else na->last_realname = sstrdup("unknown"); na->time_registered = na->last_seen = time(NULL); na->nc->language = NSDefLanguage; na->nc->email = sstrdup(email); send_event(EVENT_NICK_REGISTERED, 1, nick); alog("%s: %s (%s@%s) used saregister to register %s", s_NickServ, u->nick, u->username, u->host, nick); notice_user(s_NickServ, u, "Nick \2%s\2 has been registered", nick); if (user) { user->na = na; validate_user(user); } } } if (email) free(email); if (pass) free(pass); if (nick) free(nick); return MOD_CONT; }
static void do_syntax_err(User *u) { notice_user(s_OperServ, u, "Syntax: \2ROOT (ADD|DEL|LIST) [\037nick\037]\2"); notice_user(s_OperServ, u, "\2/msg %s HELP ROOT\2 for more information.", s_OperServ); }
void myNickServHelp(User *u) { if (is_services_admin(u)) notice_user(s_NickServ, u, " SAREGISTER Register a nickname"); }
int do_resetpass(User * u) { char *buffer = NULL; char *nick = NULL; char *email = NULL; char passcode[PASSCODELEN]; char *callBackinfo[1]; NickAlias *na = NULL; if ((RestrictReset == 1) && !(is_oper(u))) { notice_lang(s_NickServ, u, ACCESS_DENIED); return MOD_CONT; } buffer = moduleGetLastBuffer(); nick = myStrGetToken(buffer, ' ', 0); email = myStrGetToken(buffer, ' ', 1); if (!nick) { moduleNoticeLang(s_NickServ, u, RESETPASS_SYNTAX); } else if (!anope_valid_nick(nick)) { notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, nick); } else if (!(na = findnick(nick))) { notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick); } else if (na->status & NS_VERBOTEN) { notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick); } else if (na->nc->flags & NI_SUSPENDED) { notice_lang(s_NickServ, u, NICK_X_SUSPENDED, na->nick); } else if (!na->nc->email) { notice_user(s_NickServ, u, "%s has no email associated with their account.", na->nick); } else if (moduleGetData(&na->nc->moduleData, MODULEDATAKEY)) { moduleNoticeLang(s_NickServ, u, RESETPASS_ALREADY_REQUESTED1, na->nick); moduleNoticeLang(s_NickServ, u, RESETPASS_ALREADY_REQUESTED2); } else if (!email && !is_oper(u) && !is_helpop(u)) { notice(s_NickServ, u->nick, "You need to provide the e-mail address associated with the account you are trying to reset the password on."); notice(s_NickServ, u->nick, "Syntax: /ns resetpass <nickname> <e-mail>"); } else if (!is_oper(u) && !is_helpop(u) && strcasecmp(email, na->nc->email)) { notice(s_NickServ, u->nick, "The e-mail address %s does not match the one associated with account %s.", email, na->nc->display); } else { generatePassCode(passcode); moduleAddData(&na->nc->moduleData, MODULEDATAKEY, passcode); if (do_sendmail(u, na) != 0) { alog(LOG_COULDNT_SENDMAIL, MYNAME, na->nick); moduleDelData(&na->nc->moduleData, MODULEDATAKEY); } else { callBackinfo[0] = na->nick; moduleAddCallback(MYNAME, time(NULL) + ExpirePassCode, expirePassCode, 1, callBackinfo); alog(LOG_RESETPASS_REQUESTED, MYNAME, u->nick, na->nick); moduleNoticeLang(s_NickServ, u, RESETPASS_SUCCESS, na->nick); moduleNoticeLang(s_NickServ, u, RESETPASS_INSTRUC); } } if (nick) free(nick); if (email) free(email); return MOD_CONT; }
int do_root(User *u) { char *buf = moduleGetLastBuffer(); char *cmd = myStrGetToken(buf, ' ', 0); char *nick = myStrGetToken(buf, ' ', 1); if (!cmd) { do_syntax_err(u); } else { if (!stricmp(cmd, "LIST")) { notice_user(s_OperServ, u, "Current services roots:"); int i; for (i = 0; i < RootNumber; ++i) { notice_user(s_OperServ, u, "%d. %s", i + 1, ServicesRoots[i]); } notice_user(s_OperServ, u, "End of services root list."); } else if (!nick) do_syntax_err(u); else { NickAlias *na = findnick(nick); if (!na) notice_lang(s_OperServ, u, NICK_X_NOT_REGISTERED, nick); else if (!stricmp(cmd, "ADD")) { if (na->nc->flags & NI_SERVICES_ROOT) { notice_user(s_OperServ, u, "\2%s\2 is already a services root", na->nick); } else { ++RootNumber; ServicesRoots = srealloc(ServicesRoots, sizeof(char *) * RootNumber); ServicesRoots[RootNumber - 1] = sstrdup(na->nick); na->nc->flags |= NI_SERVICES_ROOT; anope_cmd_global(s_OperServ, "\2%s\2 made \2%s\2 (\2%s\2) a services root administrator", u->nick, na->nick, na->nc->display); alog("%s: %s!%s@%s made %s (%s) a services root administrator", s_OperServ, u->nick, u->username, u->host, na->nick, na->nc->display); notice_user(s_OperServ, u, "\2%s\2 added to the services root administrator list.", na->nick); } } else if (!stricmp(cmd, "DEL")) { if (!(na->nc->flags & NI_SERVICES_ROOT)) { notice_user(s_OperServ, u, "\2%s\2 isn't already a services root", na->nick); } else { na->nc->flags &= ~NI_SERVICES_ROOT; int i, j, removed = 0; NickAlias *na2; for (i = 0; i < RootNumber; ++i) { for (j = 0; j < na->nc->aliases.count; ++j) { na2 = na->nc->aliases.list[j]; if (ServicesRoots[i] && !stricmp(ServicesRoots[i], na2->nick)) { free(ServicesRoots[i]); ServicesRoots[i] = NULL; ++removed; break; } } } int RealRootNum = RootNumber - removed;; char **RealRoots = scalloc(RealRootNum, sizeof(char *)); j = 0; for (i = 0; i < RootNumber; ++i) { if (ServicesRoots[i]) { RealRoots[j] = sstrdup(ServicesRoots[i]); ++j; } } free(ServicesRoots); ServicesRoots = RealRoots; RootNumber = RealRootNum; anope_cmd_global(s_OperServ, "\2%s\2 removed \2%s\2 (\2%s\2) from being a services root administrator", u->nick, na->nick, na->nc->display); alog("%s: %s!%s@%s made %s (%s) a services root administrator", s_OperServ, u->nick, u->username, u->host, na->nick, na->nc->display); notice_user(s_OperServ, u, "\2%s\2 removed from the services root administrator list.", na->nick); } } else do_syntax_err(u); } } if (cmd) free(cmd); if (nick) free(nick); return MOD_CONT; }
int main(object me, string arg) { string target, msg, mud; string my_id; object obj; string no_tell, can_tell; string tell_out; if (! arg || sscanf(arg, "%s %s", target, msg) != 2) return help(me); if (sscanf(target, "%s@%s", target, mud) == 2) { if (GTELL->send_gtell(mud, target, me, msg)) { write("网路讯息已送出,可能要稍候才能得到回应。\n"); return 1; } } obj = find_player(target); if (! obj || ! me->visible(obj)) { if (MESSAGE_D->send_msg_to(me, target, msg)) return 1; return notify_fail("这个用户没有登录,你无法和他交谈。\n"); } my_id = me->query("id"); no_tell = obj->query("env/no_tell"); if (! wizardp(me) && (no_tell == "all" || no_tell == "ALL" || is_sub(my_id, no_tell))) { can_tell = obj->query("env/can_tell"); if (! is_sub(my_id, can_tell)) return notify_fail("这个人不想听你罗嗦啦。\n"); } if (! interactive(obj) || obj->is_net_dead()) return notify_fail("此人现在不在线上,听不到你的话。\n"); if (! living(obj)) return notify_fail("这人现在恐怕听不到你说的话了...\n"); if (me->ban_say(1)) return 0; if (obj == me) { message_vision("$N喃喃自语。\n", me); return 1; } tell_out = sprintf(HIG "%s告诉你:%s\n" NOR, me->name(1) + HIG + "(" + capitalize(my_id) + ")", msg); if (! notice_user(me->name(1), my_id, obj, tell_out)) return 1; write(sprintf(HIG "你告诉%s(%s):%s\n" NOR, obj->name(1) + HIG, capitalize(obj->query("id")), msg)); if (query_idle(obj) >= 120) write(YEL "可是" + obj->name(1) + YEL "已经在猪圈中发呆有" + chinese_number(query_idle(obj) / 60) + "分钟了,恐怕没法立刻回答你。\n"); return 1; }
int doNsSendPass(User *u) { notice_user(s_NickServ, u, "This command is disabled for security reasons. Please join #help and ask a network staff member for a password reset."); return MOD_CONT; }
int doCsSendPass(User *u) { notice_user(s_ChanServ, u, "This command is disabled for security reasons. Please join #help for assistance."); return MOD_CONT; }
/** * The /ns list command. * @param u The user who issued the command * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing. **/ static int do_list(User * u) { /* SADMINS can search for nicks based on their NS_VERBOTEN and NS_NO_EXPIRE * status. The keywords FORBIDDEN and NOEXPIRE represent these two states * respectively. These keywords should be included after the search pattern. * Multiple keywords are accepted and should be separated by spaces. Only one * of the keywords needs to match a nick's state for the nick to be displayed. * Forbidden nicks can be identified by "[Forbidden]" appearing in the last * seen address field. Nicks with NOEXPIRE set are preceeded by a "!". Only * SADMINS will be shown forbidden nicks and the "!" indicator. * Syntax for sadmins: LIST pattern [FORBIDDEN] [NOEXPIRE] * -TheShadow * * UPDATE: SUSPENDED keyword is now accepted as well. */ char *pattern = strtok(NULL, " "); char *keyword; NickAlias *na; NickCore *mync; int nnicks, i; char buf[BUFSIZE]; int is_servadmin = is_services_admin(u); int16 matchflags = 0; NickRequest *nr = NULL; int nronly = 0; int susp_keyword = 0; char noexpire_char = ' '; int count = 0, from = 0, to = 0, tofree = 0; char *tmp = NULL; char *s = NULL; if (!(!NSListOpersOnly || (is_oper(u)))) { /* reverse the help logic */ notice_lang(s_NickServ, u, ACCESS_DENIED); return MOD_STOP; } if (!pattern) { syntax_error(s_NickServ, u, "LIST", is_servadmin ? NICK_LIST_SERVADMIN_SYNTAX : NICK_LIST_SYNTAX); } else { if (pattern) { if (pattern[0] == '#') { tmp = myStrGetOnlyToken((pattern + 1), '-', 0); /* Read FROM out */ if (!tmp) { notice_lang(s_ChanServ, u, LIST_INCORRECT_RANGE); return MOD_CONT; } for (s = tmp; *s; s++) { if (!isdigit(*s)) { free(tmp); notice_lang(s_ChanServ, u, LIST_INCORRECT_RANGE); return MOD_CONT; } } from = atoi(tmp); free(tmp); tmp = myStrGetTokenRemainder(pattern, '-', 1); /* Read TO out */ if (!tmp) { notice_lang(s_ChanServ, u, LIST_INCORRECT_RANGE); return MOD_CONT; } for (s = tmp; *s; s++) { if (!isdigit(*s)) { free(tmp); notice_lang(s_ChanServ, u, LIST_INCORRECT_RANGE); return MOD_CONT; } } to = atoi(tmp); free(tmp); pattern = sstrdup("*"); tofree = 1; } } nnicks = 0; while (is_servadmin && (keyword = strtok(NULL, " "))) { if (stricmp(keyword, "FORBIDDEN") == 0) matchflags |= NS_VERBOTEN; if (stricmp(keyword, "NOEXPIRE") == 0) matchflags |= NS_NO_EXPIRE; if (stricmp(keyword, "SUSPENDED") == 0) susp_keyword = 1; if (stricmp(keyword, "UNCONFIRMED") == 0) nronly = 1; } mync = (nick_identified(u) ? u->na->nc : NULL); notice_lang(s_NickServ, u, NICK_LIST_HEADER, pattern); if (nronly != 1) { for (i = 0; i < 1024; i++) { for (na = nalists[i]; na; na = na->next) { /* Don't show private and forbidden nicks to non-services admins. */ if ((na->status & NS_VERBOTEN) && !is_servadmin) continue; if ((na->nc->flags & NI_PRIVATE) && !is_servadmin && na->nc != mync) continue; if ((matchflags != 0) && !(na->status & matchflags) && (susp_keyword == 0)) continue; else if ((susp_keyword == 1) && !(na->nc->flags & NI_SUSPENDED)) continue; /* We no longer compare the pattern against the output buffer. * Instead we build a nice nick!user@host buffer to compare. * The output is then generated separately. -TheShadow */ snprintf(buf, sizeof(buf), "%s!%s", na->nick, (na->last_usermask && !(na->status & NS_VERBOTEN)) ? na-> last_usermask : "*@*"); if (stricmp(pattern, na->nick) == 0 || match_wild_nocase(pattern, buf)) { if ((((count + 1 >= from) && (count + 1 <= to)) || ((from == 0) && (to == 0))) && (++nnicks <= NSListMax)) { if (is_servadmin && (na->status & NS_NO_EXPIRE)) noexpire_char = '!'; else { noexpire_char = ' '; } if ((na->nc->flags & NI_HIDE_MASK) && !is_servadmin && na->nc != mync) { snprintf(buf, sizeof(buf), "%-20s [Hostname Hidden]", na->nick); } else if (na->status & NS_VERBOTEN) { snprintf(buf, sizeof(buf), "%-20s [Forbidden]", na->nick); } else if (na->nc->flags & NI_SUSPENDED) { snprintf(buf, sizeof(buf), "%-20s [Suspended]", na->nick); } else { snprintf(buf, sizeof(buf), "%-20s %s", na->nick, na->last_usermask); } notice_user(s_NickServ, u, " %c%s", noexpire_char, buf); } count++; } } } } if (nronly == 1 || (is_servadmin && matchflags == 0 && susp_keyword == 0)) { noexpire_char = ' '; for (i = 0; i < 1024; i++) { for (nr = nrlists[i]; nr; nr = nr->next) { snprintf(buf, sizeof(buf), "%s!*@*", nr->nick); if (stricmp(pattern, nr->nick) == 0 || match_wild_nocase(pattern, buf)) { if (++nnicks <= NSListMax) { snprintf(buf, sizeof(buf), "%-20s [UNCONFIRMED]", nr->nick); notice_user(s_NickServ, u, " %c%s", noexpire_char, buf); } } } } } notice_lang(s_NickServ, u, NICK_LIST_RESULTS, nnicks > NSListMax ? NSListMax : nnicks, nnicks); } if (tofree) free(pattern); return MOD_CONT; }