Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Nama
Last active July 8, 2019 13:11
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 Nama/0d1fa851d413ec79f900 to your computer and use it in GitHub Desktop.
Save Nama/0d1fa851d413ec79f900 to your computer and use it in GitHub Desktop.
Short script to send messages via Telegram-Bot
#!python
import sys
import requests
from socket import gethostname
from sys import argv
link = 'https://api.telegram.org/bot'
token = 'BotToken'
def send(chatid, method, msg):
parse_mode = 'Markdown'
response = requests.post('%s%s/%s' % (link, token, method), params={'parse_mode': parse_mode, 'chat_id': chatid, 'text': msg})
if __name__ == '__main__':
chatid = str(argv[1])
method = str(argv[2])
msg = ''
for word in argv[3:]:
msg += word + ' '
send(chatid, method, msg)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment