ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   AddOn Help/Support (https://www.esoui.com/forums/forumdisplay.php?f=164)
-   -   Problem with guild mail (https://www.esoui.com/forums/showthread.php?t=4317)

Migoda 02/20/15 01:35 PM

Problem with guild mail
 
Hey fellow coders,

is there any working solution for sending a mass mail to all members of a guild without getting kicked for spam?

In my large trade guild (500 people), we are sending a news mail to our members from time to time. Using the mail function from TIM it stops after ~70 mails and the game kicks for spam.

Can this be avoided? Maybe with setting a delay between each mail?

katkat42 02/20/15 05:45 PM

Yes, that would probably work. I think MailR uses a 1-second delay by default.

Migoda 02/24/15 12:22 PM

I checked TIMs code and changed the function that processes the mail queue. Here is my solution:

Lua Code:
  1. function tim.sendQueuedMail()
  2.     if tim.mailQueueindex>0 then
  3.         -- EINEN MailQueue-Eintrag senden (pro Aufruf dieser Funktion)
  4.         local mailboxwasopen=tim.MailBoxOpen
  5.         if tim.MailBoxOpen==false then
  6.             RequestOpenMailbox()
  7.         end
  8.         tim.wait4mail=true
  9.         tim.MailInQueue=tim.mailQueue.mTO[tim.mailQueueindex]
  10.         tim.MailInQueueSUB=tim.mailQueue.mSUB[tim.mailQueueindex]
  11.         SendMail(tim.mailQueue.mTO[tim.mailQueueindex], tim.mailQueue.mSUB[tim.mailQueueindex], tim.mailQueue.mTEXT[tim.mailQueueindex])
  12.         if mailboxwasopen==false then
  13.             CloseMailbox()
  14.         end
  15.         tim.mailQueueindex=tim.mailQueueindex-1
  16.     end
  17. end

to

Lua Code:
  1. function tim.sendQueuedMail()
  2.   if tim.mailQueueindex>0 then
  3.       EVENT_MANAGER:RegisterForUpdate("tim_EVENT_EMAIL", tim.throttleTimerMail, function()
  4.         -- EINEN MailQueue-Eintrag senden (pro Aufruf dieser Funktion)
  5.         local mailboxwasopen=tim.MailBoxOpen
  6.         if tim.MailBoxOpen==false then
  7.           RequestOpenMailbox()
  8.         end
  9.         tim.wait4mail=true
  10.         tim.MailInQueue=tim.mailQueue.mTO[tim.mailQueueindex]
  11.         tim.MailInQueueSUB=tim.mailQueue.mSUB[tim.mailQueueindex]
  12.         SendMail(tim.mailQueue.mTO[tim.mailQueueindex], tim.mailQueue.mSUB[tim.mailQueueindex], tim.mailQueue.mTEXT[tim.mailQueueindex])
  13.         if mailboxwasopen==false then
  14.           CloseMailbox()
  15.         end
  16.         tim.mailQueueindex=tim.mailQueueindex-1
  17.         if tim.mailQueueindex==0 then
  18.           EVENT_MANAGER:UnregisterForUpdate("tim_EVENT_EMAIL")
  19.         end
  20.       end)
  21.     end
  22. end

Is that approach with RegisterForUpdate viable or is there a better way to add a simple delay?

Baertram 02/25/15 04:25 AM

I guess it is viable for the current source code as the function tim.sendQueuedMail() is called several times, once for each new guil member mail?

As an alternative you could delay the call to this function tim.sendQueuedMail(), use zo_callLater(tim.sendQueuedMail(), 500) or something like this.

With other addons I have seen sourc code where the EVENTS (crafting_finished e.g.) was the trigger to call the next process.
Maybe there is an event like "MAIL_HAS_BEEN_SENT" and you could use this one to send the next mail (+ delay in between.

Garkin 02/25/15 06:03 AM

Quote:

Originally Posted by Baertram (Post 19053)
I guess it is viable for the current source code as the function tim.sendQueuedMail() is called several times, once for each new guil member mail?

As an alternative you could delay the call to this function tim.sendQueuedMail(), use zo_callLater(tim.sendQueuedMail(), 500) or something like this.

With other addons I have seen sourc code where the EVENTS (crafting_finished e.g.) was the trigger to call the next process.
Maybe there is an event like "MAIL_HAS_BEEN_SENT" and you could use this one to send the next mail (+ delay in between.

* EVENT_MAIL_SEND_FAILED (*integer* _reason_)
* EVENT_MAIL_SEND_SUCCESS

Migoda 02/25/15 02:22 PM

Thanks for your inputs!

After digging a bit deeper in the code i figured out how TIM handles the mailing. tim.sendQueuedMail() is part of the update callback function (fired from OnUpdate), so one mail from the queue is sent every tick.

TIM uses a custom throttle function to control update ticks for special purposes. I ended up using this function in tim.sendQueuedMail() with my desired delay and it works.

Here is the final code:

Lua Code:
  1. function tim.sendQueuedMail()
  2.   if tim.mailQueueindex>0 then
  3.     if (tim.UpdateThrottle("SendQueuedMail", tim.throttleCountMail) == true) then
  4.       -- EINEN MailQueue-Eintrag senden (pro Aufruf dieser Funktion)
  5.       local mailboxwasopen=tim.MailBoxOpen
  6.       if tim.MailBoxOpen==false then
  7.         RequestOpenMailbox()
  8.       end
  9.       tim.wait4mail=true
  10.       tim.MailInQueue=tim.mailQueue.mTO[tim.mailQueueindex]
  11.       tim.MailInQueueSUB=tim.mailQueue.mSUB[tim.mailQueueindex]
  12.       SendMail(tim.mailQueue.mTO[tim.mailQueueindex], tim.mailQueue.mSUB[tim.mailQueueindex], tim.mailQueue.mTEXT[tim.mailQueueindex])
  13.       if mailboxwasopen==false then
  14.         CloseMailbox()
  15.       end
  16.       tim.mailQueueindex=tim.mailQueueindex-1
  17.     end
  18.   end
  19. end


All times are GMT -6. The time now is 05:25 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI