Skip to content

Instantly share code, notes, and snippets.

@enric1994
Last active September 10, 2019 11:22
Show Gist options
  • Save enric1994/a3e1f2fc62ca27a6be1cbaeb54f64fb9 to your computer and use it in GitHub Desktop.
Save enric1994/a3e1f2fc62ca27a6be1cbaeb54f64fb9 to your computer and use it in GitHub Desktop.
Simple Telegram bot for Python 2.7
#!/usr/bin/python2
#pip install telebot
import telebot
# Step 1. Create a bot and get the API key using the BotFather: https://telegram.me/BotFather
telegramToken='INSERT_API_KEY_HERE'
# Step 2. Start a conversation with your new bot using the /start command
# Step 3. Get your user ID using this bot: https://telegram.me/userinfobot
telegramChatID=1234
def send(message):
bot = telebot.TeleBot(telegramToken)
bot.config['api_key'] = telegramToken
bot.send_message(int(telegramChatID), message)
print(message)
send("Hello Telegram!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment