matrix-sdk: Fix the wasm bot example.

master
Damir Jelić 2020-08-26 16:19:39 +02:00
parent a2f7297941
commit 977e29c3af
2 changed files with 9 additions and 9 deletions

View File

@ -2,7 +2,7 @@ use matrix_sdk::{
api::r0::sync::sync_events::Response as SyncResponse, api::r0::sync::sync_events::Response as SyncResponse,
events::{ events::{
room::message::{MessageEventContent, TextMessageEventContent}, room::message::{MessageEventContent, TextMessageEventContent},
AnySyncMessageEvent, AnySyncRoomEvent, SyncMessageEvent, AnyMessageEventContent, AnySyncMessageEvent, AnySyncRoomEvent, SyncMessageEvent,
}, },
identifiers::RoomId, identifiers::RoomId,
Client, ClientConfig, SyncSettings, Client, ClientConfig, SyncSettings,
@ -32,15 +32,15 @@ impl WasmBot {
console::log_1(&format!("Received message event {:?}", &msg_body).into()); console::log_1(&format!("Received message event {:?}", &msg_body).into());
if msg_body.starts_with("!party") { if msg_body.starts_with("!party") {
let content = MessageEventContent::Text(TextMessageEventContent::plain( let content = AnyMessageEventContent::RoomMessage(MessageEventContent::Text(
"🎉🎊🥳 let's PARTY with wasm!! 🥳🎊🎉".to_string(), TextMessageEventContent::plain("🎉🎊🥳 let's PARTY with wasm!! 🥳🎊🎉".to_string()),
)); ));
self.0.room_send(&room_id, content, None).await.unwrap(); self.0.room_send(&room_id, content, None).await.unwrap();
} }
} }
async fn on_sync_response(&self, response: SyncResponse) { async fn on_sync_response(&self, response: SyncResponse) {
console::log_1(&format!("Synced").into()); console::log_1(&"Synced".to_string().into());
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 {

View File

@ -28,21 +28,21 @@ use matrix_sdk_common::{
api::r0 as api, api::r0 as api,
events::{ events::{
ignored_user_list::IgnoredUserListEvent, push_rules::PushRulesEvent, ignored_user_list::IgnoredUserListEvent, push_rules::PushRulesEvent,
room::member::MemberEventContent, AnyBasicEvent, AnyMessageEventContent, room::member::MemberEventContent, AnyBasicEvent, AnyStrippedStateEvent,
AnyStrippedStateEvent, AnySyncEphemeralRoomEvent, AnySyncMessageEvent, AnySyncRoomEvent, AnySyncEphemeralRoomEvent, AnySyncMessageEvent, AnySyncRoomEvent, AnySyncStateEvent,
AnySyncStateEvent,
}, },
identifiers::{RoomId, UserId}, identifiers::{RoomId, UserId},
locks::RwLock, locks::RwLock,
push::Ruleset, push::Ruleset,
uuid::Uuid,
Raw, Raw,
}; };
#[cfg(feature = "encryption")] #[cfg(feature = "encryption")]
use matrix_sdk_common::{ use matrix_sdk_common::{
api::r0::keys::claim_keys::Request as KeysClaimRequest, api::r0::keys::claim_keys::Request as KeysClaimRequest,
api::r0::to_device::send_event_to_device::IncomingRequest as OwnedToDeviceRequest, api::r0::to_device::send_event_to_device::IncomingRequest as OwnedToDeviceRequest,
events::room::encrypted::EncryptedEventContent, identifiers::DeviceId, events::{room::encrypted::EncryptedEventContent, AnyMessageEventContent},
identifiers::DeviceId,
uuid::Uuid,
}; };
#[cfg(feature = "encryption")] #[cfg(feature = "encryption")]
use matrix_sdk_crypto::{ use matrix_sdk_crypto::{