-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathmain
executable file
·41 lines (33 loc) · 1014 Bytes
/
main
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
#!/usr/bin/env python3
import asyncio
from datetime import datetime
import websockets
from src.senders import Sender
from src.io_process import stringing, Usage
async def main():
"""
Loading function. Connect websocket then launch bot.
"""
async with websockets.connect('ws://sim.smogon.com:8000/showdown/websocket') as websocket:
Sender(websocket)
while True:
message = await websocket.recv()
print(f'[{datetime.now().replace(microsecond=0).isoformat()}] << {message}')
await stringing(message, Usage.CHALL_OWNER)
def test():
"""
Sandbox
"""
# from src.pokemon import Pokemon
# pkm1 = Pokemon('Pikachu', 'Pikachu-Kalos', '100/100', True, '92')
# pkm1.load_unknown()
# print(pkm1)
if __name__ == "__main__":
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
try:
loop.run_until_complete(main())
finally:
loop.close()
asyncio.set_event_loop(None)
# test()