format c
This commit is contained in:
parent
37eb3f5246
commit
ff5148d944
30
src/main.rs
30
src/main.rs
@ -8,9 +8,9 @@ use matrix_sdk::{
|
|||||||
Client, Room, RoomState,
|
Client, Room, RoomState,
|
||||||
};
|
};
|
||||||
|
|
||||||
use rumqttc::{MqttOptions, AsyncClient, QoS};
|
use rumqttc::{AsyncClient, MqttOptions, QoS};
|
||||||
use std::time::Duration;
|
|
||||||
use std::thread;
|
use std::thread;
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
async fn on_room_message(event: OriginalSyncRoomMessageEvent, room: Room) {
|
async fn on_room_message(event: OriginalSyncRoomMessageEvent, room: Room) {
|
||||||
if room.state() != RoomState::Joined {
|
if room.state() != RoomState::Joined {
|
||||||
@ -21,18 +21,28 @@ async fn on_room_message(event: OriginalSyncRoomMessageEvent, room: Room) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if text_content.body.contains("!party") {
|
if text_content.body.contains("!party") {
|
||||||
|
|
||||||
// mosquitto_pub -h mqtt.chaospott.de -t foobar/oben/licht -m "baellebad,100"
|
// mosquitto_pub -h mqtt.chaospott.de -t foobar/oben/licht -m "baellebad,100"
|
||||||
|
|
||||||
let mut mqttoptions = MqttOptions::new("rumqtt-sync", "mqtt.chaospott.de", 1883);
|
let mut mqttoptions = MqttOptions::new("rumqtt-sync", "localhost", 1883);
|
||||||
mqttoptions.set_keep_alive(Duration::from_secs(5));
|
mqttoptions.set_keep_alive(Duration::from_secs(5));
|
||||||
|
|
||||||
let (mut client, mut eventloop) = AsyncClient::new(mqttoptions, 10);
|
let (mut client, mut eventloop) = AsyncClient::new(mqttoptions, 10);
|
||||||
|
|
||||||
if let Ok(resp) = client.publish("foobert/willwas", QoS::AtLeastOnce, false, vec![3; 3]).await {
|
let payload = "testtesttest";
|
||||||
|
|
||||||
|
if let Ok(resp) = client
|
||||||
|
.publish(
|
||||||
|
"foobert/willwas",
|
||||||
|
QoS::AtLeastOnce,
|
||||||
|
true,
|
||||||
|
payload.as_bytes(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
{
|
||||||
println!("{:?}", resp)
|
println!("{:?}", resp)
|
||||||
|
} else {
|
||||||
|
println!("fuckit")
|
||||||
}
|
}
|
||||||
else { println!("fuckit") }
|
|
||||||
|
|
||||||
let content = RoomMessageEventContent::text_plain("🎉🎊🥳 let's PARTY!! 🥳🎊🎉");
|
let content = RoomMessageEventContent::text_plain("🎉🎊🥳 let's PARTY!! 🥳🎊🎉");
|
||||||
|
|
||||||
@ -53,7 +63,11 @@ async fn login_and_sync(
|
|||||||
// Note that when encryption is enabled, you should use a persistent store to be
|
// Note that when encryption is enabled, you should use a persistent store to be
|
||||||
// able to restore the session with a working encryption setup.
|
// able to restore the session with a working encryption setup.
|
||||||
// See the `persist_session` example.
|
// See the `persist_session` example.
|
||||||
let client = Client::builder().homeserver_url(homeserver_url).build().await.unwrap();
|
let client = Client::builder()
|
||||||
|
.homeserver_url(homeserver_url)
|
||||||
|
.build()
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
client
|
client
|
||||||
.matrix_auth()
|
.matrix_auth()
|
||||||
.login_username(&username, &password)
|
.login_username(&username, &password)
|
||||||
@ -79,8 +93,6 @@ async fn login_and_sync(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> anyhow::Result<()> {
|
async fn main() -> anyhow::Result<()> {
|
||||||
tracing_subscriber::fmt::init();
|
tracing_subscriber::fmt::init();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user