Re-format wasm_command_bot
parent
6e29251886
commit
089ab20e7c
|
@ -60,7 +60,9 @@ impl WasmBot {
|
||||||
|
|
||||||
for (room_id, room) in response.rooms.join {
|
for (room_id, room) in response.rooms.join {
|
||||||
for event in room.timeline.events {
|
for event in room.timeline.events {
|
||||||
if let Ok(AnySyncRoomEvent::Message(AnySyncMessageEvent::RoomMessage(ev))) = event.event.deserialize() {
|
if let Ok(AnySyncRoomEvent::Message(AnySyncMessageEvent::RoomMessage(ev))) =
|
||||||
|
event.event.deserialize()
|
||||||
|
{
|
||||||
self.on_room_message(&room_id, &ev).await
|
self.on_room_message(&room_id, &ev).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,19 +83,14 @@ pub async fn run() -> Result<JsValue, JsValue> {
|
||||||
let homeserver_url = Url::parse(&homeserver_url).unwrap();
|
let homeserver_url = Url::parse(&homeserver_url).unwrap();
|
||||||
let client = Client::new(homeserver_url).unwrap();
|
let client = Client::new(homeserver_url).unwrap();
|
||||||
|
|
||||||
client
|
client.login(username, password, None, Some("rust-sdk-wasm")).await.unwrap();
|
||||||
.login(username, password, None, Some("rust-sdk-wasm"))
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let bot = WasmBot(client.clone());
|
let bot = WasmBot(client.clone());
|
||||||
|
|
||||||
client.sync_once(SyncSettings::default()).await.unwrap();
|
client.sync_once(SyncSettings::default()).await.unwrap();
|
||||||
|
|
||||||
let settings = SyncSettings::default().token(client.sync_token().await.unwrap());
|
let settings = SyncSettings::default().token(client.sync_token().await.unwrap());
|
||||||
client
|
client.sync_with_callback(settings, |response| bot.on_sync_response(response)).await;
|
||||||
.sync_with_callback(settings, |response| bot.on_sync_response(response))
|
|
||||||
.await;
|
|
||||||
|
|
||||||
Ok(JsValue::NULL)
|
Ok(JsValue::NULL)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue