Thread Tools Display Modes
02-20-09, 01:30 AM   #1
weaselSR
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Feb 2008
Posts: 5
SendAddonMessage?

I have a slight issue with my mod atm and I'm hoping somebody can help as it's just slightly out of my programming capabilities.

Basically my mod automatically replies to specific keywords in Trade, however there is so many of us using the mod now that it creates spam due to 5-10 people automatically replying to the keyword at the same time.

I'd like to lessen the resulting spam so I'm wondering if there's some way I can have the addons communicate with each other so only one person will respond. I'd like to use a hidden channel as this way the sync will be global instead of guild/raid/party only as is my understanding with SendAddonMessage().

Here's my (modified) lua below. (Slakah, you might recognize some of it )
Code:
local rswears = 80;	-- 80%

local swears = { "swear1", "swear2" }

local time

local function CheckMsgMatch(msg, chatType, channel) 
local cooldown = (math.random(40, 70));
local roll = (math.random(1, 100));

-- SWEARS	
	for _, v in ipairs(swears) do
		if strmatch(strlower(msg), strlower(v))	then
			if not time or GetTime() > time then
				SendChatMessage("reported",chatType, nil, channel)
				DEFAULT_CHAT_FRAME:AddMessage("[Match:(" .. arg2 .. ": " .. strlower(v) .. ") CD:(" .. cooldown .. ") Roll:(" .. roll .. ")]", 0.0, 1.0, 0.0);
				time = floor(GetTime()) + cooldown
				return
			end
		end
	end
end

local f = CreateFrame("Frame")
f:RegisterEvent("CHAT_MSG_CHANNEL")
f:RegisterEvent("CHAT_MSG_BATTLEGROUND") 
f:SetScript("OnEvent", function (self, event, msg, arg2, _, _, _, _, _, channel, channame)
	if (ReportedDB.MonitorTrade == true) then
		if (event == "CHAT_MSG_CHANNEL") and (channame == "Trade - City") then
			CheckMsgMatch(msg, "CHANNEL", channel)
		end
	end
end)
  Reply With Quote
02-20-09, 09:57 AM   #2
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
SendAddOnMessage() only works with the hidden addon comm channel, which only communicates between guild/group. If you want it to be more widespread than that, then you'll need to create a new chat channel, make sure it stays hidden from the user, use SendChatMessage() and have your addon monitor that channel, etc, etc. It's a pain in the butt, so I hear. But that's the extent of my knowledge.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
02-20-09, 10:06 AM   #3
Tuhljin
A Flamescale Wyrmkin
 
Tuhljin's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2008
Posts: 106
You can also send addon messages over the WHISPER channel, but then of course you'd have to have a way to know which players to whisper.
  Reply With Quote
02-20-09, 10:14 AM   #4
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
I knew I was forgetting one.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
02-20-09, 10:20 AM   #5
weaselSR
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Feb 2008
Posts: 5
Yeah that's the limitation I wanted to avoid, and thought I could use SendChatMessage() to a "hidden" channel that would communicate the needed data but I couldn't find a mod that uses anything similar to look over.
  Reply With Quote
02-20-09, 11:35 AM   #6
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
That's mainly because when SendAddOnMessage became available, most authors switched to using that. But I'm sure there's still something out there that uses it.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » SendAddonMessage?


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off