Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def attendance(bot, job):
- # Get chatID and user details based on chatID from the database
- update = job.context
- chatID = update.message.chat_id
- if not Chat.query.filter(Chat.chatID == chatID).first():
- bot.sendMessage(chat_id=update.message.chat_id, text="SOME MESSAGE")
- return
- userChat = Chat.query.filter(Chat.chatID == chatID).first()
- PID = userChat.PID
- password = userChat.password
- #Empty the previous report contents
- ...
- configure_logging({'LOG_FORMAT': '%(levelname)s: %(message)s'})
- runner = CrawlerRunner({
- 'FEED_FORMAT': 'json',
- 'FEED_URI' : 'output.json'
- })
- d = runner.crawl(MySpider, USERNAME=PID, PASSWORD=password)
- d.addBoth(lambda _: reactor.stop())
- reactor.run(installSignalHandlers=0)
- ...
- #SOME DATA PROCESSING FROM SCRAPPED ITEMS
- #Send message with processed data
- bot.sendMessage(chat_id=update.message.chat_id, text=messageContent)
- #RESTART BOT TO COUNTER ReactorNotRestartable Error.
- time.sleep(0.2)
- os.execl(sys.executable, sys.executable, *sys.argv)
Add Comment
Please, Sign In to add comment