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
02-20-09, 12:21 PM   #7
Akryn
A Firelord
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 479
A really old version of CTRA?
  Reply With Quote
02-20-09, 01:34 PM   #8
weaselSR
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Feb 2008
Posts: 5
What about just joining a channel, and then getting the list of names from the channel and using that in combination with SendAddonMessage() WHISPER?
  Reply With Quote
02-20-09, 01:51 PM   #9
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
You'd still need to create that channel and have users be in that channel, thus defeating the purpose.
__________________
"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, 05:54 PM   #10
Tuhljin
A Flamescale Wyrmkin
 
Tuhljin's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2008
Posts: 106
Originally Posted by weaselSR View Post
What about just joining a channel, and then getting the list of names from the channel and using that in combination with SendAddonMessage() WHISPER?
I wrote a library that gets a list of users from a chat channel, then sends addon whispers to all its members. Only users with your addon will whisper back, and those that do get added to an internal list of people to whisper. I use it with my addon ZoneDefense. (The library doesn't actually join the channel for you, though, since that's not its purpose.) But, as Seerah said, if you don't want to use a chat channel at all, this might not be ideal for you. It's useful for me because even though it doesn't eliminate using a channel, it at least lets you use that channel for normal communication still, and not everyone in the channel needs to have your addon.
  Reply With Quote
02-21-09, 05:28 AM   #11
weaselSR
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Feb 2008
Posts: 5
Using the chat channel is fine either way as it can be hidden fairly easily, I was just trying to think of a good way to get the list of people using the mod and being able to use the simpler method of SendAddonMessage() at the same time.
  Reply With Quote
02-21-09, 01:04 PM   #12
twobits
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Nov 2008
Posts: 38
Have it wait a random # of seconds, then have it look for other versions of itself to have replied in the time frame, that way its own messages are the IPC.
  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