Mass message

General discussion on Budabot.
User avatar
Rosss
Member
Posts: 115
Joined: Tue Dec 29, 2009 1:10 pm

Mass message

Postby Rosss » Thu Aug 18, 2016 7:07 am

Hi guys!

Is there a !massmsg command floating around out there? Or some other way to send tell to all online members?

Thanks!
Tyrence
The Team
Posts: 1883
Joined: Sat Jan 09, 2010 1:32 am

Re: Mass message

Postby Tyrence » Thu Aug 18, 2016 8:44 am

Try !tellall -- it may or may not exist in your bot, depending on which version you are running.

It exists in older versions of Budabot but it was used so little that I removed it in newer versions.
"Those who expect to reap the blessings of freedom, must, like men, undergo the fatigues of supporting it." — Thomas Paine
"Nearly all men stand adversity, but if you want to test a man's character, give him power." — Abraham Lincoln
Budabot Releases and Downloads: https://github.com/Budabot/Budabot/releases
User avatar
Rosss
Member
Posts: 115
Joined: Tue Dec 29, 2009 1:10 pm

Re: Mass message

Postby Rosss » Thu Aug 18, 2016 5:03 pm

Using newest release now, so it's not there. Doh! I'll keep snooping around and see if I can migrate/add that older functionality :D
User avatar
Rosss
Member
Posts: 115
Joined: Tue Dec 29, 2009 1:10 pm

Re: Mass message

Postby Rosss » Thu Aug 18, 2016 6:28 pm

Code: Select all

   public function massmsgCommand($message, $channel, $sender, $sendto, $args) {
      $tellmsg = $args[1];
      $data = $this->db->query("SELECT name FROM online WHERE channel_type = 'priv'");
      forEach ($data as $row) {
         $this->chatBot->sendTell("Message from $sender: <yellow>$tellmsg<end>", $row->name);
      }

      $sendto->reply("Your message has been sent to all online bot members.");
   }


Noob code question. Trying to adjust the code from former !tellall command. How can I modify this so that it sends tell to all online bot members, instead of just those who are in the priv channel?
Tyrence
The Team
Posts: 1883
Joined: Sat Jan 09, 2010 1:32 am

Re: Mass message

Postby Tyrence » Thu Aug 18, 2016 6:34 pm

Try this. I just made this module based on the code for that command. I haven't tested it, but I'm pretty sure it will work.
Attachments
TELLALL_MODULE.zip
(935 Bytes) Downloaded 19 times
"Those who expect to reap the blessings of freedom, must, like men, undergo the fatigues of supporting it." — Thomas Paine
"Nearly all men stand adversity, but if you want to test a man's character, give him power." — Abraham Lincoln
Budabot Releases and Downloads: https://github.com/Budabot/Budabot/releases
User avatar
Rosss
Member
Posts: 115
Joined: Tue Dec 29, 2009 1:10 pm

Re: Mass message

Postby Rosss » Thu Aug 18, 2016 6:36 pm

Ah neat, thank you! I'm making you work too much at this point :) But is there a way to adjust it for raidbot use instead of guild use?
Tyrence
The Team
Posts: 1883
Joined: Sat Jan 09, 2010 1:32 am

Re: Mass message

Postby Tyrence » Thu Aug 18, 2016 7:13 pm

Oh in that case, the command should look like this:

Code: Select all

public function massmsgCommand($message, $channel, $sender, $sendto, $args) {
      $tellmsg = $args[1];
      $data = $this->db->query("SELECT * FROM members_<myname>");  // retrieve list of members
      forEach ($data as $row) {
         if ($this->buddylistManager->isOnline($row->name) == 1) {  // only send message if member is online
            $this->chatBot->sendTell("Message from $sender: <yellow>$tellmsg<end>", $row->name);
         }
      }

      $sendto->reply("Your message has been sent to all online bot members.");
   }


Since we are now using the buddylistManager, you also need to inject that into your controller:

Code: Select all

/** @Inject */
public $buddylistManager;


As a final note, the bot may become unresponsive while it sends these messages due to message rate limiting.
"Those who expect to reap the blessings of freedom, must, like men, undergo the fatigues of supporting it." — Thomas Paine
"Nearly all men stand adversity, but if you want to test a man's character, give him power." — Abraham Lincoln
Budabot Releases and Downloads: https://github.com/Budabot/Budabot/releases
User avatar
Rosss
Member
Posts: 115
Joined: Tue Dec 29, 2009 1:10 pm

Re: Mass message

Postby Rosss » Thu Aug 18, 2016 9:24 pm

Awesome! Thanks buddy. Had to fix a typo in the isOnline to is_Online, then worked like a charm!

Return to “General Discussion”

Who is online

Users browsing this forum: Bing [Bot] and 1 guest