-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathclient.py
More file actions
35 lines (26 loc) · 1016 Bytes
/
Copy pathclient.py
File metadata and controls
35 lines (26 loc) · 1016 Bytes
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
from satori import EventType, Upload
from satori.client import Account, App, WebsocketsInfo
from satori.event import Event, MessageEvent
app = App(WebsocketsInfo(port=12345, path="foo"))
@app.register
async def _(account: Account, event: Event):
print(event.sn) # noqa: T201
@app.register_on(EventType.MESSAGE_CREATED)
async def on_message(account: Account, event: MessageEvent):
print(event.message) # noqa: T201
if event.user and event.user.id == "9876543210":
print(await account.channel_get(event.channel.id)) # noqa: T201
print(await account.send_message(event.channel, "Hello, World!")) # noqa: T201
print( # noqa: T201
res := await account.upload(
Upload(
b"1234",
name="foo.png",
)
)
)
print(await account.download(res[0])) # noqa: T201
@app.lifecycle
async def record(account: Account, state):
print(account, state) # noqa: T201
app.run()