WoWInterface SVN NoGuild

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 23 to Rev 22
    Reverse comparison

Rev 23 → Rev 22

trunk/LICENSE.txt New file
0,0 → 1,33
Copyright (c) 2013-2014 Phanx. All rights reserved.
 
Permission is granted for anyone to use, read, or otherwise interpret
this software for any purpose, without any restrictions.
 
Permission is granted for anyone to modify this software or sample from
it, and to distribute such modified versions or derivative works as long
as neither the names of this software nor its authors are used in the
name or title of the work or in any other way that may cause it to be
confused with or interfere with the simultaneous use of this software.
 
Permission is granted for anyone to aggregate this software with other
works not derived from this software for the purpose of creating a user
interface replacement (also commonly known as a "compilation" or "addon
pack") for the "World of Warcraft" game client, and to distribute such
collective works as long as the software is not modified in any way,
including by modifying or removing any files.
 
This software may not be distributed standalone or in any other way, in
whole or in part, modified or unmodified, without specific prior written
permission from the authors of this software.
 
The names of this software and/or its authors may not be used to
promote or endorse works derived from this software without specific
prior written permission from the authors of this software.
 
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
trunk/NoGuild.lua New file
0,0 → 1,253
--[[--------------------------------------------------------------------
NoGuild
Blocks guild solicitations in whispers and public chat channels.
Copyright (c) 2013-2014 Phanx. All rights reserved.
See the accompanying README and LICENSE files for more information.
http://www.wowinterface.com/downloads/info22644-NoGuild.html
http://www.curse.com/addons/wow/noguild/
----------------------------------------------------------------------]]
 
-- Almost all guild spam has at least one of these words.
local L1 = {
-- All languages
"<", ">", "%%", "%*", "%d/%d", "%d%-%d", "%d:%d%d", "%d ?[ap]m",
"%f[%a]lf .*gu?ilde?%f[%A]", -- en/de
-- English
"bank tab",
"free guild repair", "free repair",
"guild", "giuld", "gulid",
"le?ve?l ?25",
"main raid", "member", "memeber",
"perk", "progressio?ng?", "pv[ep] guild",
"recruit", "reqruit",
"mumble", "teamspeak", "ventrilo",
"http", "www", ".com", ".net", ".org",
"monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday",
"tues", "thurs?",
-- German
"%d ?uhr",
"bankfächern", "bewerbung",
"ep bonus",
"gegründet", "gesucht werden", "gilde[n%s]", "gildenboni", "gildenname", "gildensatzung", "gildenstamm", "gilde .+ such[te]", "gründung",
"levelbon[iu]s?", "levelgilde", "lust auf.* gilde",
"massen ?wie?der ?belebung", "mitstreiter",
"pv[ep]%-?gilde",
"raid%-?tage", "raidgilde", "raidorientert", "raidzeit", "rekrutier",
"schnelleres reiten", "socius", "stammplatz", "stufe ?25", "%f[%a]such[est] .*gilde%f[%A]",
"montag", "dienstag", "mittwoch", "donnerstag", "freitag", "samstag", "sonntag",
}
 
-- And probably at least one of these words.
local L2 = {
"[^i]le?ve?l? ?%d",
"active", "applicant", "apply",
"casual", "consider[ei][dn]g?", "content", "core",
"exceptional", "e?xpe?r?i?e?n?c?e?",
"farm", "fill", "focus", "fun",
"goal",
"hardcore", "helpful",
"info", "interest", "invite",
"join",
"laid back", "looking",
"member",
"newly formed", "nice",
"pacific", "player", "progression", "pve", "pvp",
"raid", "rbg", "realm", "repu?t?a?t?i?o?n?", "roster",
"server time", "skilled", "social",
"tabard", "times",
"unlock",
"ventr?i?l?o?",
"want", "we are", "we plan t?on?", "weekend", "weekly", "would you like",
-- German
"18 jahren",
"aktive", "anfänger", "atmosphäre", "aufz?u?bau", "bock",
"entsprechend", "erfahren", "farmen", "gründe", "hoffe", "interesse", "klasse",
"leveln", "lust", "möchte", "motivierte", "pflichten",
"sozial", "spaß", "spiel", "stamm",
"verplichtung", "verstärkung", "wilkommen",
}
 
-- Guild spam usually does not contain these words.
local OK = {
"|hachivement", "|hinstancelock", "|hitem", "|hquest", "|htrade",
"arena", "[235]v[235]", " [235]s",
"challenge mode", "cm gold", "flex", "^lf ", "lfm", "lfg", "scenario", -- "tank", "heal", "dps",
"ffa", "no reserve",
-- "galak", "%f[%a]sha%f[%A]", "%f[%a]soo%f[%A]",
"%f[%a]wt[bs]%f[%A]",
-- German
"abend", "heute", "morgen",
"gildengruppe", "herausforderung", "%f[%a]id%f[%A]", "kaufe", "rbg push", "szenario", "vk%f[%A]",
}
 
------------------------------------------------------------------------
 
NoGuildMessages = {}
 
local format, strfind, strjoin, strlower, strmatch, strtrim, tinsert, tostring, tremove, type
= format, strfind, strjoin, strlower, strmatch, strtrim, tinsert, tostring, tremove, type
 
local BNGetFriendToonInfo, BNGetNumFriends, BNGetNumFriendToons, CanComplainChat, UnitInParty, UnitInRaid, UnitIsInMyGuild
= BNGetFriendToonInfo, BNGetNumFriends, BNGetNumFriendToons, CanComplainChat, UnitInParty, UnitInRaid, UnitIsInMyGuild
 
local function debug(str, ...)
if (...) then
if type(str) == "string" and strmatch(str, "%%[dfqsx%d%.]") then
(DEBUG_CHAT_FRAME or ChatFrame3):AddMessage("|cffffcc33[NoGuild]|r " .. format(str, ...))
else
(DEBUG_CHAT_FRAME or ChatFrame3):AddMessage("|cffffcc33[NoGuild]|r " .. strjoin(" ", tostringall(str, ...)))
end
elseif str then
(DEBUG_CHAT_FRAME or ChatFrame3):AddMessage("|cffffcc33[NoGuild]|r " .. tostring(str))
end
end
 
------------------------------------------------------------------------
 
local seen, last, result = {}
 
local function GetGuildSpamScore(message)
local score = 0
local messagelower = gsub(strlower(strtrim(message)), "{.-}", "")--[[
for i = 1, #L0 do
if strfind(messagelower, L0[i]) then
score = score + 10
end
end]]
for i = 1, #L1 do
if strfind(messagelower, L1[i]) then
score = score + 4
end
end
for i = 1, #L2 do
if strfind(messagelower, L2[i]) then
score = score + 1
end
end
for i = 1, #OK do
if strfind(messagelower, OK[i]) then
score = score - 4
end
end
return score
end
_G.GetGuildSpamScore = GetGuildSpamScore
 
local function exspaminate(self, event, message, sender, _, _, _, flag, _, channelID, _, _, line, guid)
if line == last then
return result
end
last, result = line, nil
 
--debug("[flag]", tostring(flag), "[line]", tostring(line), "[CanComplainChat]", tostring(CanComplainChat(line)))
 
if flag == "GM" or flag == "DEV" then
return --debug("ALLOWED [flag]", flag)
end
 
if event == "CHAT_MSG_CHANNEL" and (channelID == 0 or type(channelID) ~= "number") then
-- Ignore custom channels
return --debug("ALLOWED custom channel", channelID)
end
 
if not CanComplainChat(line) or UnitIsInMyGuild(sender) or UnitInRaid(sender) or UnitInParty(sender) then
return --[[debug("ALLOWED",
"[CanComplainChat]", CanComplainChat(line),
"[UnitIsInMyGuild]", UnitIsInMyGuild(sender),
"[UnitInRaid]", UnitInRaid(sender),
"[UnitInParty]", UnitInParty(sender))]]
end
 
if event == "CHAT_MSG_WHISPER" then
local _, numBnetFriends = BNGetNumFriends()
for i = 1, numBnetFriends do
for j = 1, BNGetNumFriendToons(i) do
local _, name, game = BNGetFriendToonInfo(i, j)
if name == sender and game == "WoW" then
return --debug("ALLOWED [BNGetFriendToonInfo]", i, j, name, game)
end
end
end
end
 
local score = GetGuildSpamScore(message)
 
if score > 3 then
--debug("Blocked message with score %d from |Hplayer:%s:%d|h%s|h:", score, sender, line, sender)
--debug(" ", message)
if not seen[message] then
tinsert(NoGuildMessages, 1, format("[%d] %s: %s", score, sender, message))
end
result = true
return true
end
 
--if event == "CHAT_MSG_WHISPER" and score > 0 then
-- debug("Allowed message with score %d from |Hplayer:%s:%d|h%s|h:", score, sender, line, sender)
--end
result = nil
end
 
------------------------------------------------------------------------
 
local addon = CreateFrame("Frame")
addon:RegisterEvent("PLAYER_LOGIN")
addon:SetScript("OnEvent", function(self, event)
if event == "PLAYER_LOGIN" then
-- Spammers love that "personal touch"
local name = UnitName("player")
tinsert(L1, strlower(name))
 
-- Guild Mail, Hasty Hearth, Mass Resurrection, Mobile Banking, Mount Up, The Quick and the Dead
for _, spell in pairs({ 83951, 83944, 83968, 83958, 78633, 83950 }) do
local name = GetSpellInfo(spell)
if name then
tinsert(L1, strlower(name))
end
end
 
if NoGuildStatus == nil then
SetAutoDeclineGuildInvites(true)
NoGuildStatus = true
end
 
self:UnregisterEvent("PLAYER_LOGIN")
self:RegisterEvent("DISABLE_DECLINE_GUILD_INVITE")
self:RegisterEvent("ENABLE_DECLINE_GUILD_INVITE")
self:RegisterEvent("PLAYER_GUILD_UPDATE")
self:RegisterEvent("PLAYER_LOGOUT")
 
elseif event == "PLAYER_LOGOUT" then
-- Remove duplicate log entries
local seen = {}
for i = #NoGuildMessages, 1, -1 do
local message = NoGuildMessages[i]
if seen[message] then
tremove(NoGuildMessages, i)
else
seen[message] = true
end
end
-- Truncate log
while #NoGuildMessages > 100 do
tremove(NoGuildMessages, #NoGuildMessages)
end
-- End
return
end
 
local enable = GetAutoDeclineGuildInvites() and not IsInGuild()
if enable == NoGuildStatus and event ~= "PLAYER_LOGIN" then
return
end
if enable then
-- Los!
ChatFrame_AddMessageEventFilter("CHAT_MSG_CHANNEL", exspaminate)
ChatFrame_AddMessageEventFilter("CHAT_MSG_WHISPER", exspaminate)
else
-- Halt!
ChatFrame_RemoveMessageEventFilter("CHAT_MSG_CHANNEL", exspaminate)
ChatFrame_RemoveMessageEventFilter("CHAT_MSG_WHISPER", exspaminate)
end
NoGuildStatus = enable
end)
\ No newline at end of file
trunk/NoGuild.toc New file
0,0 → 1,23
## Interface: 60000
## Version: 6.0.2.wowi:revision
 
## Title: NoGuild
## Notes: Blocks guild advertisements in whispers and public chat channels.
## Notes-deDE: Blockiert Gildenwerbungen in Flüstern und öffentlichen Chat-Channels.
## Notes-esES: Bloquea los anuncios de hermandades en susurros y los canales públicos.
## Notes-esMX: Bloquea los anuncios de hermandades en susurros y los canales públicos.
 
## Author: Phanx
## X-Email: addons@phanx.net
## X-Copyright: Copyright (c) 2013-2014 Phanx. All rights reserved.
## X-License: See the accompanying LICENSE file for details.
## X-CompatibleLocales: deDE, enUS, esES, esMX, frFR, itIT, ptBR, koKR, ruRU, zhCN, zhTW
## X-Localizations: deDE, enUS
## X-Website: http://www.wowinterface.com/downloads/info22644-NoGuild.html
## X-Curse-Project-Name: noguild
## X-WoWI-ID: 22644
 
## SavedVariables: NoGuildMessages
## SavedVariablesPerCharacter: NoGuildStatus
 
NoGuild.lua
\ No newline at end of file
trunk/README.txt New file
0,0 → 1,42
NoGuild
============
 
Blocks guild advertisements in whispers and public chat channels.
 
 
Download
-----------
 
* [WoWInterface](http://www.wowinterface.com/downloads/info22644-NoGuild.html)
* [Curse](http://www.curse.com/addons/wow/noguild)
 
 
Localization
-----------------
 
Compatible with all localized game clients.
 
Currently detects spam in English and German only. Contributions of
keyword lists for other languages are welcome.
 
 
Feedback
-----------
 
Post a ticket on either download site, or a comment on WoWInterface.
 
If you are reporting a bug, please include directions I can follow to
reproduce the bug, whether it still happens when all other addons are
disabled, and the exact text of the related error message (if any) from
[Bugger](http://www.wowinterface.com/downloads/info23144-Bugger.html).
 
If you need to contact me privately, you can send me a private message
on either download site, or email me at <addons@phanx.net>.
 
 
License
----------
 
Copyright (c) 2014 Phanx. All rights reserved.
See the accompanying LICENSE file for information about the conditions
under which redistribution and modification may be allowed.