[3.3][DEV] Telegram Bridge

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!
Scam Warning
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)
User avatar
darakhshan
Registered User
Posts: 1032
Joined: Fri Apr 30, 2004 7:18 pm

Re: [3.3][DEV] Telegram Bridge

Post by darakhshan »

mbld wrote: Thu Mar 16, 2023 6:03 pm
darakhshan wrote: Thu Mar 16, 2023 11:30 am Where can I find those permisions?
It's currently only in the develop-branch.
You will find a tab "Telegram" in the user permissions, if you install that branch.
OK I will where to download and install that one?
When you stop learning, stop listening, stop looking and asking questions, always new questions, then it is time to die. Lillian Smith :!:
mbld
Registered User
Posts: 21
Joined: Thu Aug 23, 2018 7:37 pm

Re: [3.3][DEV] Telegram Bridge

Post by mbld »

I wanted to wait with the release, to see if RexTOr wants to provide a Russian translation.
You can go to the develop branch on GitHub (https://github.com/D-MBLD/phpbb-telegra ... ee/develop) and use the "Download ZIP" command behind the "Code"-Button.
Then deactivate the extension, delete all files below eb/telegram, extract the zip into that directory, and activate the extension again.

Note: By deactivating the extension, unfortunately I have to delete the telegram notification settings of all users.
The reason is, that the board is not able to deal with notification settings for methods, which do not exist. Not deleting the settings would lead to a crashing board, after the extension was deactivated.
rxu
Extensions Development Team
Posts: 3711
Joined: Wed Oct 25, 2006 12:46 pm
Location: Siberia, Russian Federation
Contact:

Re: [3.3][DEV] Telegram Bridge

Post by rxu »

mbld wrote: Fri Mar 17, 2023 7:59 am The reason is, that the board is not able to deal with notification settings for methods, which do not exist. Not deleting the settings would lead to a crashing board, after the extension was deactivated.
Actually you need just to disable custom notification via ext.php on extension disable step and to enable it on enable step. You can get an example here https://github.com/phpbb-extensions/aut ... er/ext.php.
mbld
Registered User
Posts: 21
Joined: Thu Aug 23, 2018 7:37 pm

Re: [3.3][DEV] Telegram Bridge

Post by mbld »

rxu wrote: Fri Mar 17, 2023 9:44 am Actually you need just to disable custom notification via ext.php on extension disable step and to enable it on enable step. You can get an example here https://github.com/phpbb-extensions/aut ... er/ext.php.
Thanks for the hint. But that works only for custom notification types, not for custom notification methods.
There is a separate table for notification types, where the types can be disabled.
But there is no such table for notification methods. (Or at least I could not find one)
rxu
Extensions Development Team
Posts: 3711
Joined: Wed Oct 25, 2006 12:46 pm
Location: Siberia, Russian Federation
Contact:

Re: [3.3][DEV] Telegram Bridge

Post by rxu »

mbld wrote: Fri Mar 17, 2023 4:54 pm But there is no such table for notification methods.
Will it work if you add $extension_manager->is_enabled() check to the notification method's function is_available()?
mbld
Registered User
Posts: 21
Joined: Thu Aug 23, 2018 7:37 pm

Re: [3.3][DEV] Telegram Bridge

Post by mbld »

rxu wrote: Sat Mar 18, 2023 4:29 am
mbld wrote: Fri Mar 17, 2023 4:54 pm But there is no such table for notification methods.
Will it work if you add $extension_manager->is_enabled() check to the notification method's function is_available()?
When the extension is disabled, the method class is not available at all. So it does not help to change any method of the class.

I have reported that as a bug: https://tracker.phpbb.com/browse/PHPBB3-17117

The only option I currently see, is to move back and forth the corresponding settings into a table created by the extension, whenever the extension is disabled/enabled. I think deleting the user settings on every extension update (or forum update, where extensions are typically also deactivated) is indeed not acceptable.
User avatar
ReXtor
Registered User
Posts: 28
Joined: Sat Jan 28, 2023 12:23 pm
Location: Siberia

Re: [3.3][DEV] Telegram Bridge

Post by ReXtor »

mbld wrote: Thu Mar 16, 2023 9:36 am I have added the custom permissions for telegram (notify, browse and post) together with some other improvements/refactorings in the develop branch.
Wonderful! I will update and check in the coming days.
mbld wrote: Thu Mar 16, 2023 9:36 am If you want to provide a translation, I will wait some days before creating the new release, so I can add the translation to the release.
(You can find the changes by comparing the language files of the develop branch with the release tag in GitHub)
Yes, I'm going to do it right now.

After 50 minutes...
It's already done. But now I will reinstall/update the extension and check it.

After XX minutes...
Disabled > cleared the data > deleted the extension directory > clear cache > uploaded a new version > enabled it:

Code: Select all

SQL ERROR [ mysqli ]

Table 'blahblah.phpbb_eb_telegram_chat' doesn't exist [1146]

SQL

SHOW COLUMNS FROM phpbb_eb_telegram_chat

BACKTRACE

FILE: (not given by php)
LINE: (not given by php)
CALL: msg_handler()

FILE: [ROOT]/phpbb/db/driver/driver.php
LINE: 1023
CALL: trigger_error()

FILE: [ROOT]/phpbb/db/driver/mysqli.php
LINE: 202
CALL: phpbb\db\driver\driver->sql_error()

FILE: [ROOT]/phpbb/db/tools/tools.php
LINE: 834
CALL: phpbb\db\driver\mysqli->sql_query()

FILE: [ROOT]/phpbb/db/tools/tools.php
LINE: 851
CALL: phpbb\db\tools\tools->sql_list_columns()

FILE: [ROOT]/ext/eb/telegram/migrations/telegram_table_v2.php
LINE: 17
CALL: phpbb\db\tools\tools->sql_column_exists()

FILE: [ROOT]/phpbb/db/migrator.php
LINE: 365
CALL: eb\telegram\migrations\telegram_table_v2->effectively_installed()

FILE: [ROOT]/phpbb/db/migrator.php
LINE: 288
CALL: phpbb\db\migrator->try_apply()

FILE: [ROOT]/phpbb/db/migrator.php
LINE: 241
CALL: phpbb\db\migrator->update_do()

FILE: [ROOT]/phpbb/extension/base.php
LINE: 78
CALL: phpbb\db\migrator->update()

FILE: [ROOT]/phpbb/extension/manager.php
LINE: 231
CALL: phpbb\extension\base->enable_step()

FILE: [ROOT]/includes/acp/acp_extensions.php
LINE: 209
CALL: phpbb\extension\manager->enable_step()

FILE: [ROOT]/includes/functions_module.php
LINE: 676
CALL: acp_extensions->main()

FILE: [ROOT]/adm/index.php
LINE: 81
CALL: p_master->load_active()
At the same time, in fact, the extension recorded some data and moved to the disabled list (previously it was in the list of not installed).

After X minutes...
I also tried to delete the directory of my translation (I thought there might be a problem in it), but it didn't help - the same error.

After X minutes...
I also tried to re-upload the files completely to exclude FTP connection errors - but the problem persisted.

After XX minutes...
Installed the previous version (from master) > Configured > Disabled (without deleting data) > Replaced the directory with a new version (from develop) > Enabled Extension > Success

Updating is a success, and a clean install is a failure :/

After XXX minutes...
Initial testing of the translation (ru) has been performed. Changes sent to branch :translation_ru on GitHub.
mbld
Registered User
Posts: 21
Joined: Thu Aug 23, 2018 7:37 pm

Re: [3.3][DEV] Telegram Bridge

Post by mbld »

Thanks for the translation. Will compile a new release tomorrow.
ReXtor wrote: Sat Mar 18, 2023 6:04 pm Updating is a success, and a clean install is a failure :/
I didn't think, that sql_column_exists fails, if the table does not exist.
Seems I should add a test, that installs and activates the extension.
User avatar
ReXtor
Registered User
Posts: 28
Joined: Sat Jan 28, 2023 12:23 pm
Location: Siberia

Re: [3.3][DEV] Telegram Bridge

Post by ReXtor »

mbld wrote: Thu Mar 16, 2023 9:36 am
I have not yet checked your proposals regarding markdown. I am currently sending the telegram messages using HTML style rather than MarkdownV2 style.

The BBCodes are shown intentionally, while I try to display the enclosed text matching the BBCode's formatting. That means e.g. a bold text is shown in bold, and is in addition surrounded by the \[b\] tag. This allows to copy and paste the text, keeping BBCodes.
Doesn't really matter much. In both variants, the display will be the same. There is no need to convert regular messages from BBCode to Markdown. Converting to HTML is enough.

However, if an extension is used to support Markdown at the conference itself, then when displayed via Telegram, it is also converted into HTML tags. Why not send the processed text to Telegram (without BBCode or markdown tags), as is done when exporting conference messages via Atom feed.

For example, I use one of the forums to post news and the Atom feed is enabled there. From this forum, the social network (VK) is configured to import it by its own means. I design messages in Markdown, but in Atom (XML) all markdown design is replaced with html tags. As a result, normal text gets into the social network, with html formatting, and there it is recognized within the limits of what is allowed. Almost the same thing happens when using the design via BBCode, but there are fewer possibilities without adding custom options.

When using BBCode
web
web
2023-03-20_02-08-07.png (10.44 KiB) Viewed 1976 times
tlg
tlg
2023-03-20_02-09-41.png (8.96 KiB) Viewed 1976 times
When using Markdown (ext):
web-source
web-source
2023-03-20_02-18-18.png (3.72 KiB) Viewed 1976 times
web-view
web-view
2023-03-20_02-18-56.png (7.55 KiB) Viewed 1976 times
tlg
tlg
2023-03-20_02-21-11.png (7.67 KiB) Viewed 1976 times

With images, the situation is even more complicated. This is how a typical (for my conference) message with images looks like:
2023-03-20_01-54-42.png
2023-03-20_01-52-54.png

Code: Select all

Warning: Topic is too long and was cut. Telegram doesn 't allow more than 4096 characters !
...
1&filename=6999a8916a6ed34e2aab9e39cac73cd0.jpg&disposition=inline&hash=&limit=0&content_type=image%2Fjpeg&owner_uid=7386801&tknv=v2&size=XXXL&crop=0&modified=1679229564&preview=f6b9f9b1c2077607fb2ae81b1d3f6e003fbc010029fcfd2439cf32d7ecee03f9&inf=CzDnftTfj0wrq145XtpEeFyatMH2ogEW7_QCk46UJ3SZgJcSRbO1QC2L7xs0u7Au_3GiQHdLxSKzLEz0UotYJw%3D%3D[/img]

[img]/image_preview?uid=7386801&filename=b822b98971d489cc2a297fd59202e1f6.jpg&disposition=inline&hash=&limit=0&content_type=image%2Fjpeg&owner_uid=7386801&tknv=v2&size=XXXL&crop=0&modified=1679230111&preview=eb830f7a2bf656556ebbccd883c73a4e76d4a743f9108049e2c3ad7f00b009cb&inf=Au7WWytRR774Fxz6hx1u-1v22_OXeB4ZOz3UtxoPnhEtI4-zV195YEwoQ_EkUek37TaxonHE8l_tEgUn7JU5Fg%3D%3D[/img]

[img]/image_preview?uid=7386801&filename=b18801ceb98c7e0dae90c32bb8277d4e.jpg&disposition=inline&hash=&limit=0&content_type=image%2Fjpeg&owner_uid=7386801&tknv=v2&size=XXXL&crop=0&modified=1679230114&preview=3554c88e46ebe13ffabef45009d2815b428cae569512b0ed496eda7e588333ce&inf=rrDLfAcYjtFUYPsyI6ab4KMENYS7OOJi9bMC94AUoLhxlUBE76tfBEWWO6r5ih6VQXcQ0EVUVd8mGK7p77xS8Q%3D%3D[/img]

[img]/image_preview?uid=7386801&filename=753094386a3aaacfbd2d7e15794ca4df.jpg&disposition=inline&hash=&limit=0&content_type=image%2Fjpeg&owner_uid=7386801&tknv=v2&size=XXXL&crop=0&modified=1679232910&preview=744f7bf5a2cc1dc8a697d9fed8cde43ffe6b948d40f4be8e859192b5b406000a&inf=AXNT7Sqx2iDwV_hIBlFWdnmweBnygsl6FaF5XxvO04lUZGJoQGbw5uQ8CNY00IkvpGEr-L1QuMeHH4bXQ4bcew%3D%3D[/img]

[img]/image_preview?uid=7386801&filename=03c8d9040c8b92d8f7671d8230fe3565.jpg&disposition=inline&hash=&limit=0&content_type=image%2Fjpeg&owner_uid=7386801&tknv=v2&size=XXXL&crop=0&modified=1679234399&preview=af8176c20a13f26df736a42b4d168f821bbe7685d122ed8fb03e5bd3a05969c1&inf=UU3Xtc_lERlLhs5kwLjVPFbZuvRRUCFvQYzDnQDlpD9-emzdq7yvbRWCFGcnFgeJtphMf1bUMOF4Kf92pAHZfw%3D%3D[/img]

[/spoiler]
___________________________________
This is exactly what I meant when I talked about the need to replace the contents of [img] with a stub text :/

Also, you need to do something so that the text after / stops being highlighted as a bot command. Otherwise, when you click on such a text, we have:
/text
/text
But, this will be solved by itself if you stop giving the "raw" text of messages (converting what you need into html tags).

Warning: Topic is too long and was cut. Telegram doesn 't allow more than 4096 characters !
When this event occurs, there is no link to the topic in the bot message. It may be worth considering the possibility of displaying standard information (date, author, title with a link), or at least a link to go to the topic (for example, at the end of such a message).

I also remembered about this:
navigation
navigation
Perhaps it is worth implementing a transition to the topic, including when sending a digit? Button navigation is good. But, someone, by mistake, can try to enter the number manually and will receive an error message that is not quite clear. Moreover, for backward/forward in any case, you need to enter +/- manually.

I also noticed a strange display of the name of the forum/section:
forum name
forum name
2023-03-20_03-18-00.png (7.68 KiB) Viewed 1970 times
I understand that long titles are cut off and the ending is replaced with .... But in this case, this is the full name (11 characters).
User avatar
ReXtor
Registered User
Posts: 28
Joined: Sat Jan 28, 2023 12:23 pm
Location: Siberia

Re: [3.3][DEV] Telegram Bridge

Post by ReXtor »

For moderators: this message is published separately due to the exhaustion of the limit on the number of attachments in the last message.

When sending a message via a bot, formatting performed via the formatting menu in Telegram is not supported:
tlg message
tlg message
web view
web view
2023-03-20_03-31-07.png (4.58 KiB) Viewed 1967 times
Does the extension clean the text from formatting? If yes, and if the raw text goes into markdown design, then maybe it's worth sending it "as is"? Again, if there is an extension for Markdown, the conference will display this text as expected, with a design. But if the raw text is sent in html tags, then probably not worth it.

If I use the design via Markdown manually:
raw md
raw md
2023-03-20_04-10-10.png (8.38 KiB) Viewed 1961 times
tlg
tlg
2023-03-20_04-11-34.png (6.86 KiB) Viewed 1961 times
then the message reaches the conference in a distorted form:
web view
web view
2023-03-20_04-12-10.png (6.31 KiB) Viewed 1961 times
When using the design via BBCode manually, this does not happen. However, this is logical :)

After sending a message through the bot, nothing happens (visually):
send message
send message
Perhaps it is worth considering updating the last message from the bot by adding the sent message to it?
mbld
Registered User
Posts: 21
Joined: Thu Aug 23, 2018 7:37 pm

Re: [3.3][DEV] Telegram Bridge

Post by mbld »

ReXtor wrote: Sun Mar 19, 2023 6:48 pm After sending a message through the bot, nothing happens (visually):
...
Perhaps it is worth considering updating the last message from the bot by adding the sent message to it?
That was a bug, which I already fixed with this commit. Fix is already included in 1.0.3-dev.
User avatar
ReXtor
Registered User
Posts: 28
Joined: Sat Jan 28, 2023 12:23 pm
Location: Siberia

Re: [3.3][DEV] Telegram Bridge

Post by ReXtor »

When adding a footer to ACP after saving it, the encoding deteriorates:
default message
default message
2023-03-20_23-30-18.png (6.03 KiB) Viewed 1880 times
after saving the settings:
after save
after save
2023-03-20_23-31-07.png (5.44 KiB) Viewed 1880 times
Russian symbols are spoiling.
ReXtor wrote: Sun Mar 19, 2023 5:59 pm I also noticed a strange display of the name of the forum/section:
2023-03-20_03-18-00.png
I understand that long titles are cut off and the ending is replaced with .... But in this case, this is the full name (11 characters).
Also similar is seen on other buttons:
send email (16 symb)
send email (16 symb)
2023-03-20_23-21-41.png (2.69 KiB) Viewed 1879 times
add topic (13 symb)
add topic (13 symb)
2023-03-20_23-25-14.png (3.96 KiB) Viewed 1879 times
Specified text = full text, but it is still appended to ...

Regarding the output of the text of messages in TG with bbcode - when viewing a message with links wrapped in [url], [img], [media], etc., the closing bbcode is attached to the link when displayed in telegram and the link becomes a "broken".
For example: [media]https://youtube.com/[/media] in TG it is recognized as https://youtube.com/[/media]

Perhaps on the "first" message of the bot, where the forums are navigated (and there are only six buttons), you should add the "update" button. When returning to the bot interface after some absence, in order to update the information to the current one, you have to click on a button and go back.

When removing a bot from the list of your telegram chats and reactivating it, there is nothing left but to click "start". The bot sends this to the extension, but the extension does not know about this command and returns an error message. It may be worth providing for the output of the "first" screen by the /start command (provided that the ID has already been configured at the conference).
mbld
Registered User
Posts: 21
Joined: Thu Aug 23, 2018 7:37 pm

Re: [3.3][DEV] Telegram Bridge

Post by mbld »

OK, a lot of testing (Thank you!) and a lot of things to do.

I'll try to sort it out beginning with the latest:

Regarding the footer in ACP: Solved in develop branch.

Regarding the shortened text on buttons: Solved in develop branch.
(In both cases a multibyte character problem)

Regarding the closing BBCode, which is treated as part of a link:
No idea yet. Created an issue in GitHub.

Regarding the update-button: Have to think about it. Created an issue.

Regarding the handling of /start-command: Should be no problem. Created an issue.

Regarding formatting:
As a first attempt, the bold/italic/underline formatting which can be either set using the format-buttons, or as markdown (except underline) is now converted into BBCode. (develop branch) For further improvements, I created an issue.
But please note: *italic* is no standard telegram MD, but it is rather __italic__.
I guess it works in your case, because the MD-extension in your forum cares for rendering.

I have not yet cared for compatibility with the alfredoramos/markdown-Extension. (Created an issue).

Regarding shortened text longer than 4096 chars: I think shortening the text only after a fixed header part is a good idea: Created an issue.

Regarding img-tag: Not yet fully checked. Created an issue.

Regarding text starting with a slash, which is automatically treated as telegram command: See issue.

Regarding input of topic or forums index: Good idea; Had that already implemented locally, but dropped it. Created an issue.
User avatar
ReXtor
Registered User
Posts: 28
Joined: Sat Jan 28, 2023 12:23 pm
Location: Siberia

Re: [3.3][DEV] Telegram Bridge

Post by ReXtor »

mbld wrote: Tue Mar 21, 2023 3:24 pm Regarding the closing BBCode, which is treated as part of a link:
No idea yet. Created an issue in GitHub.
It seems to me that this can be solved only by removing any BBCode from sending to telegram.
mbld wrote: Tue Mar 21, 2023 3:24 pm Regarding the handling of /start-command: Should be no problem. Created an issue.
At the same time, you can think about the possibility of adding processing of other commands. For example, the output of "active topics", "recent topics" and the like, by analogy with the standard functionality of the conference when viewed via the web.
mbld wrote: Tue Mar 21, 2023 3:24 pm Regarding formatting:
As a first attempt, the bold/italic/underline formatting which can be either set using the format-buttons, or as markdown (except underline) is now converted into BBCode. (develop branch) For further improvements, I created an issue.
But please note: *italic* is no standard telegram MD, but it is rather __italic__.
I was guided by this help. This is probably about internal processing, not about user input.
mbld wrote: Tue Mar 21, 2023 3:24 pm I guess it works in your case, because the MD-extension in your forum cares for rendering.

I have not yet cared for compatibility with the alfredoramos/markdown-Extension. (Created an issue).
In fact, the extension alfredoramos/markdown only enables this feature, and the functionality itself is located in the core of the conference (Text Formatter).
mbld wrote: Tue Mar 21, 2023 3:24 pm Regarding img-tag: Not yet fully checked. Created an issue.
Here you need to remember that links to images may not necessarily have a full path. In my case (and in the case of some other extensions), they lack the initial part of protocol://hostname. The same applies to other links. Personally, I think that everything inside [img][/img] is more logical to simply replace with some text. Since images cannot be displayed inside telegram in the form in which they can be inside the post. Moreover, the preview of the image may work and everything will take on an even stranger appearance.

At the same time, if it is a link in a simple [url] and if it has a full path (there is at least a hostname), then it is quite possible to give it in telegram in the usual form. If there is no hostname in the link, then add it to the link (the path to the conference). And if it is [url=]link name[/url], then give it to telegram in the form of the text "link name" with a link attached to it.

By the way, you can do the same with the contents of [img] - replace the link text with some text IMG, but attach a link to the image to it. Also taking into account the conversion of the link address into a full path, if necessary. However, I do not know whether the length of the attached links affects the total volume of the message.
mbld
Registered User
Posts: 21
Joined: Thu Aug 23, 2018 7:37 pm

Re: [3.3][DEV] Telegram Bridge

Post by mbld »

New version 1.0.4-dev released.
See GitHub Release Notes for a list of new functions/fixes.
Post Reply

Return to “Extensions in Development”