Skip to content

Instantly share code, notes, and snippets.

@drewreece
Last active August 31, 2016 01:29
Show Gist options
  • Save drewreece/8da044105935f15b5f3e2779789960a0 to your computer and use it in GitHub Desktop.
Save drewreece/8da044105935f15b5f3e2779789960a0 to your computer and use it in GitHub Desktop.
Sends Pokémon stickers for testing pokealarm
# -*- coding: utf-8 -*-
# drop into alarms/Telegram/ & run in that directory
import telepot
import json
import os
import sys
import time
target_chat = "TELEGRAM_CHAT-ID"
bot_id = "TELEGRAM_BOT_ID"
def handle(msg):
chat_id = msg['chat']['id']
if chat_id == target_chat:
if msg['sticker']:
print "file_id: {}".format(msg['sticker']['file_id'])
bot = telepot.Bot(bot_id)
bot.message_loop(handle)
print 'listening...'
bot.sendMessage(target_chat, "Image will be above name...")
# get names of pokemon from locale file
with open(os.path.abspath('../../locales/pokemon.en.json')) as file:
namelist = json.load(file)
def use_pyversion():
#sourcing data from python file (work in progress)
import telegram_stickers
return telegram_stickers.stickerlist
def use_json():
# get file_id of pokemon
with open(os.path.abspath('telegram_stickers.json')) as file:
stickerlist = json.load(file)
return stickerlist
stickerlist = use_json()
#stickerlist = use_pyversion() #work in progress
for k, v in stickerlist.iteritems():
# take it slowly or they get out of order
bot.sendSticker(target_chat, v)
time.sleep(0.5)
bot.sendMessage(target_chat, namelist[k])
time.sleep(0.5)
bot.sendMessage(target_chat, "...that is all.")
while 1:
time.sleep(10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment