• Welcome to Simple Machines Community Forum. Please login or sign up.
October 26, 2021, 06:28:39 PM

News:

Want to get involved in developing SMF, then why not lend a hand on our github!


Discord Web Hooks

Started by vbgamer45, October 21, 2018, 12:26:05 PM

Previous topic - Next topic

vbgamer45

Link to Mod

Adds support for posting of new topics and messages to discord.
Also supports posting when a new user registers.

You can customize the messages posted for these actions, along with the name of the bot that posts the message.
Video demo: https://softwaredemos.tinytake.com/sf/MjkxMDYwMV84NzMyNzM0

Uses either cURL or fsockopen to make the post.

Changelog


2.0.1
+Pretty Urls support on messages posted to discord

2.0
+Added options to set custom discord post urls on a board level

1.0.2
!Fixed message link in postings to include anchor links.
!Fixed case of username guest language string not being loaded.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Rock Lee Code

Oh it seems interesting I'm going to try it, great job @vbgamer45!


Regards!
¡Regresando como cual Fenix! ~ Bomber Code © 2020
Ayudas - Aportes - Tutoriales - Y mucho mas!!!

moyack

Awesome mod!! could be added the option in the profile settings to add the discord username so it can be set in the in the automated messages?

vbgamer45

So it would just appear in the message? As an option.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

moyack

Quote from: vbgamer45 on October 24, 2018, 08:52:04 AM
So it would just appear in the message? As an option.
Yes, something like that :D

BTW, could it be possible, when someone make a new topic, that the discord message shows the canonical url instead the recent one.

vbgamer45

Possible like the main url to the topic?
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

moyack

Quote from: vbgamer45 on November 07, 2018, 01:16:52 PM
Possible like the main url to the topic?
That's right. This could help to show better the topic link in the discord chat. In my forum it will show the page with description and image preview now that I use Open Graph tags.

efk

Quote from: moyack on October 23, 2018, 04:31:53 PM
Awesome mod!! could be added the option in the profile settings to add the discord username so it can be set in the in the automated messages?
Sounds like a really nice mod, will try it in next days.

moyack

I just noticed a bug but I think it's not totally caused by the mod. When I post a message it shows in discord the link in the wrong way:
right link: http://wc3modding.info/5531/2-pirate-coasts/msg41393/#msg41393 or it should be:
link shown in discord: http://wc3modding.info/index.php?topic=5531.msg=41393

I think it's caused by the usage of SEF in my site. I use portamx SEF to make links more friendly. Any idea about how to fix it?

Thanks in advance

vbgamer45

The code in sources/discord2.php needs to be updated to support portamx SEF I would ask them if they have  a function to turn into an seo link.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

moyack

I did some modifications to handle canonical url and show properly special characters in the discord channel.

find:
$message = str_replace("(username)",$username,$message);
$message = str_replace("(title)",$row['subject'],$message);
$message = str_replace("(board)",$row['name'],$message);
$message = str_replace("(url)",$scripturl . '?topic=' . $row['id_topic'] . '.msg=' . $messageid,$message);


Replace with:
$message = str_replace("(username)",$username,$message);
$message = str_replace("(title)",$row['subject'],$message);
$message = str_replace("(board)",$row['name'],$message);
$message = str_replace("(can_url)",$scripturl . '?topic=' . $row['id_topic'] . '.0',$message); // this one allows canonical url...
$message = str_replace("(url)",$scripturl . '?topic=' . $row['id_topic'] . '.msg=' . $messageid,$message);
$message = html_entity_decode($message, ENT_QUOTES | ENT_XML1, 'UTF-8');


The html_entity_decode function was needed because I put this text in the discord settings in your mod:

Quote@(username) wrote a new post *(title)* - __(url)__ on *(board)* board. As Illidan says, this is a "Child's Play"
and it showed in discord in this way:

Quote@moyack wrote a new post Re: A new TESH Syntax Highlighter for Warcraft 3 - http://wc3modding.info/index.php?topic=5436.msg=41399 on WC3 Editing Tools board. As Illidan says, this is a "Child's Play"

vbgamer45

Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

vbgamer45

Update
1.0.1
!Fixed entity issue with discord message posts thanks to moyack
+Added (can_url) variable to handle canonical url thanks to moyack
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

moyack

Quote from: vbgamer45 on December 09, 2018, 09:34:13 PM
Update
1.0.1
!Fixed entity issue with discord message posts thanks to moyack
+Added (can_url) variable to handle canonical url thanks to moyack

Glad to help :)

If I manage to add the integration with PortaMX, I'll share this modification. This could lead into other integrations with other SEF...

Arantor

Um, that isn't the right url format, it isn't topic=123.msg=456 in stock SMF.

As for SEF, most of them work off hacking the sess_rewrite buffer.
No good deed goes unpunished
All helpful urges should be circumvented

vbgamer45

1.0.1a
+Added support for SMF 2.1.x
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

SugarD-x

Quote from: vbgamer45 on February 24, 2019, 10:37:42 AM
1.0.1a
+Added support for SMF 2.1.x
Just a heads up, in SMF 2.1 RC2, it is still reporting the version number as being 1.0.1 and not 1.0.1a.

shaggyze

For some reason or another it seems as though Discord Web Hooks has installed twice to my smf board but only one appears in installed packages because when a new post is made it gets sent to discord twice so i was wondering what file i would have to edit to remove the double send.

uotiara.com/img/2019-06-11_12-42-41.png

also the link that gets sent to discord is the wrong link for my smf version i guess so i also need to know the file to edit that as well.

mabimods.net/index.php?topic=10456.msg=252115

should be

mabimods.net/index.php?topic=10456.msg252115#msg252115

vbgamer45

Upload package to https://www.smfhacks.com/smf-package-parser.html
And check the file edits are applied only once.


For the second you would need to edit sources/discord2.php
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

shaggyze

June 11, 2019, 05:26:13 PM #19 Last Edit: June 11, 2019, 05:41:40 PM by shaggyze
getting an error saying package-info.xml not found! when uploading
puu.sh/DEJlX/d1f571659d.zip
though it does contain package-info.xml and i did use the right smf version when uploading it, however i did open the zip as soon as it downloaded to desktop an extracted your original .zip into a folder due to just plain lazyness an created a new .zip on desktop from that folder in which i installed... so that may have been the reason/problem to begin with, which as i said i think i may have installed it twice somehow...
(might have deleted it without uninstalling it)

each time i try uninstalling and reinstalling it still posts to discord twice so i'm not sure what i can do to fix the mistake already made.

using your original zip on smfhacks.com/smf-package-parser.html worked without an error so i'll try uninstalling and reinstalling the correct package here in a minute

Edit:
using your original package still results in double posts so need to find the file that was edited that probably now has two crucial edits causing it to be posted twice.

Advertisement: