Advertisement:

Author Topic: Discord Web Hooks  (Read 1605 times)

Online vbgamer45

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 20,775
    • smfhacks on Facebook
    • VBGAMER45 on GitHub
    • @createaforum on Twitter
    • SMF For Free
Discord Web Hooks
« on: October 21, 2018, 12:26:05 PM »
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.

Uses either cURL or fsockopen to make the post.
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

Offline Rock Lee

  • Native Language Support Specialist
  • SMF Hero
  • *
  • Posts: 2,106
  • Gender: Male
  • I also speak english :D
    • BomberCode.Oficial on Facebook
    • RockLee-BC on GitHub
    • @Bomber_Code on Twitter
    • Bomber Code ~ La nueva era del conocimiento
Re: Discord Web Hooks
« Reply #1 on: October 21, 2018, 08:04:48 PM »
Oh it seems interesting I'm going to try it, great job @vbgamer45!


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


Ayudame via PayPal

Offline moyack

  • Semi-Newbie
  • *
  • Posts: 47
  • Gender: Male
  • Bootstrap FTW!!
Re: Discord Web Hooks
« Reply #2 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?

Online vbgamer45

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 20,775
    • smfhacks on Facebook
    • VBGAMER45 on GitHub
    • @createaforum on Twitter
    • SMF For Free
Re: Discord Web Hooks
« Reply #3 on: October 24, 2018, 08:52:04 AM »
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

Offline moyack

  • Semi-Newbie
  • *
  • Posts: 47
  • Gender: Male
  • Bootstrap FTW!!
Re: Discord Web Hooks
« Reply #4 on: November 07, 2018, 12:36:51 PM »
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.

Online vbgamer45

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 20,775
    • smfhacks on Facebook
    • VBGAMER45 on GitHub
    • @createaforum on Twitter
    • SMF For Free
Re: Discord Web Hooks
« Reply #5 on: November 07, 2018, 01:16:52 PM »
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

Offline moyack

  • Semi-Newbie
  • *
  • Posts: 47
  • Gender: Male
  • Bootstrap FTW!!
Re: Discord Web Hooks
« Reply #6 on: November 10, 2018, 01:30:34 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.

Offline efk

  • Jr. Member
  • **
  • Posts: 143
  • Gender: Male
Re: Discord Web Hooks
« Reply #7 on: November 11, 2018, 01:21:35 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.

Offline moyack

  • Semi-Newbie
  • *
  • Posts: 47
  • Gender: Male
  • Bootstrap FTW!!
Re: Discord Web Hooks
« Reply #8 on: November 23, 2018, 08:53:11 PM »
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

Online vbgamer45

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 20,775
    • smfhacks on Facebook
    • VBGAMER45 on GitHub
    • @createaforum on Twitter
    • SMF For Free
Re: Discord Web Hooks
« Reply #9 on: November 23, 2018, 09:12:09 PM »
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

Offline moyack

  • Semi-Newbie
  • *
  • Posts: 47
  • Gender: Male
  • Bootstrap FTW!!
Re: Discord Web Hooks
« Reply #10 on: December 09, 2018, 08:13:32 PM »
I did some modifications to handle canonical url and show properly special characters in the discord channel.

find:
Code: [Select]
$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:
Code: [Select]
$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"

Online vbgamer45

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 20,775
    • smfhacks on Facebook
    • VBGAMER45 on GitHub
    • @createaforum on Twitter
    • SMF For Free
Re: Discord Web Hooks
« Reply #11 on: December 09, 2018, 08:46:54 PM »
Nice good tip!
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

Online vbgamer45

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 20,775
    • smfhacks on Facebook
    • VBGAMER45 on GitHub
    • @createaforum on Twitter
    • SMF For Free
Re: Discord Web Hooks
« Reply #12 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
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

Offline moyack

  • Semi-Newbie
  • *
  • Posts: 47
  • Gender: Male
  • Bootstrap FTW!!
Re: Discord Web Hooks
« Reply #13 on: December 10, 2018, 01:53:08 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...

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 69,912
    • StoryBB/StoryBB on GitHub
Re: Discord Web Hooks
« Reply #14 on: December 10, 2018, 02:15:06 PM »
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.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.