Re-format wasm_command_bot

master
Jonas Platte 2021-06-23 14:04:10 +02:00
parent 6e29251886
commit 089ab20e7c
No known key found for this signature in database
GPG Key ID: CC154DE0E30B7C67
1 changed files with 5 additions and 8 deletions

View File

@ -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)
} }