Skip to content

Instantly share code, notes, and snippets.

@sae13
Created June 1, 2018 13:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sae13/49f4c6f94e3ccf3ee46eebaff67f5359 to your computer and use it in GitHub Desktop.
Save sae13/49f4c6f94e3ccf3ee46eebaff67f5359 to your computer and use it in GitHub Desktop.
python-telegram-bot job run_once example
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