-
-
Save lucaspg96/284c9dbe01d05d0563fde8fbb00db220 to your computer and use it in GitHub Desktop.
#This script is independet of lib or python version (tested on python 2.7 and 3.5) | |
import telegram | |
#token that can be generated talking with @BotFather on telegram | |
my_token = '' | |
def send(msg, chat_id, token=my_token): | |
""" | |
Send a mensage to a telegram user specified on chatId | |
chat_id must be a number! | |
""" | |
bot = telegram.Bot(token=token) | |
bot.sendMessage(chat_id=chat_id, text=msg) |
Hi Allan, this script only sends one message, but you can call this same function inside a script. For example, I have a script that checks the disk space of our server and notifies if some partition is becoming overloaded. I schedule this script to run every day using crontab on Ubuntu Server.
I want to write to python script that sends periodic message to a telegram bot. How can I do it?
Hi Allan, this script only sends one message, but you can call this same function inside a script. For example, I have a script that checks the disk space of our server and notifies if some partition is becoming overloaded. I schedule this script to run every day using crontab on Ubuntu Server.
I want to write to python script that sends periodic message to a telegram bot. How can I do it?
Hi @greazee,how I said before, the way I did was using crontab at my Ubuntu Server. I scheduled to execute the script each 2 hours and, if the memory/cpu usage surpasses a threshold (80%), the script send a message to my telegram using a telegram bot
import Schedule
could i send a massage from my private account, and not from my bot?
could i send a massage from my private account, and not from my bot?
there is any way ?
see this :
https://www.youtube.com/watch?v=ULIdgdR84Gg
I am also very new to this, lemme explain my situation:
I want to share my tool (selenium python app with a tkinter GUI) with some friends or unknown persons.
I would like to let telegrambot send a message like "Tool started" once my app gets started.
How can I achieve it that every user, using my app, is geting a private message?
_How do I obtain/get the target user's ChatID (my Telegram user's ID) to whom my bot is going to send the message, please?
If you do not want to use it, you can create a dummy bot that receives a message and takes the chatId for each message.
Any advice fora code that would achieve that? I am struggling woth that part.
@Torento22 you should be pip-installing
python-telegram-bot
package, nottelegram
.