Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
38 lines (26 sloc) 1.1 KB
import random
import os
from staticmap import StaticMap, CircleMarker
import telegram
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
def start(bot, update):
bot.send_message(chat_id=update.message.chat_id, text="Envia'm la teva localització!")
def where(bot, update, user_data):
fitxer = "%d.png" % random.randint(1000000, 9999999)
lat, lon = update.message.location.latitude, update.message.location.longitude
mapa = StaticMap(500, 500)
mapa.add_marker(CircleMarker((lon, lat), 'blue', 10))
imatge = mapa.render()
bot.send_photo(chat_id=update.message.chat_id, photo=open(fitxer, 'rb'))
except Exception as e:
bot.send_message(chat_id=update.message.chat_id, text='💣')
TOKEN = open('token.txt').read().strip()
updater = Updater(token=TOKEN)
dispatcher = updater.dispatcher
dispatcher.add_handler(CommandHandler('start', start))
dispatcher.add_handler(MessageHandler(Filters.location, where, pass_user_data=True))
You can’t perform that action at this time.