Thread Tools Display Modes
04-27-13, 04:32 PM   #1
bsmorgan
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 219
Help with Calendar API

I'm attempting to create an addon that will remove (or report and remove) the latest rash of gold calendar spam. The Calendar API looks like it has all the functions necessary but what I have written so far isn't working reliably.

My first question is can this be done without event handlers? If not, can someone outline how to iterate through all the calendar entries or all the calendar entries that are pending?

Thanks!

Brad
  Reply With Quote
04-27-13, 04:41 PM   #2
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
Why would you want to avoid event handlers at all? They're likely to be pretty essential.
  Reply With Quote
04-27-13, 04:50 PM   #3
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,360
I don't have an answer to your specific question but one request I would make is to avoid forcing Calendar to load early.

Either by using Deps in your .toc or by using LoadAddOn() in .lua.

Prefer instead to monitor for it loading normally and initialize your addon then, or delay your check for at least a few seconds (5-10) after PLAYER_LOGIN if you prefer to load it forcibly.

Loading it early causes all sorts of problems with events and I expect your addon if it makes release to be rather popular.
(I had gold seller calendar spam until the end of 2013 recently, had to manually report each one)

Best to start properly at the start than have to go back and refactor your code later.
  Reply With Quote
04-28-13, 12:39 PM   #4
bsmorgan
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 219
Originally Posted by Haleth View Post
Why would you want to avoid event handlers at all? They're likely to be pretty essential.
I have two example addons (neither of which work). One uses ACE and event handlers, the other has no event handlers. I also have an example macro that is supposed to work but needs to be edited for the specific spam (title).

I don't have much experience with ACE so I asked about doing this without event handlers as that would be the simpler addon to start with. Since it appears that event handlers will be necessary, I'll move in that direction.

Drizit, Thanks for the advice. Can you think of an addon that monitors for the loading of a Blizzard addon? I'm a huge fan of code reuse and coding by example!

Last edited by bsmorgan : 04-28-13 at 12:43 PM.
  Reply With Quote
04-28-13, 12:42 PM   #5
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
If you want your addon to do something in response to something else happening, you either need to
  1. register for an event and listen for it
  2. hook functions
Number 1 is usually way better than number 2.

I don't know what your "example addon" is or what it does or how it does it, but...

Also, FYI, your macro is also doing something in response to something else happening. Except you're triggering it manually instead of it doing it automatically, no? (Again, I have no idea what your macro is...)
__________________
"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
04-28-13, 02:53 PM   #6
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,360
Checking for the calendar loading normally can be done like this

Lua Code:
  1. local eventframe = CreateFrame("Frame")
  2. eventframe.OnEvent = function(self,event,...)
  3.   return eventframe[event] and eventframe[event](...)
  4. end
  5. eventframe:SetScript("OnEvent",eventframe.OnEvent)
  6.  
  7. local AwesomeDespamFunction = function()
  8.   -- do whatever I need to do to remove spam
  9. end
  10.  
  11. eventframe.ADDON_LOADED = function(addon)
  12.   if addon == "Blizzard_Calendar" then
  13.     AwesomeDespamFunction()
  14.     eventframe:UnregisterEvent("ADDON_LOADED")
  15.   end
  16. end
  17. if IsAddOnLoaded("Blizzard_Calendar") then
  18.   AwesomeDespamFunction()
  19. else
  20.   eventframe:RegisterEvent("ADDON_LOADED")
  21. end
The macro you have would be a good starting point for the AwesomeDespamFunction.
You'd have to use the API to detect the calendar events you want to remove.

Example: Remove any events that are not posted from someone on your guild or friendlist would be an option.
Example2: Hooking the existing Report function and removing all events posted from same player instead of user having to do each one manually.
(or adding an extra item in the event dropdown, "Clear spam")
Or make it a user option.

For starters as a user I'd be happy with either.
a. Use events to detect when something changed in calendar and automatically remove any events that weren't posted by guild/friends.
b. Add an item to the context menu that allows me to mass-remove events from a specific creator.

Last edited by Dridzt : 04-28-13 at 02:55 PM.
  Reply With Quote
05-12-13, 02:19 PM   #7
bsmorgan
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 219
I have an alpha version of "Calendar Spam Remove" and would like some other people to test it.

Send me a private message and I'll return instructions on how to download. I expect everyone that sends me a message is willing to ask questions and provide suggestions, criticisms, bug reports, etc.

I'm going to start with a small group of testers and add people as the addon progresses.

Brad

Last edited by bsmorgan : 05-12-13 at 02:22 PM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Help with Calendar API


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