diff options
| author | 2009-09-04 17:24:57 +0000 | |
|---|---|---|
| committer | 2009-09-04 17:24:57 +0000 | |
| commit | 0c8ad5e64bbc1cce030cb80e1a50350c56fa1bb7 (patch) | |
| tree | da3a45020cd67033ba653d850d6425d8704e9638 /src/modules/chan | |
| parent | fix for #554 (diff) | |
| download | KVIrc-0c8ad5e64bbc1cce030cb80e1a50350c56fa1bb7.tar.gz KVIrc-0c8ad5e64bbc1cce030cb80e1a50350c56fa1bb7.tar.bz2 KVIrc-0c8ad5e64bbc1cce030cb80e1a50350c56fa1bb7.zip | |
added $chan.matchqban (fixes #555)
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@3477 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src/modules/chan')
| -rw-r--r-- | src/modules/chan/libkvichan.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/modules/chan/libkvichan.cpp b/src/modules/chan/libkvichan.cpp index 543d28782..ed51151ff 100644 --- a/src/modules/chan/libkvichan.cpp +++ b/src/modules/chan/libkvichan.cpp @@ -1453,6 +1453,59 @@ static bool chan_kvs_fnc_matchinvite(KviKvsModuleFunctionCall * c) } /* + @doc: chan.matchqban + @type: + function + @title: + $chan.matchqban + @short: + Matches a mask agains the channel ban list searcing for +q bans (aka mute bans) + @syntax: + <string> $chan.matchqban([window_id],<complete_mask>) + @description: + Some networks use +q channel mode to set "mute bans". + When an user mask matches such a ban, he won't be able to send messages to the channel. + The "mute bans" masks will be inserted in the normal channel bans list, with a percent sign % prepended + This function returns the "mute ban" mask that matches <complete_mask> on channel identified by [window_id].[br] + If no ban mask matches <complete_mask> an empty string is returned.[br] + If [window_id] is empty, the current window is used.[br] + If the window designated by [window_id] is not a channel a warning is printed and an empty string is returned.[br] + This function is useful to determine if a "mute ban" set on the channel matches an user.[br] +*/ + +static bool chan_kvs_fnc_matchqban(KviKvsModuleFunctionCall * c) +{ + QString szWinId,szMask; + KVSM_PARAMETERS_BEGIN(c) + KVSM_PARAMETER("window id",KVS_PT_STRING,0,szWinId) + KVSM_PARAMETER("mask",KVS_PT_STRING,0,szMask) + KVSM_PARAMETERS_END(c) + + KviChannel * ch = chan_kvs_find_channel(c,szWinId); + szMask.prepend('%'); + + if(!ch) + { + c->returnValue()->setNothing(); + return true; + } + + KviPointerList<KviMaskEntry> * l = ch->banList(); + + for(KviMaskEntry * e = l->first();e;e = l->next()) + { + if(KviQString::matchStringCI(e->szMask,szMask)) + { + c->returnValue()->setString(e->szMask); + return true; + } + } + + c->returnValue()->setNothing(); + return true; +} + +/* @doc: chan.usermodelevel @type: function @@ -1608,6 +1661,7 @@ static bool chan_module_init(KviModule * m) KVSM_REGISTER_FUNCTION(m,"banexceptionlist",chan_kvs_fnc_banexceptionlist); KVSM_REGISTER_FUNCTION(m,"invitelist",chan_kvs_fnc_invitelist); KVSM_REGISTER_FUNCTION(m,"matchban",chan_kvs_fnc_matchban); + KVSM_REGISTER_FUNCTION(m,"matchqban",chan_kvs_fnc_matchqban); KVSM_REGISTER_FUNCTION(m,"matchbanexception",chan_kvs_fnc_matchbanexception); KVSM_REGISTER_FUNCTION(m,"matchinvite",chan_kvs_fnc_matchinvite); KVSM_REGISTER_FUNCTION(m,"getUrl",chan_kvs_fnc_getUrl); |
