Created
June 1, 2018 13:05
-
-
Save sae13/49f4c6f94e3ccf3ee46eebaff67f5359 to your computer and use it in GitHub Desktop.
python-telegram-bot job run_once example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from telegram.ext import Updater, Dispatcher, Job, CommandHandler | |
import logging | |
# Enable logging | |
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', | |
level=logging.INFO) | |
logger = logging.getLogger(__name__) | |
def error(bot, update, error): | |
"""Log Errors caused by Updates.""" | |
logger.warning('Update "%s" caused error "%s"', update, error) | |
token = "408413304:AAExDBT9xmHDk5T352UM" | |
my_id = "245549956" | |
updater = Updater(token) | |
def sendHi(bot,job): | |
# print(update) | |
bot.sendMessage(chat_id=job.contxetet,text="func") | |
dispatcher = updater.dispatcher | |
j = updater.job_queue.run_once(sendHi,1,context="245549956") | |
dispatcher.add_error_handler(error) | |
updater.start_polling() | |
updater.idle() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment