[ABD] Discord Notifications -- send messages to Discord to report forum events

Any abandoned Extensions will be moved to this forum.

WARNING: Extensions in this forum are not currently being supported or maintained by the original Extension author. Proceed at your own risk.
Forum rules
IMPORTANT: Extension Development Forum rules

WARNING: Extensions in this forum are not currently being supported nor updated by the original Extension author. Proceed at your own risk.
nou nou
Registered User
Posts: 389
Joined: Sat Oct 29, 2016 8:08 pm

Re: [3.2][RC] Discord Notifications -- send messages to Discord to report forum events

Post by nou nou » Sat Dec 22, 2018 2:30 am

This works really great, thank you for developing!

I've found one issue. I only have Discord notification on for the creation of Topics and Posts. Anything else is turned off.

When a new post is created by quoting another (quote rather than reply button) no notification is sent to Discord, even though a new post is created (the quote).

Bug? Or by design?

User avatar
jackennils
Registered User
Posts: 214
Joined: Mon Jun 01, 2009 7:48 pm

Re: [3.2][RC] Discord Notifications -- send messages to Discord to report forum events

Post by jackennils » Sat Dec 22, 2018 7:32 pm

Thank you for all the work!

Here's the German translation:
https://drive.google.com/open?id=18_zk1 ... sGOQMAKgIq

;)

SinusVonAlpha
Registered User
Posts: 17
Joined: Sat Nov 10, 2018 1:15 pm

Re: [3.2][RC] Discord Notifications -- send messages to Discord to report forum events

Post by SinusVonAlpha » Thu Dec 27, 2018 11:28 pm

Kacer wrote:
Sat Dec 08, 2018 8:29 pm
Heyya I would like to gratefully thank you about your splendid work! The bot works fine and does what it intends to do.

I may ask a little too much but I would like to suggest a feature.
The intention is to use this extension with multiple webhooks towards multiple discord channels, making it "expandable".
Currently the bot sends everything to one discord channel

Here's an example:
Forum Announcement webhook bot -> Fetches only the Forum "Announcement" category/section and sends it to the f.ex. #general discord channel
Forum Report webhook bot -> Fetches only the Forum "Report" category/section and sends it to the f.ex. #report discord channel

As it is for now, it works perfectly fine :)
This would be a great feature - I really hope you find the time to work on this sometime in the future!

AlvoErrado2
Registered User
Posts: 13
Joined: Fri May 04, 2012 7:24 pm
Name: Antonio R.

Re: [3.2][RC] Discord Notifications -- send messages to Discord to report forum events

Post by AlvoErrado2 » Wed Jan 09, 2019 9:26 pm

SinusVonAlpha wrote:
Thu Dec 27, 2018 11:28 pm
Kacer wrote:
Sat Dec 08, 2018 8:29 pm
Heyya I would like to gratefully thank you about your splendid work! The bot works fine and does what it intends to do.

I may ask a little too much but I would like to suggest a feature.
The intention is to use this extension with multiple webhooks towards multiple discord channels, making it "expandable".
Currently the bot sends everything to one discord channel

Here's an example:
Forum Announcement webhook bot -> Fetches only the Forum "Announcement" category/section and sends it to the f.ex. #general discord channel
Forum Report webhook bot -> Fetches only the Forum "Report" category/section and sends it to the f.ex. #report discord channel

As it is for now, it works perfectly fine :)
This would be a great feature - I really hope you find the time to work on this sometime in the future!
I would also like a function like that, would be quite useful for a situation I'm thinking about. :D

nou nou
Registered User
Posts: 389
Joined: Sat Oct 29, 2016 8:08 pm

Re: [3.2][RC] Discord Notifications -- send messages to Discord to report forum events

Post by nou nou » Fri Jan 11, 2019 8:12 am

How difficult would it be to be able to send notifications to several Discord servers at once?

Say you run a forum that is of interest to several different Discord groups...

User avatar
Nephthys Vasudan
Registered User
Posts: 3
Joined: Mon Jan 14, 2019 11:16 pm
Location: Eorzea
Name: Nephthys Vasudan

Re: [3.2][RC] Discord Notifications -- send messages to Discord to report forum events

Post by Nephthys Vasudan » Mon Jan 14, 2019 11:26 pm

I've been looking into ways where I can update my membership on our discord server without having to manually "news blast" the new topics and such from our PHPBB.

I saw your mod and I was wondering if there's a way for me to install this even though its not quite officially released?

Forgive my ignorance - Not very familiar with GitHub and such. :oops:

Thanks! :mrgreen:
Nephthys Vasudan - Adventurer Extraordinaire
Server Administrator for Dreadwyrm Academy


User avatar
Nephthys Vasudan
Registered User
Posts: 3
Joined: Mon Jan 14, 2019 11:16 pm
Location: Eorzea
Name: Nephthys Vasudan

Re: [3.2][RC] Discord Notifications -- send messages to Discord to report forum events

Post by Nephthys Vasudan » Thu Jan 17, 2019 3:25 am

Thanks - ill give this a try in the next day or so. :mrgreen:
Nephthys Vasudan - Adventurer Extraordinaire
Server Administrator for Dreadwyrm Academy

nou nou
Registered User
Posts: 389
Joined: Sat Oct 29, 2016 8:08 pm

Re: [3.2][RC] Discord Notifications -- send messages to Discord to report forum events

Post by nou nou » Thu Jan 17, 2019 3:01 pm

The other day I had a post that couldn't be sent to Discord for some reason, and it threw a PHP debug error. I wish I had copied the error, because so far I couldn't reproduce it.

The forum itself worked fine, though. The post was there, no other issues. Just the Discord post wasn't sent. I consider it just a glitch...

Anyway, what I am getting at is that it would be nice if errors would just be suppressed and show up in the error log, rather than being thrown. Since the forum works fine in and of itself and the Discord sends are in the background, I wouldn't want my users to think there is anything critically wrong...

User avatar
Nephthys Vasudan
Registered User
Posts: 3
Joined: Mon Jan 14, 2019 11:16 pm
Location: Eorzea
Name: Nephthys Vasudan

Re: [3.2][RC] Discord Notifications -- send messages to Discord to report forum events

Post by Nephthys Vasudan » Sun Jan 20, 2019 8:59 pm

Installed - works great!

Feature requests/ideas:
1: Is it possible to notify on Private Message GROUP..a specific group that is...some people do not check emails or bother to look.

2: Is it possible to limit notifications to specific groups that trigger posts/edits etc. In other words - it notifies if someone is in a specific group and not just the board itself.

EDIT:

3: Is it possible to specify which boards notify on edits/updates etc? Not just global switches. Or as an alternate - set up a 2nd web hook to notify on other things - etc. Sorry if i sound random. :oops:

Thanks. :mrgreen: :mrgreen:
Nephthys Vasudan - Adventurer Extraordinaire
Server Administrator for Dreadwyrm Academy

IceReaper9355
Registered User
Posts: 1
Joined: Tue Jan 22, 2019 8:17 pm

Re: [3.2][RC] Discord Notifications -- send messages to Discord to report forum events

Post by IceReaper9355 » Tue Jan 22, 2019 8:25 pm

So I read and tried using

Code: Select all

curl -H "Content-Type: application/json" -X POST -d '{"username": "Lunar Valley", "content": "Testing a new bot: https://example.ca/"}' https://discordapp.com/api/webhooks/537361159494434831/jT31avxRkM0sv6PgINolSVCMpep-2lVEZgxmLOgNzQSecUiM5WNeXpIEqdrkOh54nMFo
And it sent the messages successfully through the console, but when I click "Send Test Message" I get an HTTP ERROR 500.

I am hosted on Digital Ocean LAMP stack using a Lets Encrypt Certificate on a virtual apache host.

Board version: 3.2.5
PHP version: 7.2.10-0ubuntu0.18.04.1
Database server: MySQL(i) 5.7.24-0ubuntu0.18.04.1
Curl version: curl 7.58.0 (x86_64-pc-linux-gnu)

nou nou
Registered User
Posts: 389
Joined: Sat Oct 29, 2016 8:08 pm

Re: [3.2][RC] Discord Notifications -- send messages to Discord to report forum events

Post by nou nou » Fri Jan 25, 2019 1:15 am

Bug report! :)

The extension does not generate correct links to posts on topics with more than one page.

For example, it outputs

Code: Select all

https://www.forum.com/viewtopic.php?t=1411#p21695
which, if the topic is longer than one page, goes to the first post in the topic (because the anchor is not on the page).

Instead it should be

Code: Select all

https://www.forum.com/viewtopic.php?p=21695#p21695

Thanks!


EDIT: fixed this by editing the file notification_event_listener.php:

Find:

Code: Select all

	private function generate_post_link($topic_id, $post_id, $text)
	{
		$url = generate_board_url() . '/viewtopic.php?t=' . $topic_id . '#p' . $post_id;
		$url = $this->reformat_link_url($url);
		$text = $this->reformat_link_text($text);
		return sprintf('[%s](%s)', $text, $url);
	}
(line 887)

Replace with:

Code: Select all

	private function generate_post_link($topic_id, $post_id, $text)
	{
		$url = generate_board_url() . '/viewtopic.php?p=' . $post_id . '#p' . $post_id;
		$url = $this->reformat_link_url($url);
		$text = $this->reformat_link_text($text);
		return sprintf('[%s](%s)', $text, $url);
	}
Terrifically commented code, by the way! Thank you :)

nou nou
Registered User
Posts: 389
Joined: Sat Oct 29, 2016 8:08 pm

Re: [3.2][RC] Discord Notifications -- send messages to Discord to report forum events

Post by nou nou » Sun Jan 27, 2019 10:00 pm

nou nou wrote:
Thu Jan 17, 2019 3:01 pm
The other day I had a post that couldn't be sent to Discord for some reason, and it threw a PHP debug error. I wish I had copied the error, because so far I couldn't reproduce it.
It's a "cannot send empty message" error. I just had it again (and forgot to copy it) - but it is a rare occurrence... If anyone knows how to suppress the errors coming from Discord, that would be great... :)

nou nou
Registered User
Posts: 389
Joined: Sat Oct 29, 2016 8:08 pm

Re: [3.2][RC] Discord Notifications -- send messages to Discord to report forum events

Post by nou nou » Wed Jan 30, 2019 1:03 am

It happened again, here is the error message in question:

Code: Select all

{"code": 50006, "message": "Cannot send an empty message"}[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 1855: Cannot modify header information - headers already sent by (output started at [ROOT]/ext/roots/discordnotifications/notification_service.php:328)
Forum post is OK, but Discord message not sent. It's not a big deal if that's a glitch that can happen, but some error handling would be great to not freak out any users...

nou nou
Registered User
Posts: 389
Joined: Sat Oct 29, 2016 8:08 pm

Re: [3.2][RC] Discord Notifications -- send messages to Discord to report forum events

Post by nou nou » Tue Feb 05, 2019 7:30 am

Just to follow up on the above post...

I've managed to fix the phpBB Debug warnings issue by doing the following:

In notification_service.php, search for

Code: Select all

$response = curl_exec($h);
Before, add:

Code: Select all

curl_setopt($h, CURLOPT_RETURNTRANSFER, 1);
This returns the transfer as a string of the return value of curl_exec() instead of outputting (printing) it directly. I don't speak php, this is from manuals and Google - but so far so good! ;)

The underlying issue (i.e. bug) is that when there is a post that contains TABS, it throws that "cannot send empty message error" and the message doesn't get sent to Discord. I bet there's a relatively simple JSON formatting at the source of this. But again, I don't speak php so progress is (very) slow.

The forum that I am testing this with has a fair amount of posts containing (Lua) code. Something as simple as this:

Code: Select all

{
	ActiveTool = "Plasma1"
}
...borks the transfer to Discord, because of the TAB preceding ActiveTool.

Anyhoo - hoping this is helpful and can be verified and fixed properly, and if I can find the time for it I'll keep digging... :)

Locked

Return to “Abandoned Extensions”