如何在django-telegrambot中使用job_queue?

时间:2019-06-03 19:41:53

标签: python django python-telegram-bot telegram-webhook

我正在使用python-telegram-bot和django-telegrambot。我设置了webhook,并且想使用job_queue方法进行run_repeating,但是我的代码无法正常工作。我不知道怎么写。谢谢。

def check_dollar_price():
   r = requests.get('http://www.tgju.org/chart
/price_dollar_rl').content
   from bs4 import BeautifulSoup
   soup = BeautifulSoup(r, 'html.parser')
   result = soup.find('div', {'class': "profile-container"}).ul.li.span.get_text()
   # bot = DjangoTelegramBot.dispatcher.bot
   bot = DjangoTelegramBot.dispatcher.bot
   bot.sendMessage(-1001326345035, 'the dollar price is >>>  ' + result)

def main():
   logger.info(">>>>>>>>>secend app ================???? log")
   dp = DjangoTelegramBot.dispatcher
   jq = DjangoTelegramBot.dispatcher.job_queue
   jq.run_repeating(check_dollar_price, interval=60, first=0)

0 个答案:

没有答案