WoWInterface SVN NoGuild

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 5 to Rev 4
    Reverse comparison

Rev 5 → Rev 4

trunk/NoGuild.lua
37,10 → 37,10
"laid back", "looking",
"member",
"newly formed", "nice",
"pacific", "progression", "pve", "pvp",
"progression", "pve", "pvp",
"raid", "rbg", "repu?t?a?t?i?o?n?", "roster",
"server time", "skilled", "social",
"tabard", "times",
"tabard",
"unlock",
"ventr?i?l?o?",
"want", "we are", "we plan t?on?", "weekend", "weekly", "would you like",
59,45 → 59,51
local BNGetFriendToonInfo, BNGetNumFriends, BNGetNumFriendToons, CanComplainChat, GetAutoDeclineGuildInvites, IsInGuild, UnitInParty, UnitInRaid, UnitIsInMyGuild
= BNGetFriendToonInfo, BNGetNumFriends, BNGetNumFriendToons, CanComplainChat, GetAutoDeclineGuildInvites, IsInGuild, UnitInParty, UnitInRaid, UnitIsInMyGuild
 
local function debug(str, ...)
if (...) then
if type(str) == "string" and strmatch(str, "%%[dfqsx%d%.]") then
DEFAULT_CHAT_FRAME:AddMessage("|cffffcc33[NoGuild]|r " .. format(str, ...))
local function debug(lvl, str, ...)
if str then
if (...) then
if type(str) == "string" and strmatch(str, "%%[dfqsx%d%.]") then
DEFAULT_CHAT_FRAME:AddMessage("|cffffcc33[NoGuild]|r " .. format(str, ...))
else
DEFAULT_CHAT_FRAME:AddMessage("|cffffcc33[NoGuild]|r " .. strjoin(" ", tostringall(str, ...)))
end
else
DEFAULT_CHAT_FRAME:AddMessage("|cffffcc33[NoGuild]|r " .. strjoin(" ", tostringall(str, ...)))
DEFAULT_CHAT_FRAME:AddMessage("|cffffcc33[NoGuild]|r " .. tostring(str))
end
elseif str then
DEFAULT_CHAT_FRAME:AddMessage("|cffffcc33[NoGuild]|r " .. tostring(str))
end
end
 
------------------------------------------------------------------------
 
local seen, last, result = {}
local last, result
 
local function exspaminate(self, event, message, sender, _, _, _, flag, _, channelID, _, _, line, guid)
local function exspaminate(self, event, message, sender, _, _, _, flag, _, _, _, _, line, guid)
if line == last then
return result
end
last, result = line, nil
 
if GetAutoDeclineGuildInvites() == 0 and not IsInGuild() then
return -- debug("ALLOWED [GetAutoDeclineGuildInvites]", tostring(GetAutoDeclineGuildInvites()), "[IsInGuild]", tostring(IsInGuild()))
end
 
-- debug("[flag]", tostring(flag), "[line]", tostring(line), "[CanComplainChat]", tostring(CanComplainChat(line)))
 
if flag == "GM" or flag == "DEV" then
return --debug("ALLOWED [flag]", flag)
return -- debug("ALLOWED [flag]", flag)
end
 
if event == "CHAT_MSG_CHANNEL" and (channelID == 0 or type(channelID) ~= "number") then
if event == "CHAT_MSG_CHANNEL" and (channelId == 0 or type(channelId) ~= "number") then
-- Ignore custom channels
return --debug("ALLOWED custom channel", channelID)
return
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)) ]]
"[CanComplainChat]", tostring(CanComplainChat(line) or "nil"),
"[UnitIsInMyGuild]", tostring(UnitIsInMyGuild(sender) or "nil"),
"[UnitInRaid]", tostring(UnitInRaid(sender) or "nil"),
"[UnitInParty]", tostring(UnitInParty(sender) or "nil")) ]]
end
 
if event == "CHAT_MSG_WHISPER" then
106,7 → 112,7
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)
return -- debug("ALLOWED [BNGetFriendToonInfo]", i, j, name, game)
end
end
end
131,60 → 137,34
end
 
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
-- debug("Blocked message with score %d from |Hplayer:%s:%d|h%s|h:", score, sender, line, sender)
-- debug(" ", message)
tinsert(NoGuildMessages, 1, format("[%d] %s: %s", score, sender, message))
result = true
return true
end
 
--debug("Allowed message with score %d from |Hplayer:%s:%d|h%s|h:", score, sender, line, sender)
result = nil
end
 
------------------------------------------------------------------------
 
local enabled
 
local addon = CreateFrame("Frame")
addon:RegisterEvent("PLAYER_LOGIN")
addon:SetScript("OnEvent", function(self, event)
if event == "PLAYER_LOGIN" then
-- Spammers love that "personal touch"
tinsert(L1, (UnitName("player")))
addon:SetScript("OnEvent", function()
-- Initialize log
NoGuildMessages = NoGuildMessages or {}
db = NoGuildMessages
 
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
-- Truncate log
while #NoGuildMessages > 100 do
tremove(NoGuildMessages, #NoGuildMessages)
end
-- End
return
-- Truncate log
for i = 50, #db do
db[i] = nil
end
 
local toenable = IsInGuild() or GetAutoDeclineGuildInvites() == 1
if toenable == enabled then
return
end
if toenable then
-- Los!
print("Los!")
ChatFrame_AddMessageEventFilter("CHAT_MSG_CHANNEL", exspaminate)
ChatFrame_AddMessageEventFilter("CHAT_MSG_WHISPER", exspaminate)
enabled = true
else
-- Halt!
print("Halt!")
ChatFrame_RemoveMessageEventFilter("CHAT_MSG_CHANNEL", exspaminate)
ChatFrame_RemoveMessageEventFilter("CHAT_MSG_WHISPER", exspaminate)
enabled = false
end
-- Spammers love that "personal touch"
tinsert(L1, (UnitName("player")))
 
-- Los!
ChatFrame_AddMessageEventFilter("CHAT_MSG_CHANNEL", exspaminate)
ChatFrame_AddMessageEventFilter("CHAT_MSG_WHISPER", exspaminate)
end)
\ No newline at end of file