Skip to content

Instantly share code, notes, and snippets.

@juananpe

juananpe/tg.py Secret

Created February 22, 2021 14:23
Show Gist options
  • Save juananpe/edee47d41ed16c0a00eb820e0135bed3 to your computer and use it in GitHub Desktop.
Save juananpe/edee47d41ed16c0a00eb820e0135bed3 to your computer and use it in GitHub Desktop.
Telegram notifier
import telegram
import sys
CHAT_ID="XXXXXXX"
def get_credentials(file_path):
f = open(file_path)
return f.readline().strip()
def main():
cred = get_credentials("/ruta/a/telegram.token")
message = " ".join(sys.argv[1:])
bot = telegram.Bot(token=cred)
bot.send_message(chat_id=CHAT_ID, text=message)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment