Compare commits
No commits in common. "c2d9dcdd744ae8bff63a6e8805df58eea383df8d" and "6611f239f796c2b35cdf93f5b0eb8f2a561e27a7" have entirely different histories.
c2d9dcdd74
...
6611f239f7
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -1483,7 +1483,6 @@ dependencies = [
|
||||||
"colored",
|
"colored",
|
||||||
"futures",
|
"futures",
|
||||||
"headers",
|
"headers",
|
||||||
"lazy_static",
|
|
||||||
"lettre",
|
"lettre",
|
||||||
"log",
|
"log",
|
||||||
"mediawiki",
|
"mediawiki",
|
||||||
|
|
|
@ -24,7 +24,6 @@ nom = "7.1.3"
|
||||||
mediawiki = "0.3.1"
|
mediawiki = "0.3.1"
|
||||||
ollama-rs = "0.2.1"
|
ollama-rs = "0.2.1"
|
||||||
tokio = "1.0.0"
|
tokio = "1.0.0"
|
||||||
lazy_static = "1.4"
|
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "Plenum-Bot"
|
name = "Plenum-Bot"
|
||||||
|
|
|
@ -46,11 +46,6 @@ pub const CONFIG: CfgGroup<'static> = CfgGroup {
|
||||||
description:
|
description:
|
||||||
"Message-Id of last initial announcement to send In-Reply-To (if applicable).",
|
"Message-Id of last initial announcement to send In-Reply-To (if applicable).",
|
||||||
},
|
},
|
||||||
CfgField::Default {
|
|
||||||
key: "state-toc",
|
|
||||||
default: "error: no toc saved",
|
|
||||||
description: "Recipient of the emails sent.",
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,6 @@ impl KeyValueStore {
|
||||||
let result = row.get(0)?;
|
let result = row.get(0)?;
|
||||||
Ok(result)
|
Ok(result)
|
||||||
} else {
|
} else {
|
||||||
println!(": Keinen Wert für '{key}' gefunden, bitte Datenbank überprüfen!");
|
|
||||||
Err(rusqlite::Error::QueryReturnedNoRows)
|
Err(rusqlite::Error::QueryReturnedNoRows)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
67
src/main.rs
67
src/main.rs
|
@ -59,7 +59,7 @@ const CONFIG_SPEC: CfgSpec<'static> = CfgSpec {
|
||||||
description: "Various strings used.",
|
description: "Various strings used.",
|
||||||
fields: &[
|
fields: &[
|
||||||
CfgField::Default { key: "email-greeting",
|
CfgField::Default { key: "email-greeting",
|
||||||
default: "Hallo liebe Mitreisenden,",
|
default: "Hallo liebe Mitreisende,",
|
||||||
description: "\"Hello\"-greeting added at the start of every email.",
|
description: "\"Hello\"-greeting added at the start of every email.",
|
||||||
},
|
},
|
||||||
CfgField::Default { key: "email-signature",
|
CfgField::Default { key: "email-signature",
|
||||||
|
@ -400,23 +400,13 @@ fn do_announcement(
|
||||||
"Falls ihr noch Themen ergänzen wollt ist hier der Link zum Pad:\n {}",
|
"Falls ihr noch Themen ergänzen wollt ist hier der Link zum Pad:\n {}",
|
||||||
hedgedoc.format_url(¤t_pad_id)
|
hedgedoc.format_url(¤t_pad_id)
|
||||||
);
|
);
|
||||||
let mut body = format!("{line1}\n\n{line2}");
|
let body = format!("{line1}\n\n{line2}");
|
||||||
// send it
|
// send it
|
||||||
let message_id = send_email(&subject, &body, email, config)?;
|
let message_id = send_email(&subject, &body, email, config)?;
|
||||||
// on success, update state (ignore write errors, they'll be checked later)
|
// on success, update state (ignore write errors, they'll be checked later)
|
||||||
config.set("email-message-id", &message_id).ok();
|
config.set("email-message-id", &message_id).ok();
|
||||||
config.set("state-name", &ProgramState::Announced.to_string()).ok();
|
config.set("state-name", &ProgramState::Announced.to_string()).ok();
|
||||||
config.set("email-state-toc", &toc).ok();
|
config.set("state-toc", &toc).ok();
|
||||||
let mut matrix = MatrixClient::new(
|
|
||||||
&config["matrix-homeserver-url"],
|
|
||||||
&config["matrix-user-id"],
|
|
||||||
&config["matrix-access-token"],
|
|
||||||
&config["matrix-room-id-1"],
|
|
||||||
&config["matrix-room-id-2"],
|
|
||||||
is_dry_run(),
|
|
||||||
);
|
|
||||||
let message = format!("{}\n\n{}{}",&config["text-email-greeting"], &body, &config["text-email-signature"]);
|
|
||||||
matrix.send_message_to_two_rooms(&message)?;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -427,7 +417,7 @@ fn do_reminder(
|
||||||
NYI!("trace/verbose annotations");
|
NYI!("trace/verbose annotations");
|
||||||
// fetch current pad contents & summarize
|
// fetch current pad contents & summarize
|
||||||
let (current_pad_id, _pad_content, toc, n_topics) = get_pad_info(config, hedgedoc);
|
let (current_pad_id, _pad_content, toc, n_topics) = get_pad_info(config, hedgedoc);
|
||||||
let old_toc = config.get("email-state-toc")?;
|
let old_toc = config.get("state-toc")?;
|
||||||
// construct email
|
// construct email
|
||||||
let human_date = plenum_day.format("%d.%m.%Y");
|
let human_date = plenum_day.format("%d.%m.%Y");
|
||||||
let subject = if n_topics == 0 {
|
let subject = if n_topics == 0 {
|
||||||
|
@ -446,7 +436,7 @@ fn do_reminder(
|
||||||
} else {
|
} else {
|
||||||
format!("Es gab nochmal Änderungen, die aktualisierten Themen für das Plenum sind:\n\n{toc}\n\n")
|
format!("Es gab nochmal Änderungen, die aktualisierten Themen für das Plenum sind:\n\n{toc}\n\n")
|
||||||
};
|
};
|
||||||
let mut body = if n_topics > 0 {
|
let body = if n_topics > 0 {
|
||||||
format!(
|
format!(
|
||||||
"{body_prefix}Die vollen Details findet ihr im Pad:\n {}\n\nBis {} um 20:00!",
|
"{body_prefix}Die vollen Details findet ihr im Pad:\n {}\n\nBis {} um 20:00!",
|
||||||
hedgedoc.format_url(¤t_pad_id),
|
hedgedoc.format_url(¤t_pad_id),
|
||||||
|
@ -467,21 +457,9 @@ fn do_reminder(
|
||||||
NYI!(
|
NYI!(
|
||||||
"do we skip ahead to ProgramState::Logged here or do we later add a note to the wiki?"
|
"do we skip ahead to ProgramState::Logged here or do we later add a note to the wiki?"
|
||||||
);
|
);
|
||||||
// TODO: ADD SOMETHING TO WIKI
|
|
||||||
}
|
}
|
||||||
|
|
||||||
config.set("state-name", &ProgramState::Reminded.to_string()).ok();
|
config.set("state-name", &ProgramState::Reminded.to_string()).ok();
|
||||||
config.set("email-state-toc", &toc).ok();
|
config.set("state-toc", &toc).ok();
|
||||||
let mut matrix = MatrixClient::new(
|
|
||||||
&config["matrix-homeserver-url"],
|
|
||||||
&config["matrix-user-id"],
|
|
||||||
&config["matrix-access-token"],
|
|
||||||
&config["matrix-room-id-1"],
|
|
||||||
&config["matrix-room-id-2"],
|
|
||||||
is_dry_run(),
|
|
||||||
);
|
|
||||||
let message = format!("{}\n\n{}{}",&config["text-email-greeting"], &body, &config["text-email-signature"]);
|
|
||||||
matrix.send_message_to_two_rooms(&message)?;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -522,7 +500,7 @@ fn do_protocol(
|
||||||
let pad_content = pad_content.replace("[toc]", &toc);
|
let pad_content = pad_content.replace("[toc]", &toc);
|
||||||
let body = format!(
|
let body = format!(
|
||||||
"Anbei das Protokoll vom {human_date}, ab sofort auch im Wiki zu finden.\n\n\
|
"Anbei das Protokoll vom {human_date}, ab sofort auch im Wiki zu finden.\n\n\
|
||||||
Das Pad für das nächste Plenum ist zu finden unter <{}/{}>.\n\nDie Protokolle der letzten Plena findet ihr im wiki unter <{}/index.php?title={}>.\n\n---Protokoll:---\n{}\n-----",
|
Das Pad für das nächste Plenum ist zu finden unter <{}/{}>.\nDie Protokolle der letzten Plena findet ihr im wiki unter <{}/index.php?title={}>.\n\n---Protokoll:---\n{}\n-----",
|
||||||
&config["hedgedoc-server-url"],
|
&config["hedgedoc-server-url"],
|
||||||
&config["hedgedoc-next-id"],
|
&config["hedgedoc-next-id"],
|
||||||
&config["wiki-server-url"],
|
&config["wiki-server-url"],
|
||||||
|
@ -539,7 +517,7 @@ fn do_protocol(
|
||||||
let pad_content = pad_content.replace("[toc]", &toc);
|
let pad_content = pad_content.replace("[toc]", &toc);
|
||||||
let body = format!(
|
let body = format!(
|
||||||
"Anbei das Protokoll vom {human_date}, ab sofort auch im Wiki zu finden.\n\n\
|
"Anbei das Protokoll vom {human_date}, ab sofort auch im Wiki zu finden.\n\n\
|
||||||
Das Pad für das nächste Plenum ist zu finden unter {}/{}.\n\nDie Protokolle der letzten Plena findet ihr im wiki unter {}/index.php?title={}.\n\n---Protokoll:---{}",
|
Das Pad für das nächste Plenum ist zu finden unter {}/{}.\nDie Protokolle der letzten Plena findet ihr im wiki unter {}/index.php?title={}.\n\n---Protokoll:---{}",
|
||||||
&config["hedgedoc-server-url"],
|
&config["hedgedoc-server-url"],
|
||||||
&config["hedgedoc-next-id"],
|
&config["hedgedoc-next-id"],
|
||||||
&config["wiki-server-url"],
|
&config["wiki-server-url"],
|
||||||
|
@ -554,24 +532,39 @@ fn do_protocol(
|
||||||
&config["matrix-homeserver-url"],
|
&config["matrix-homeserver-url"],
|
||||||
&config["matrix-user-id"],
|
&config["matrix-user-id"],
|
||||||
&config["matrix-access-token"],
|
&config["matrix-access-token"],
|
||||||
&config["matrix-room-id-1"],
|
&config["matrix-room-id-for-short-messages"],
|
||||||
&config["matrix-room-id-2"],
|
&config["matrix-room-id-for-long-messages"],
|
||||||
is_dry_run(),
|
is_dry_run(),
|
||||||
);
|
);
|
||||||
// Send the matrix room message
|
// Send the matrix room message
|
||||||
let human_date = plenum_day.format("%d.%m.%Y");
|
let human_date = plenum_day.format("%d.%m.%Y");
|
||||||
let pad_content = pad_content.replace("[toc]", &toc);
|
let pad_content = pad_content.replace("[toc]", &toc);
|
||||||
let message = format!(
|
let long_message = format!(
|
||||||
"Anbei das Protokoll vom {human_date}, ab sofort auch im Wiki zu finden.\n\n\
|
"Anbei das Protokoll vom {human_date}, ab sofort auch im Wiki zu finden.\n\n\
|
||||||
Das Pad für das nächste Plenum ist zu finden unter {}/{}.\n\nDie Protokolle der letzten Plena findet ihr im wiki unter {}/index.php?title={}.\n\n**Hier die Zusammenfassung:**\n\n{}",
|
Das Pad für das nächste Plenum ist zu finden unter {}/{}.\nDie Protokolle der letzten Plena findet ihr im wiki unter {}/index.php?title={}.\n**Hier die Zusammenfassung:**\n{}",
|
||||||
&config["hedgedoc-server-url"],
|
&config["hedgedoc-server-url"],
|
||||||
&config["hedgedoc-next-id"],
|
&config["hedgedoc-next-id"],
|
||||||
&config["wiki-server-url"],
|
&config["wiki-server-url"],
|
||||||
&config["wiki-plenum-page"],
|
&config["wiki-plenum-page"],
|
||||||
&summary_or_toc
|
&summary_or_toc
|
||||||
);
|
);
|
||||||
let full_message = format!("{}\n\n{}{}",&config["text-email-greeting"], &message, &config["text-email-signature"]);
|
let full_long_message = format!(
|
||||||
matrix.send_message_to_two_rooms(&full_message)?;
|
"{}\n{}{}",
|
||||||
|
&config["text-email-greeting"], long_message, &config["text-email-signature"]
|
||||||
|
);
|
||||||
|
let short_message = format!(
|
||||||
|
"Das letzte Plenum hatte Anbei das Protokoll vom {human_date}, ab sofort auch im Wiki zu finden.\n\n\
|
||||||
|
Das Pad für das nächste Plenum ist zu finden unter {}/{}.\nDie Protokolle der letzten Plena findet ihr im wiki unter {}/index.php?title={}.",
|
||||||
|
&config["hedgedoc-server-url"],
|
||||||
|
&config["hedgedoc-next-id"],
|
||||||
|
&config["wiki-server-url"],
|
||||||
|
&config["wiki-plenum-page"]
|
||||||
|
);
|
||||||
|
let full_short_message = format!(
|
||||||
|
"{}\n{}{}",
|
||||||
|
&config["text-email-greeting"], short_message, &config["text-email-signature"].strip_prefix("[").unwrap_or(&config["text-email-signature"]).strip_suffix("]").unwrap_or(&config["text-email-signature"])
|
||||||
|
);
|
||||||
|
matrix.send_short_and_long_messages_to_two_rooms(&full_short_message, &full_long_message)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -583,7 +576,7 @@ fn do_cleanup(
|
||||||
_wiki: &Mediawiki,
|
_wiki: &Mediawiki,
|
||||||
) -> Result<(), Box<dyn Error>> {
|
) -> Result<(), Box<dyn Error>> {
|
||||||
NYI!("trace/verbose annotations");
|
NYI!("trace/verbose annotations");
|
||||||
config.delete("email-state-toc");
|
config.delete("state-toc");
|
||||||
config.delete("email-last-message-id");
|
config.delete("email-last-message-id");
|
||||||
NYI!("rotate pad links");
|
NYI!("rotate pad links");
|
||||||
NYI!("double-check state for leftovers");
|
NYI!("double-check state for leftovers");
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
use lazy_static::lazy_static;
|
|
||||||
|
|
||||||
use colored::Colorize;
|
use colored::Colorize;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
@ -33,12 +32,12 @@ pub const CONFIG: CfgGroup<'static> = CfgGroup {
|
||||||
description: "Access Token / \"password\" used for authenticating as the bot.",
|
description: "Access Token / \"password\" used for authenticating as the bot.",
|
||||||
},
|
},
|
||||||
CfgField::Default {
|
CfgField::Default {
|
||||||
key: "room-id-1",
|
key: "room-id-for-long-messages",
|
||||||
default: "!someLongRoomIdentifier:matrix.org",
|
default: "!someLongRoomIdentifier:matrix.org",
|
||||||
description: "API Username associated with the bot account used for writing messages.",
|
description: "API Username associated with the bot account used for writing messages.",
|
||||||
},
|
},
|
||||||
CfgField::Default {
|
CfgField::Default {
|
||||||
key: "room-id-2",
|
key: "room-id-for-short-messages",
|
||||||
default: "!someLongRoomIdentifier:matrix.org",
|
default: "!someLongRoomIdentifier:matrix.org",
|
||||||
description: "API Username associated with the bot account used for writing messages.",
|
description: "API Username associated with the bot account used for writing messages.",
|
||||||
},
|
},
|
||||||
|
@ -52,8 +51,8 @@ pub struct MatrixClient {
|
||||||
is_dry_run: bool,
|
is_dry_run: bool,
|
||||||
client: Client,
|
client: Client,
|
||||||
txn_id: u64,
|
txn_id: u64,
|
||||||
room_id_1: String,
|
room_id_for_short_messages: String,
|
||||||
room_id_2: String,
|
room_id_for_long_messages: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
@ -83,8 +82,8 @@ impl std::fmt::Debug for MatrixClient {
|
||||||
|
|
||||||
impl MatrixClient {
|
impl MatrixClient {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
homeserver_url: &str, user_id: &str, access_token: &str, room_id_1: &str,
|
homeserver_url: &str, user_id: &str, access_token: &str, room_id_for_short_messages: &str,
|
||||||
room_id_2: &str, is_dry_run: bool,
|
room_id_for_long_messages: &str, is_dry_run: bool,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
homeserver_url: homeserver_url.to_string(),
|
homeserver_url: homeserver_url.to_string(),
|
||||||
|
@ -93,8 +92,8 @@ impl MatrixClient {
|
||||||
is_dry_run,
|
is_dry_run,
|
||||||
client: Client::builder().cookie_store(true).build().unwrap(),
|
client: Client::builder().cookie_store(true).build().unwrap(),
|
||||||
txn_id: SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs(),
|
txn_id: SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs(),
|
||||||
room_id_2: room_id_2.to_string(),
|
room_id_for_long_messages: room_id_for_long_messages.to_string(),
|
||||||
room_id_1: room_id_1.to_string(),
|
room_id_for_short_messages: room_id_for_short_messages.to_string(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn request<T: Serialize>(
|
fn request<T: Serialize>(
|
||||||
|
@ -103,7 +102,7 @@ impl MatrixClient {
|
||||||
) -> Result<Value, Box<dyn Error>> {
|
) -> Result<Value, Box<dyn Error>> {
|
||||||
let client = reqwest::blocking::Client::new();
|
let client = reqwest::blocking::Client::new();
|
||||||
let url = format!("{}/_matrix/client{}", self.homeserver_url, endpoint);
|
let url = format!("{}/_matrix/client{}", self.homeserver_url, endpoint);
|
||||||
verboseln!("url: {}\n", url.blue());
|
print!("url: {}", url.yellow());
|
||||||
|
|
||||||
// Construct URL with query parameters
|
// Construct URL with query parameters
|
||||||
let mut request = client.request(method, &url);
|
let mut request = client.request(method, &url);
|
||||||
|
@ -177,28 +176,41 @@ impl MatrixClient {
|
||||||
current
|
current
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn format_text_to_html(markdown: String) -> Result<String, Box<dyn Error>> {
|
pub fn pandoc_convert_md_to_html(markdown: String) -> Result<String, Box<dyn Error>> {
|
||||||
lazy_static! {
|
let (output, errors, status) = crate::pipe(
|
||||||
static ref MATRIX_BOLD: Regex = Regex::new(r"\*\*(.+?)\*\*").unwrap();
|
"pandoc",
|
||||||
static ref MATRIX_ITALIC: Regex = Regex::new(r"\*(.+?)\*").unwrap();
|
&mut [
|
||||||
static ref MATRIX_URL: Regex = Regex::new(r"(https?://\S+?)(?:[.,])?(?:\s|$)").unwrap();
|
"--from", "markdown-auto_identifiers",
|
||||||
|
"--to", "html5",
|
||||||
|
"--wrap=none", // Verhindert Zeilenumbrüche
|
||||||
|
"--no-highlight", // Deaktiviert Syntax-Highlighting
|
||||||
|
],
|
||||||
|
markdown,
|
||||||
|
)?;
|
||||||
|
if status.success() {
|
||||||
|
println!("Resultat von Pandoc: {}", output);
|
||||||
|
Ok(output)
|
||||||
|
} else {
|
||||||
|
Err(format!("Pandoc error, exit code {:?}\n{}", status, errors).into())
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let mut html = markdown;
|
pub fn format_matrix_html(markdown: String) -> Result<String, Box<dyn Error>> {
|
||||||
|
let mut html = Self::pandoc_convert_md_to_html(markdown)?;
|
||||||
|
|
||||||
// Handle URLs first
|
let url_regex = Regex::new(r"(https?://[^\s<]+)")?;
|
||||||
html = MATRIX_URL.replace_all(&html, r"<a href='$1'>$1</a>").to_string();
|
html = url_regex.replace_all(&html, r#"<a href="$1">$1</a>"#).to_string();
|
||||||
|
|
||||||
// Basic formatting
|
html = html.replace("\n\n", "</p><p>");
|
||||||
html = MATRIX_BOLD.replace_all(&html, r"<b>$1</b>").to_string();
|
|
||||||
html = MATRIX_ITALIC.replace_all(&html, r"<i>$1</i>").to_string();
|
|
||||||
|
|
||||||
// Convert newlines to <br>
|
|
||||||
html = html.replace("\n", "<br>");
|
html = html.replace("\n", "<br>");
|
||||||
|
|
||||||
|
html = html.replace("**", "<strong>");
|
||||||
|
html = html.replace("__", "<strong>");
|
||||||
|
|
||||||
Ok(html)
|
Ok(html)
|
||||||
}
|
}
|
||||||
pub fn pandoc_convert_text_to_md(markdown: String) -> Result<String, Box<dyn Error>> {
|
|
||||||
|
pub fn pandoc_convert_text_to_md(markdown: String) -> Result<String, Box<dyn Error>> {
|
||||||
let (output, errors, status) = crate::pipe(
|
let (output, errors, status) = crate::pipe(
|
||||||
"pandoc",
|
"pandoc",
|
||||||
&mut ["--from", "markdown-auto_identifiers", "--to", "html5"],
|
&mut ["--from", "markdown-auto_identifiers", "--to", "html5"],
|
||||||
|
@ -215,14 +227,14 @@ impl MatrixClient {
|
||||||
pub fn send_room_message(
|
pub fn send_room_message(
|
||||||
&mut self, room_id: &str, text: &str,
|
&mut self, room_id: &str, text: &str,
|
||||||
) -> Result<Value, Box<dyn Error>> {
|
) -> Result<Value, Box<dyn Error>> {
|
||||||
let formatted_text = Self::format_text_to_html(text.to_string())?;
|
let formatted_text = Self::format_matrix_html(text.to_string())?;
|
||||||
let content = HashMap::from([
|
let content = HashMap::from([
|
||||||
("type", "m.room.message"),
|
("type", "m.room.message"),
|
||||||
("msgtype", "m.text"),
|
("msgtype", "m.text"),
|
||||||
("body", text),
|
("body", text),
|
||||||
("format", "org.matrix.custom.html"),
|
("format", "org.matrix.custom.html"),
|
||||||
("formatted_body", &formatted_text),
|
("formatted_body", &formatted_text),
|
||||||
// ("m.mentions", "{}"),
|
("m.mentions", "{}"),
|
||||||
]);
|
]);
|
||||||
self.send_room_event(&room_id, "m.room.message", &content)
|
self.send_room_event(&room_id, "m.room.message", &content)
|
||||||
}
|
}
|
||||||
|
@ -231,14 +243,14 @@ impl MatrixClient {
|
||||||
&mut self, room: &str, event_type: &str, content: &impl Serialize,
|
&mut self, room: &str, event_type: &str, content: &impl Serialize,
|
||||||
) -> Result<Value, Box<dyn Error>> {
|
) -> Result<Value, Box<dyn Error>> {
|
||||||
let endpoint = format!("/r0/rooms/{}/send/{}/{}", room, event_type, self.txn_id());
|
let endpoint = format!("/r0/rooms/{}/send/{}/{}", room, event_type, self.txn_id());
|
||||||
verboseln!("room event:{}", &endpoint.green());
|
println!("room event:{}", &endpoint.red());
|
||||||
self.put(&endpoint, None, Some(content), false)
|
self.put(&endpoint, None, Some(content), false)
|
||||||
}
|
}
|
||||||
pub fn send_message_to_two_rooms(
|
pub fn send_short_and_long_messages_to_two_rooms(
|
||||||
&mut self, message: &str
|
&mut self, short_message: &str, long_message: &str,
|
||||||
) -> Result<(), Box<dyn Error>> {
|
) -> Result<(), Box<dyn Error>> {
|
||||||
self.send_room_message( &self.room_id_2.clone(), &message,)?;
|
self.send_room_message( &self.room_id_for_long_messages.clone(), &long_message,)?;
|
||||||
self.send_room_message( &self.room_id_1.clone(), &message,)?;
|
self.send_room_message( &self.room_id_for_short_messages.clone(), &short_message,)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue