📜 ⬆️ ⬇️

Comments in the telegram channel

Getting acquainted with the telegram bots came out messy - at work it was necessary to get ahead of the team of colleagues, and knowing the internal API well, the bot was written in a few days (later modified and received telegram verify badge )

According to the results, two bots were written (main and mailing), on which the management calmed down, and I started samizdat.

Once again, having played around with the prototype, I wanted to think that you can quickly write something else interesting in the telegram stack. The choice fell on the comments.

Bot @CommentsUserBot for comments in the telegram channel

There are channels in the telegram, but you cannot comment on them, and there are chats where you cannot write news - you will receive either all spam messages or nothing if you go to the mute .
Although, if you do in the pin chat with an alert, you can emulate the publication of aka in #channel.
image
')
After some thought, I went to read the documentation for telegra.ph . I already had to write a parser for news to the corporate site for IV, and I had an idea about what widgets exist on the platform ( however, some did not start ). Also, in the community of bot developers, I learned a few non-public APIs that came in handy later.

Everything looked clear, and over the weekend I sketched a prototype of a comment bot to the telegram channel - a button clung to the post, going to the bot to write the text, and then generating the comments page in the telegraph. In the channel itself, the button should show the number of comments.

image
Technically, the server only works at the time of the publication of comments. All the rest - text and graphics - is stored and cached by the telegraph itself.

After stuffing the developers for testing, I collected feedback, sketched a plan and began quietly gashting changes. So, initially, the automatic update mode of the channel was changed by the settings (manual or auto, the replacement of the original post or the publication of comment-post). The comments themselves were replenished with widgets, graphics and video ( thanks to Oleg O. for testing vulnerabilities. By the way, he also has a good comment @ Bot-ComBotBot ).
At that time I installed the telegram-x, and one of the important updates in it was that, once registered in the bot, you do not need to press start each time you enter from the deep link.
Comments, since the flat chat already exists, it was decided to make a tree. I did not write such storage before, but after a couple of bulky articles the database was able to digest them. The current limiting depth of branches is 10 levels. The number of comments per page 20, with pre-show answers in the branches, the number of comments and pagination.

Yes, the telegraph does not allow to turn around with the design of the page, but this was exactly what was needed - a bot in the telegram ecosystem - there are no additional authorizations and exits to the sites. The fonts will not fly, and the comment pages themselves will work through Instant View . The user himself at the same time stuffs the comment in the usual format, in a telegram - with emoticons, stickers, links and other things.

Editing is replaced by the addition of the current comment. In general, this is still enough, because your own comments can be deleted ( directly from the comments page ).

image

Then, when the bot wanted to use large channels ( > 100k subscribers ), there was a question of administration. The deletion of an unwanted comment and user ban has been added. Also, due to personal dislike of spam, response alerts are turned off by default for the user, but the settings allow you to subscribe to both comments and channel / post comments, plus a choice of comments level. All this comes from a separate bot-spammer, so by blocking it by unaware of the telegram interface, you can still write comments in other channels.

Zadizaynenaya in gimpe icon is painted for all entities of the project - bot, alert bot, project news and chat support.

About language interfaces: pages in the telegraph in en , and bots in en / ru (auto-detection works).
The comments are very much in South America. Now the good Samaritans are transferring files on the githaba for more localization.
In the spring (summer?), When the RKN began blocking accesses, I felt a little uncomfortable to develop (on the train, on the way to / c work - double ssh to the server periodically falls off), so the development rate (already low) has decreased. Now I collect reviews, make plans for improvements and write from time to time another bot, the work of which I will need in the current project.

Bot @CommentsUserBot for comments in the telegram channel.

Connect, write, discuss)

Source: https://habr.com/ru/post/428696/


All Articles