docs: showcase more methods
This commit is contained in:
parent
7b385e3103
commit
d134faa17e
1 changed files with 6 additions and 4 deletions
10
README.md
10
README.md
|
@ -19,16 +19,18 @@ app = AppService(
|
||||||
as_token="YOUR-APPSERVICE-TOKEN",
|
as_token="YOUR-APPSERVICE-TOKEN",
|
||||||
hs_token="YOUR-HOMESERVER-TOKEN",
|
hs_token="YOUR-HOMESERVER-TOKEN",
|
||||||
)
|
)
|
||||||
|
mxid = "@_appsrv_firstuser:matrix.org"
|
||||||
|
room = "#my-epic-room:matrix.org"
|
||||||
```
|
```
|
||||||
|
|
||||||
to execute actions use AppService's helper methods:
|
to execute actions use AppService's helper methods:
|
||||||
```python
|
```python
|
||||||
mxid = "@_appsrv_firstuser:matrix.org"
|
|
||||||
room = "#my-epic-room:matrix.org"
|
|
||||||
await app.register_mxid(mxid)
|
await app.register_mxid(mxid)
|
||||||
await app.set_nick(mxid, "First User")
|
await app.set_nick(mxid, "First User")
|
||||||
|
await app.set_avatar(mxid, "https://cdn.alemi.dev/profile/pic/someriver.jpg")
|
||||||
await app.invite_to_room(room, mxid)
|
await app.invite_to_room(room, mxid)
|
||||||
await app.join_room(room, mxid)
|
await app.join_room(room, mxid)
|
||||||
|
await app.set_presence(mxid, online=True)
|
||||||
await app.send_message(room, "<b>hello world!</b>")
|
await app.send_message(room, "<b>hello world!</b>")
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -36,10 +38,10 @@ to subscribe to room events use the callback decorator:
|
||||||
```python
|
```python
|
||||||
from aioappsrv.matrix import Event
|
from aioappsrv.matrix import Event
|
||||||
|
|
||||||
room = "#my-epic-room:matrix.org"
|
|
||||||
@app.callback(room)
|
@app.callback(room)
|
||||||
async def my_cb(event: Event):
|
async def my_cb(event: Event):
|
||||||
print(f"{event.sender}: {event.content['body']}")
|
print(f"{event.room_id}| {event.sender} : {event.content['body']}")
|
||||||
|
await app.ack_event(event.room_id, event.event_id)
|
||||||
```
|
```
|
||||||
|
|
||||||
## state
|
## state
|
||||||
|
|
Loading…
Reference in a new issue