After python-telegram-bot > 20.4 bot.send_message as async method
Last active
August 25, 2023 08:44
-
-
Save i-sync/0f223976fb1bf2d5b994896904c187d0 to your computer and use it in GitHub Desktop.
nicept
This file contains hidden or 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
| import requests | |
| import telegram | |
| import asyncio | |
| #https://www.nicept.net/attendance.php | |
| #telegram | |
| token = '317386xxx:xxxxxxx' | |
| group = {'id': -100xsdf87, 'name': 'asynchronize'} | |
| async def get_attendance(): | |
| headers = { | |
| "Cookie": "__cfduid=dadbcddd; xxxxx", | |
| "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36" | |
| } | |
| url = "https://www.nicept.net/attendance.php" | |
| res = requests.get(url, headers = headers); | |
| if res.status_code == 200: | |
| msg = "nicept login successfull!" | |
| else: | |
| msg = "nicept login failed!" | |
| #send telegram message | |
| bot = telegram.Bot(token) | |
| await bot.send_message(chat_id=group["id"], text= msg) | |
| async def pt_school_add_bonus(): | |
| headers = { | |
| "Cookie": "__cfduid=dadbcddd; xxxxx", | |
| "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36" | |
| } | |
| url = "http://pt.btschool.club/index.php?action=addbonus" | |
| res = requests.get(url, headers = headers); | |
| if res.status_code == 200: | |
| msg = "pt school login successfull!" | |
| else: | |
| msg = "pt school login failed!" | |
| print(msg) | |
| #send telegram message | |
| bot = telegram.Bot(token) | |
| await bot.send_message(chat_id=group["id"], text= msg) | |
| async def main(): | |
| await asyncio.gather(get_attendance(), pt_school_add_bonus()) | |
| if __name__ == "__main__": | |
| asyncio.run(main()) |
This file contains hidden or 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
| python-telegram-bot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment