I have a Python script that works great with 'telegram bot'. I want to send the user a welcome message on start of the app.
Hopefuly someone here can direct me how to do this.
Thanks in advance.
I have tried using the send_text function in several places on the script with no luck.
This is not possible, as the Bot API does not send an update when the user opens the app.
Related
I have two working discord bots and a test server. I want my first bot to add the second bot to the test server. How would I go about this? I have researched it and found nothing. Any help would be appreciated. Thanks!
This isn’t possible, bots can’t run other bots cmds or add other bots to a server.
I am experimenting with telegram bots and python. My question is how can I make my python program persistently check for messages which are sent to my telegram bot?
for example:
while checkForIncomingMessages:
print(latestMessage)
if latestMessage == "ifconfig":
# execute ifconfig command on laptop
thanks in advance!
There are example bots on the github page of the telegrambot.
echobot2
I have a conversation where the bot send out multiple replies.
For example:
User: “Hi”
Bot: “Hello”
Bot: “How can I help you?”
Here the bot sends out multiple messages. In interactive mode this is working fine. However, after I setup the REST API (following this How to serve chatbot from server?), the bot does not send out multiple messages for obvious reasons. How can I get this working?
you can use \n\n inside a text response to split it into two messages..
Unfortunately it does not work with button response messages.
Here You can use custom actions with as many dispatcher.utter_message() events as you want..
I've coded a Telegram bot (python-telegram-bot) and I would like to know if there's a way to open an app from the bot.
To be more accurate, the bot searches torrent links and the original idea was to send that links directly to qBitTorrent in the user's computer but unfortunately I'm stuck in that step, so for the moment I though about give the user the magnet link so it can be pasted in the qBitTorrent app. The thing is that it would great to automaticly open the app from the bot.
Thanks in advance!
A bot can't open an external app
I've also stuck on this problem. I've tried to open another app via URI, for example:
things://add?title=My%20new%20task
The example above shows my try to open the macOS application called Things.
The main answer is: Telegram doesn't allow to open external applications from bot and doesn't allow use any protocol in URI, except for http and tg.
I think, you can use 3rd-party (or your one) service, which will redirect you on any page that you will ask. Your URL may be a URI to your app: your mobile/PC browser can redirect you directly to the app.
Generally speaking, you're right: one Android app is able to start another app.
However, in this case, this is not your app, we're talking about, but you want another app (Telegram) to open another app. So you have to rely on what that app (Telegram) provides you with their API.
You can have a look at Telegram's bot API at https://core.telegram.org/bots/api There is no method to execute commands or open another app. So it will not be possible for you to open another app with your Telegram bot.
I was also trying to do this, but that was not possible. But as workaround you can make a simple site that opens the app and make Telegram open that.
I've started tinkering with python recently and I'm on my way to create my very first telegram bot mainly for managing my Raspberry Pi and a few things connected to it. The bot is done but I would like to send a message to all the users that have already interacted with the bot when it starts, basically saying something like "I'm ready!", but I haven't been able to find any information about it.
Is there any specific method in the API already done to do this? Or should I create another file to store the chat_id from all the users and read it with python?
Thank you all for your help!! Regards!
You should have a Database that stores Chat-id(s) of Clients that interact with your bot.
If you're able to put them into a list, then the job is half done.
All you need to do is to create a "for loop", and send message to all the ID(s) in the list.
Example:
message = "Good morning"
chats =[1234447488,3748838477,4748848578,7463638488]
for chat in chats:
bot.send_message(chat_id=chat,text= "message")
In case of of clients that have deleted your bot, you may experience an error. You can catch that with try and except.
Is there any specific method in the API already done to do this?
No, there's no such method.
Or should I create another file to store the chat_id from all the users and read it with python?
Yes, you should handle it yourself. Usually user ids and another information about User <-> Bot interaction is stored in a database on a server, because it's easier for maintaining and searching.
So if you want to send a plain text message to your users in a file, you should call SendMessage method of telegram bot API for every user in your file.
You should save users in database or file.After that use for to send_message one by one to all users that you have in database or file.
Yes you should create another file or use a database to store the chat_id of all the users you interact with. You can check Telegram Bots API to see all the available commands. if there is no such command then there probably won't be any command in the wrapper you are using for python either.