Skip to content

Instantly share code, notes, and snippets.

@4heck
Created March 16, 2021 08:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 4heck/b8d7b7fa3f8048d83e8097e5c4664914 to your computer and use it in GitHub Desktop.
Save 4heck/b8d7b7fa3f8048d83e8097e5c4664914 to your computer and use it in GitHub Desktop.
telegram_snippet
...
TELEGRAM_TOKEN = os.environ.get("TELEGRAM_BOT_TOKEN", "")
TELEGRAM_CHAT_ID = os.environ.get("TELEGRAM_CHAT_ID", "")
TELEGRAM_SEND_MESSAGE_URL_TEMPLATE = (
f"https://api.telegram.org/bot{TELEGRAM_TOKEN}/sendMessage?"
f"chat_id={TELEGRAM_CHAT_ID}&text={{}}&disable_web_page_preview=True"
)
...
...
url = settings.TELEGRAM_SEND_MESSAGE_URL_TEMPLATE.format(TEXT_MESSAGE)
...
...
response = requests.request("POST", url, data=data)
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment