Last active
July 8, 2019 13:11
-
-
Save Nama/0d1fa851d413ec79f900 to your computer and use it in GitHub Desktop.
Short script to send messages via Telegram-Bot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!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