I wrote a telegram bot using telegram bot python API, I want to implement two button option for user to select but I don't have any database to save the option with chat_id.
For example: A user want to translate a Eng text to another language, And has two languages available: 1.Persian 2.Spanish
user will select a language and then send the text and its choice will be saved for other texts
Can anyone help me to do that? Personally I thought that I can initialize a python dictionary with chat_id and its option but this is not practical.
Recently, I heard something about conversion handler that added in alpha version of telegram bot API, can I use it in this situation?
Related
I created a telegram bot with Nodejs and node-telegram-bot-api package and Mongodb for the database. Now, I want to add multiple languages in the bot and I want to keep the user language selected, and back data with his language.
I know I can save user language on a field in Mongodb. but I wanna know if there is any best way to keep that for the best performance. because there are many responses to users, I must check the language users every second with this method.
I have just created a bot on telegram. The purpose is to create private conversations with users (each user separately)
With my facebook bot I can go into the Page "Inbox" and watch all conversations. Is there such an option on telegram ? This helps me alot debugging my system.
To "watch all conversations" you can store them to database (e.g. csv file, SQLite, Postgresql, MongoDB, or any other depending on your environment). And later you can query for them when you need.
Another option, you can create separate predefined chat with you and bot, where bot will write some logs. Or if you have time - you can develop advanced mechanism that will show history (from database mentioned above) and will have ability to reply directly to that chat by chat_id.
I used rocket chat for that. I was creating private room for every user and was adding there the user and the bot (I was doing that via my backend). Then I used rocket chat ui to view the conversations. Currently, I see they have built-in integration with telegram bots: https://docs.rocket.chat/guides/administrator-guides/integrations/telegram
I want to create a telegram bot for a home project and i wish the bot only talk to 3 people, how can I do this?
I thought to create a file with the chat id of each of us and check it before responding to any command, I think it will work. the bot will send the correct info if it's one of us and "goodbye" to any other
But is there any other way to block any other conversation with my bot?
Pd: I'm using python-telegram-bot
For the first part of your question you can make a private group and add your bot as one of its administrators. Then it can talk to the members and answer to their commands.
Even if you don't want to do so, it is possible by checking the chatID of each update that the bot receives. If the chatID exists in the file, DataBase or even in a simple array the bot answers the command and if not it just ignores or sends a simple text like what you said good-bye.
Note that bots cannot block people they can only ignore their
messages.
Yes, I know I can add my bot to channel as admin and then the bot can work brilliantly.
But what I want to do is to add my bot to other channels to parse the data and do some analysis. How could this be achieved provided that I don't own those channels? Any other possible non-bot methods are welcomed to share.
I am currently using 'twx.botapi' from Python to do bot automation.
I saw on internet that there is some programs that can use Telegram CLI.
I want to choose between them
for Telegram bot API there is much more documents explaining its functionality, but for CLI there isn't much that explains its features
it seems the only way to know about is to experiment with it.
unfortunately i don't have a linux distro installed on my pc so experimenting isn't an option right know.
so I thought to ask from people who already used it
I know about Telegram bot api, its powers and its limitations
here is my questions:
what can I do using Telegram CLI that I can't do with with bot api, and vice versa?
Telegram bot API:
do not require to register new Telegram account, so you don't need to have another phone number;
bot cannot write to user first, only after user sends a first message to bot;
already has the commands interface (/command);
can do stuff by simple HTTP POST (by sending request via cURL, for example). So you can hook to this tons of stuff (notifications about new articles at the website or so);
you can rather easily create lots of them;
you can write you own implementation in almost any programming language;
you have a list of bots you have created (thanks to #BotFather). If you have lost somehow control of your bot - just revoke the token via #BotFather and it's yours again;
pretty simple to use.
Telegram client application (in this case - CLI):
requires new Telegram account registration with phone number;
acts like any other actual Telegram user (can write to other users first, without invitation). Well, that's a good thing;
not really good cross-platform abilities for now (some lack of CLI-realisations);
not really easy to install and use;
you have to implement the commands handling part;
if you have lost your phone number - pretty much you lose this account, because it's not like you would make some precautions for CLI client account. So you will have to register a new one and repeat the setting procedure for client.
In conclusion, bots actually got rid of CLI clients, in my opinion. I had CLI account right to the moment the bots appeared. After that I deleted it and created a bot. And not just one :)
So, bots are for the "robot" stuff, and real accounts are for the real people.
The Telegram CLI library interacts directly with their MTproto protocol, which means it's like their desktop/mobile app...but for the console. You can send messages from one phone number to another. This means that when authenticating with the CLI application, you use your real number as if you were logging into the mobile application.
I wouldn't suggest using it for bot behavior as you have to write an application that wraps the Telegram CLI and parses the log file as it is displayed...since it doesn't implement all the MTproto methods and the outputs for the log file are custom...it can be quite annoying and different than what you would expect.
With Telegram CLI you can send a number to another Telegram user without having them initiate the conversation first (since it functions just like a normal Telegram client) where the Bot API requires the user to add the Bot and start interaction before the Bot knows you are there.
previous answers are almost correct. Two different interfaces for different purposes:
Telegram Bot API allows to develop a Telegram Bot.
Telegram CLI (as this one, as an implementation example: https://github.com/vysheng/tg) are telegram client implementations, running from command line, based on MTproto protocol, as Chris Brand said.
As a bot developer, I'm interested to have a TG CLI interface (2) to automatize dialogs tests, with bash scripts, with a bot made with (1).