diff --git a/Changes b/Changes index dd83cbf1f..89ada00db 100644 --- a/Changes +++ b/Changes @@ -2934,3 +2934,6 @@ seen. gmtime warning still there - Fixed a bug in 'Flood from unknown connection' (#0001566). - Rewrote a great deal of the remote include code to make it work on Windows due to Microsoft insanity. +- Added /tempshun, temporary shuns the current session of specified nick + (just like the 'tempshun' in spamfilter and ban version). Suggested by + Cnils (#0001526). [docs/help.conf will be updated later] diff --git a/src/modules/m_tkl.c b/src/modules/m_tkl.c index e6e080649..1db3b18c9 100644 --- a/src/modules/m_tkl.c +++ b/src/modules/m_tkl.c @@ -30,6 +30,7 @@ DLLFUNC int m_gline(aClient *cptr, aClient *sptr, int parc, char *parv[]); DLLFUNC int m_shun(aClient *cptr, aClient *sptr, int parc, char *parv[]); +DLLFUNC int m_tempshun(aClient *cptr, aClient *sptr, int parc, char *parv[]); DLLFUNC int m_gzline(aClient *cptr, aClient *sptr, int parc, char *parv[]); DLLFUNC int m_tkline(aClient *cptr, aClient *sptr, int parc, char *parv[]); DLLFUNC int m_tzline(aClient *cptr, aClient *sptr, int parc, char *parv[]); @@ -46,6 +47,8 @@ DLLFUNC int m_spamfilter(aClient *cptr, aClient *sptr, int parc, char *parv[]); #define MSG_ZLINE "ZLINE" #define MSG_SPAMFILTER "SPAMFILTER" #define TOK_NONE "" +#define MSG_TEMPSHUN "TEMPSHUN" +#define TOK_TEMPSHUN "Tz" ModuleHeader MOD_HEADER(m_tkl) = { @@ -65,6 +68,7 @@ DLLFUNC int MOD_INIT(m_tkl)(ModuleInfo *modinfo) */ add_Command(MSG_GLINE, TOK_GLINE, m_gline, 3); add_Command(MSG_SHUN, TOK_SHUN, m_shun, 3); + add_Command(MSG_TEMPSHUN, TOK_TEMPSHUN, m_tempshun, 2); add_Command(MSG_ZLINE, TOK_NONE, m_tzline, 3); add_Command(MSG_KLINE, TOK_NONE, m_tkline, 3); add_Command(MSG_GZLINE, TOK_NONE, m_gzline, 3); @@ -174,6 +178,80 @@ DLLFUNC int m_shun(aClient *cptr, aClient *sptr, int parc, char *parv[]) } +DLLFUNC int m_tempshun(aClient *cptr, aClient *sptr, int parc, char *parv[]) +{ +aClient *acptr; +char *comment = ((parc > 2) && !BadPtr(parv[2])) ? parv[2] : "no reason"; +char *name; +int remove = 0; + + if (MyClient(sptr) && (!OPCanTKL(sptr) || !IsOper(sptr))) + { + sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, + sptr->name); + return 0; + } + if ((parc < 2) || BadPtr(parv[1])) + { + sendto_one(sptr, err_str(ERR_NEEDMOREPARAMS), me.name, sptr->name, "TEMPSHUN"); + return 0; + } + if (parv[1][0] == '+') + name = parv[1]+1; + else if (parv[1][0] == '-') + { + name = parv[1]+1; + remove = 1; + } else + name = parv[1]; + + acptr = find_person(name, NULL); + if (!acptr) + { + sendto_one(sptr, err_str(ERR_NOSUCHNICK), me.name, sptr->name, name); + return 0; + } + if (!MyClient(acptr)) + { + sendto_one(acptr->from, ":%s %s %s :%s", + sptr->name, IsToken(acptr->from) ? TOK_TEMPSHUN : MSG_TEMPSHUN, + parv[1], comment); + } else { + char buf[1024]; + if (!remove) + { + if (IsShunned(acptr)) + { + sendnotice(sptr, "User '%s' already shunned", acptr->name); + } else if (IsAnOper(acptr)) + { + sendnotice(sptr, "You cannot tempshun '%s' because (s)he is an oper", acptr->name); + } else + { + SetShunned(acptr); + ircsprintf(buf, "Temporary shun added on user %s (%s@%s) by %s [%s]", + acptr->name, acptr->user->username, acptr->user->realhost, + sptr->name, comment); + sendto_snomask(SNO_TKL, "%s", buf); + sendto_serv_butone_token(NULL, me.name, MSG_SENDSNO, TOK_SENDSNO, "G :%s", buf); + } + } else { + if (!IsShunned(acptr)) + { + sendnotice(sptr, "User '%s' is not shunned", acptr->name); + } else { + ClearShunned(acptr); + ircsprintf(buf, "Removed temporary shun on user %s (%s@%s) by %s", + acptr->name, acptr->user->username, acptr->user->realhost, + sptr->name); + sendto_snomask(SNO_TKL, "%s", buf); + sendto_serv_butone_token(NULL, me.name, MSG_SENDSNO, TOK_SENDSNO, "G :%s", buf); + } + } + } + return 0; +} + DLLFUNC int m_tkline(aClient *cptr, aClient *sptr, int parc, char *parv[]) { if (IsServer(sptr)) diff --git a/src/s_kline.c b/src/s_kline.c index 7d32df593..be53f1343 100644 --- a/src/s_kline.c +++ b/src/s_kline.c @@ -134,7 +134,7 @@ int tkl_add_line(int type, char *usermask, char *hostmask, char *reason, char * nl->subtype = spamfilter_gettargets(usermask, NULL); nl->spamf = unreal_buildspamfilter(reason); nl->spamf->action = banact_chartoval(*hostmask); - nl->expire_at = 0; /* temporarely spamfilters are NOT supported! (makes no sense) */ + nl->expire_at = 0; /* temporary spamfilters are NOT supported! (makes no sense) */ if (!spamf_tkl_reason) { /* no exttkl support, use default values... */ @@ -1102,7 +1102,7 @@ int place_host_ban(aClient *sptr, int action, char *reason, long duration) { case BAN_ACT_TEMPSHUN: /* We simply mark this connection as shunned and do not add a ban record */ - sendto_snomask(SNO_TKL, "Temporarely shun added at user %s (%s@%s) [%s]", + sendto_snomask(SNO_TKL, "Temporary shun added at user %s (%s@%s) [%s]", sptr->name, sptr->user ? sptr->user->username : "unknown", sptr->user ? sptr->user->realhost : Inet_ia2p(&sptr->ip),