Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import logging
- from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
- person = str({ "name": "John", "age": 31, "city": "New York" }) #variable global a introducir
- # Enable logging
- logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
- level=logging.INFO)
- logger = logging.getLogger(__name__)
- # Define a few command handlers. These usually take the two arguments update and
- # context. Error handlers also receive the raised TelegramError object in error.
- def start(update, context):
- """Send a message when the command /start is issued."""
- update.message.reply_text('We are informing you with this bot about the current mall availavility')
- def help_command(update, context):
- """Send a message when the command /help is issued."""
- update.message.reply_text('Help!')
- def echo(update, context):
- """Echo the user message."""
- update.message.reply_text('The mail availability is '+ person)
- # update.message.reply_text(update.message.text)
- def pic(bot, update):
- chat_id = update.message.chat_id # get the recipient´s ID
- bot.send_photo(chat_id=chat_id, photo=open('./people1.png', 'rb'))
- #context.bot.sendPhoto(chat_id=chat_id, photo=open('./people1.jpg', 'rb'))
- #update.message.reply_text(text="I'm sorry Dave I'm afraid I can't do that.")
- def main():
- """Start the bot."""
- # Create the Updater and pass it your bot's token.
- # Make sure to set use_context=True to use the new context based callbacks
- # Post version 12 this will no longer be necessary
- updater = Updater("1054564599:AAF6kqAC_8haOPmcFO9SlytJB0RB9vbW8fk", use_context=True)
- # Get the dispatcher to register handlers
- dp = updater.dispatcher
- # on different commands - answer in Telegram
- dp.add_handler(CommandHandler("start", start))
- dp.add_handler(CommandHandler("help", help_command))
- # on noncommand i.e message - echo the message on Telegram
- dp.add_handler(MessageHandler(Filters.text & ~Filters.command, echo))
- dp.add_handler(CommandHandler('pic', pic))
- # Start the Bot
- updater.start_polling()
- # Run the bot until you press Ctrl-C or the process receives SIGINT,
- # SIGTERM or SIGABRT. This should be used most of the time, since
- # start_polling() is non-blocking and will stop the bot gracefully.
- updater.idle()
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement