forked from samarth1220/Userge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
42 lines (35 loc) · 1.09 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# Copyright (C) 2020 by UsergeTeam@Github, < https://github.com/UsergeTeam >.
#
# This file is part of < https://github.com/UsergeTeam/Userge > project,
# and is released under the "GNU v3.0 License Agreement".
# Please see < https://github.com/uaudith/Userge/blob/master/LICENSE >
#
# All rights reserved.
import os
import asyncio
from userge import userge
async def worker() -> None:
chat_id = int(os.environ.get("CHAT_ID") or 0)
await userge.send_message(chat_id, 'testing_userge')
print('sleeping 3 sec...!')
await asyncio.sleep(3)
async def main() -> None:
print('starting client...!')
await userge.start()
tasks = []
print('adding tasks...!')
for task in userge._tasks:
tasks.append(loop.create_task(task()))
print('stating worker...!')
await worker()
print('closing tasks...!')
for task in tasks:
task.cancel()
print('stopping client...!')
await userge.stop()
loop = asyncio.get_event_loop()
print('creating loop...!')
loop.run_until_complete(main())
print('closing loop...!')
loop.close()
print('userge test has been finished!')