dorzki / slack-notifications

Get WordPress notifications to your team's Slack channel.
https://wordpress.org/plugins/dorzki-notifications-to-slack/
GNU General Public License v3.0
41 stars 27 forks source link

Struggling to find a way to fire the 'send_message' function manually #46

Closed adamcollingburn closed 4 years ago

adamcollingburn commented 4 years ago

As above, I'd like to be able to create my own slack messages from my custom functions but struggling to find a way to do this

DorZuberi commented 4 years ago

Hi Adam, You can do something like that:

Slack_Bot::get_instance()->send_message( $message, $attachments, $args );
adamcollingburn commented 4 years ago

Thanks Dorzki - I tried this and just get Class Slack_Bot could not be found

adamcollingburn commented 4 years ago

So I tried to include 'core/class-slack-bot.php' and it says the class is already in use 😅

DorZuberi commented 4 years ago

Don't forget to add the namespace at the top.of the file:

use Slack_Notifications\Slack_Bot;

Or add the namespace before the class name:

Slack_Notifications\Slack_Bot::get_instance()->send_message( $message, $attachments, $args );
adamcollingburn commented 4 years ago

Thanks!

Do you know why it'd always be posting to the default channel? I've tried

['channel' => '#artists'] and ['channel' => 'artists']

in $args param and it still just posts to the default channel

adamcollingburn commented 4 years ago

@dorzki Any thoughts on this? Do I need to find a channel ID or something?

adamcollingburn commented 4 years ago

@DorZuberi Any idea?

DorZuberi commented 4 years ago

Hi @adamcollingburn , Sorry for the late reply, I'm a bit packed up at work.

About your question, Slack have changed the way Webhook works. I will release soon an update to address this issue.

adamcollingburn commented 4 years ago

Okay thanks dude

DorZuberi commented 4 years ago

I'm closing this issue because the main question was answered. You may open a new issue about the wrong channel.

adamcollingburn commented 3 years ago

Hey @DorZuberi,

Are you any closer to releasing an update for the webhook issue?