[3.2][BETA] Telegram Notifications

A place for Extension Authors to post and receive feedback on Extensions still in development. No Extensions within this forum should be used within a live environment!
Ideas Centre
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: Extensions Development rules

IMPORTANT FOR NEEDED EVENTS!!!
If you need an event for your extension please read this for the steps to follow to request the event(s)
lassik
Registered User
Posts: 15
Joined: Thu Jul 27, 2017 11:16 am

[3.2][BETA] Telegram Notifications

Post by lassik » Thu Jul 27, 2017 11:34 am

Extension Name: Telegram Notifications
Author: lassik

Extension Description: Notify on Telegram whenever someone posts on phpBB
Extension Version: 0.3.0 (BETA)

Features: Adds a panel to the ACP where you can type in the Auth Token of your Telegram bot and the Chat ID of the Telegram chat where to send notifications. The extension will then send a short notification message to the Telegram chatroom whenever someone makes a post on your phpBB forum. The notifications look like this:
Telegram Bot wrote: [lassik] Quote: Title of the topic
Extension Download: https://github.com/lassik/phpbb-ext-tel ... _0_3_0.zip

Extension GitHub Page:: https://github.com/lassik/phpbb-ext-tel ... ifications
Last edited by lassik on Mon Sep 18, 2017 1:33 pm, edited 9 times in total.

lassik
Registered User
Posts: 15
Joined: Thu Jul 27, 2017 11:16 am

Re: [3.2][ALPHA] Telegram Notifications

Post by lassik » Thu Jul 27, 2017 12:00 pm

This extension works and it's in daily use on a small forum of ours. It also passes almost all of the EPV (extension prevalidator) checks. But polish is lacking:
  • The ACP language translations (L_WHATEVER) do not work. I couldn't figure out why.
  • I'm using PHP's curl API to access Telegram via HTTPS. Is it OK to rely on curl?
  • This is my first PHP and phpBB project, so I'm afraid the coding style is far from exemplary.
  • There isn't yet a ready-to-download zip file, one must clone the Git repo to install it.
If someone would like to help get this polished to the point where it's acceptable to submit to the extension database, I'd be very happy. Until then, it's perfectly usable as-is, just a little more difficult to set up. Also, if someone other than me wants to be the long-term maintainer, that's even better :D I just wanted to get the job done because our club needed this.

User avatar
kasimi
Extension Customisations
Extension Customisations
Posts: 2190
Joined: Sat Sep 10, 2011 7:12 pm
Location: Germany
Contact:

Re: [3.2][ALPHA] Telegram Notifications

Post by kasimi » Thu Jul 27, 2017 12:20 pm

The add_lang() method is from 3.1 and doesn't work with extensions:
https://github.com/lassik/phpbb-ext-tel ... le.php#L20

Try using 3.2's language service instead: https://area51.phpbb.com/docs/dev/32x/e ... age-object

Code: Select all

global $phpbb_container;
$lang = $phpbb_container->get('language');
$lang->add_lang('common', 'lassik/telegramnotifications');
lassik wrote:
Thu Jul 27, 2017 12:00 pm
Is it OK to rely on curl?
Yes it is, as long as it doesn't break the board if cURL isn't available. :)

User avatar
david63
Jr. Extension Validator
Posts: 13143
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Name: David Wood
Contact:

Re: [3.2][ALPHA] Telegram Notifications

Post by david63 » Thu Jul 27, 2017 12:24 pm

lassik wrote:
Thu Jul 27, 2017 12:00 pm
There isn't yet a ready-to-download zip file, one must clone the Git repo to install it.
Creating a "Release" on Github will automatically create a .zip for you.
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored

lassik
Registered User
Posts: 15
Joined: Thu Jul 27, 2017 11:16 am

Re: [3.2][ALPHA] Telegram Notifications

Post by lassik » Thu Jul 27, 2017 1:42 pm

Thanks for the extremely quick feedback! I made the suggested changes and pushed to GitHub.
kasimi wrote:
Thu Jul 27, 2017 12:20 pm
Try using 3.2's language service instead: https://area51.phpbb.com/docs/dev/32x/e ... age-object
Got this to work. Except for one part: The ACP's EXTENSIONS tab still shows "ACP_TELEGRAM_NOTIFICATIONS" instead of "Telegram Notifications" (what ACP_TELEGRAM_NOTIFICATIONS expands to) as the category title in the left sidebar.
kasimi wrote:
Thu Jul 27, 2017 12:20 pm
lassik wrote:
Thu Jul 27, 2017 12:00 pm
Is it OK to rely on curl?
Yes it is, as long as it doesn't break the board if cURL isn't available. :)
I added a check for function_exists('curl_version')
david63 wrote:
Thu Jul 27, 2017 12:24 pm
Creating a "Release" on Github will automatically create a .zip for you.
I'm ready to make a release. But will the directory structure be appropriate if the "acp", "adm", "config" etc. directories are at the top level of the zip file (as GitHub will make it) - or should all of that stuff be in a subdirectory inside the zip file? If so, what's the customary way to solve this problem if I want to keep the Git repo's directory structure as-is?

User avatar
david63
Jr. Extension Validator
Posts: 13143
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Name: David Wood
Contact:

Re: [3.2][ALPHA] Telegram Notifications

Post by david63 » Thu Jul 27, 2017 2:07 pm

lassik wrote:
Thu Jul 27, 2017 1:42 pm
But will the directory structure be appropriate
Creating a release will sort out the correct directory structure - just try it and see - you can always delete it if it not what you want.
lassik wrote:
Thu Jul 27, 2017 1:42 pm
The ACP's EXTENSIONS tab still shows "ACP_TELEGRAM_NOTIFICATIONS" instead of "Telegram Notifications"
You need to have those language variables in an info_acp_namespace.php file
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored

lassik
Registered User
Posts: 15
Joined: Thu Jul 27, 2017 11:16 am

Re: [3.2][ALPHA] Telegram Notifications

Post by lassik » Thu Jul 27, 2017 2:36 pm


lassik
Registered User
Posts: 15
Joined: Thu Jul 27, 2017 11:16 am

Re: [3.2][ALPHA] Telegram Notifications

Post by lassik » Thu Jul 27, 2017 3:26 pm

Should I just submit that zipfile to the customization database and fix any EPV issues, or do you want to pre-check it from GitHub first?

User avatar
david63
Jr. Extension Validator
Posts: 13143
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Name: David Wood
Contact:

Re: [3.2][ALPHA] Telegram Notifications

Post by david63 » Thu Jul 27, 2017 5:57 pm

I would suggest that before you even consider submitting it to the CDB that you review the phpBB coding guidelines as there are several parts of your code that do not comply.
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored

lassik
Registered User
Posts: 15
Joined: Thu Jul 27, 2017 11:16 am

Re: [3.2][ALPHA] Telegram Notifications

Post by lassik » Tue Aug 01, 2017 2:46 pm

I read the entire coding guidelines document and made the following fixes:
  • Use tabs for indentation.
  • Do not forget to comment the functions.
  • Do not forget to comment the class.
  • Classes need a separate @package definition.
  • Always include the braces.
  • Where to put the braces.
  • Commas after every array element.
Commit log on GitHub: https://github.com/lassik/phpbb-ext-tel ... its/master

lassik
Registered User
Posts: 15
Joined: Thu Jul 27, 2017 11:16 am

Re: [3.2][BETA] Telegram Notifications

Post by lassik » Wed Aug 02, 2017 7:30 am

Just posted the first zip file ready for testing (EDIT: well, the second one after the previous attempt to generate one automatically from GitHub - this one has proper subdirectories): https://github.com/lassik/phpbb-ext-tel ... s_HEAD.zip

One thing - I now send HTML-formatted Telegram messages so I can have the topic titles be clickable links instead of showing the long post URL directly in the message. This causes EPV to complain about the use of the htmlspecialchars() function (which I use to escape the HTML before sending it to the Telegram API). What function should I use instead to do the escaping? The relevant lines of source code are: https://github.com/lassik/phpbb-ext-tel ... hp#L58-L62

romeo_piter
Registered User
Posts: 78
Joined: Mon Nov 09, 2009 7:11 pm
Location: Russia
Contact:

Re: [3.2][BETA] Telegram Notifications

Post by romeo_piter » Wed Aug 02, 2017 3:34 pm

Will this ext work in 3.1?

User avatar
potku
Registered User
Posts: 705
Joined: Wed Dec 22, 2004 10:26 pm
Location: Tampere, Finland
Contact:

Re: [3.2][BETA] Telegram Notifications

Post by potku » Thu Aug 03, 2017 8:14 am

This seems interesting! :)

Since I know nothing about Telegram bots, where can that chat ID be found? Or how is that chat created, I guess... :D I did create a bot and received that token.
Potku.net

"Before I speak, I have something important to say."

- Groucho Marx

lassik
Registered User
Posts: 15
Joined: Thu Jul 27, 2017 11:16 am

Re: [3.2][BETA] Telegram Notifications

Post by lassik » Thu Aug 03, 2017 9:53 am

Thanks for your interest :)
romeo_piter wrote:
Wed Aug 02, 2017 3:34 pm
Will this ext work in 3.1?
Nope, sorry. 3.2 only.
potku wrote:
Thu Aug 03, 2017 8:14 am
where can that chat ID be found? Or how is that chat created, I guess... :D
You invite your bot to an existing group chat (the one where you want the bot to send notifications about new posts). Then input the chat ID of that group chat into the phpBB ACP. Unfortunately the chat ID is a bit tricky to find. Can you manage with these instructions? https://stackoverflow.com/a/32572159

User avatar
potku
Registered User
Posts: 705
Joined: Wed Dec 22, 2004 10:26 pm
Location: Tampere, Finland
Contact:

Re: [3.2][BETA] Telegram Notifications

Post by potku » Thu Aug 03, 2017 10:50 am

Thanks for the link. I did have a look at couple of those before, but I really have always found Stackoverflow's UI very...different, to be polite. :D It's a shame I cannot stand it because there is a lot of information there.

However, I did some digging around. I should be at a point where that ID is the only thing missing. Is it the one with a negative sign in front of it (I read that for groups it's like that)?

Code: Select all

{"ok":true,"result":[{"update_id":xxxxxxx,
"message":{"message_id":4,"from":{"id":xxxxxx,"first_name":"xxxxx","language_code":"fi-FI"},"chat":{"id":-xxxxxx,"title":"Potku.net","type":"group","all_members_are_administrators":true},"date":1501756766,"text":"/register","entities":[{"type":"bot_command","offset":0,"length":9}]}}]}
EDIT: I think it must be. In that case, the bot is not delivering messages to the group. But since this EXT does work, we must have done something wrong...
Potku.net

"Before I speak, I have something important to say."

- Groucho Marx

Post Reply

Return to “Extensions in Development”

Who is online

Users browsing this forum: accs-p, BadBlock, nou nou, PhilDiscuss and 24 guests

cron