Skip to content

Instantly share code, notes, and snippets.

@lucaspg96
Last active February 20, 2025 18:27
Show Gist options
  • Save lucaspg96/284c9dbe01d05d0563fde8fbb00db220 to your computer and use it in GitHub Desktop.
Save lucaspg96/284c9dbe01d05d0563fde8fbb00db220 to your computer and use it in GitHub Desktop.
A python script to send messages to a telegram user. Useful to notify when long scripts are finished!
#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)
@exec85
Copy link

exec85 commented Jul 9, 2021

_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.

@Omokami
Copy link

Omokami commented Nov 11, 2024

@everyone

Are there any instances of sending messages using TypeScript?

@hamdan-Deb
Copy link

no idea

@Omokami
Copy link

Omokami commented Jan 11, 2025

i solved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment