Skip to content

Instantly share code, notes, and snippets.

@leandrotoledo
Last active April 23, 2016 13:15
Show Gist options
  • Save leandrotoledo/f84617ca088fe8fe0877d7222e057f7e to your computer and use it in GitHub Desktop.
Save leandrotoledo/f84617ca088fe8fe0877d7222e057f7e to your computer and use it in GitHub Desktop.
import logging
import telegram
from telegram import ReplyKeyboardMarkup, KeyboardButton
from telegram.ext import Updater, CommandHandler, MessageHandler, filters
# Enable logging
logging.basicConfig(
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level=logging.INFO)
logger = logging.getLogger(__name__)
def test(bot, update):
bot.sendMessage(update.message.chat_id,
text='location',
reply_markup=ReplyKeyboardMarkup([[KeyboardButton("test", request_location=True)]] , one_time_keyboard=True))
def entered_value(bot, update):
print(update.message.location.latitude)
print(update.message.location.longitude)
def error(bot, update, error):
logger.warn('Update "%s" caused error "%s"' % (update, error))
def main():
updater = Updater("YOUR TOKEN HERE")
updater.dispatcher.addHandler(CommandHandler("test", test))
updater.dispatcher.addHandler(MessageHandler([filters.LOCATION], entered_value))
updater.dispatcher.addErrorHandler(error)
updater.start_polling()
updater.idle()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment