feat/tone-tags #26
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/tone-tags"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Add tone tag decoder that translates tone tags in thread
.expect()s 9082b86ca1530a45a9e6tob0203a3ca0@ -32,6 +32,14 @@ async fn on_room_message(event: OriginalSyncRoomMessageEvent, room: Room, clientlet message = text_content.body.trim();message.trim().lines().map(|line| {if let Some(tag) = line.split(" ").last().unwrap_or("").strip_prefix("/") {if let Err(e) = reply_tag(room, event, client, tag).await {tracing::error!("{e}");}};});ich empfehle gleich
message.split_whitespace()zu nehmen. Das ist robuster, falls jemand mehr als ein space oder tabs benutzt.Ausserdem:
awaitnicht in normalen loops, wenn du willst, kann ich das naeher erlaeutern.mapmachst, nutzt er den iterator nicht. Die iterator combinators sollten immer als letzte Operationcollecthaben wenn du output von der loop haben willstfor_eachhaben, wenn du einfach fuer jedes item irgendwas ausfuehren willstIn dem Fall hier sollte es eher sein:
bzw wenn du fancy sein willst sogar
Ist so besser? Dass es sich nur das letzte Wort anschaut, ist so gewollt, ausßer du denkst, das ist nicht gut. Aber ich wollte vermeiden, dass z.B. Linux-Dateipfade immer als tag identifiziert werden (
/etcoder so).Das mit
.awaitin loops würde mich atatsächlich interessieren ^^'@ -319,0 +402,20 @@"s" => "sarcastic / sarcastically","sarc" => "sarcastic / sarcastically","sbh" => "somebody here","sbtw" => "subtweeting","srs" => "serious","st" => "statement (see also: /naq)","state" => "statement (see also: /naq)","sx" => "sexual intent","x" => "sexual intent","t" => "teasing","tan" => "tangent","th" => "threat","tic" => "tic, for when something typed out was unintentional due to being a tic","ts" => "to self","u" => "upset","unin" => "unintentional","unre" => "unrelated","vu" => "very upset","w" => "warm / warmth",_ => "Unable to decode tone tag :/",Ich glaube ich wuerde hier dann einfach nichts machen in dem case und early returnen wenn es nicht matcht mit
Dann hast du auch das "Problem" mit den Dateipfaden nicht mehr weil du wirklich nur auf die fest definierten tone tags matchst.
@ -32,6 +32,21 @@ async fn on_room_message(event: OriginalSyncRoomMessageEvent, room: Room, clientlet message = text_content.body.trim();for line in message.lines() {if let Some(token) = line.split_whitespace().last().unwrap_or("").strip_prefix("/"){let _ = commands::reply_tag(room.clone(), &event, token).awaitAwait geht in loops nicht weil es nicht wirklich gut definiert ist, wie das funktionieren soll. Also rust kann dann nicht wissen, was du haben willst:
deswegen gibt's dafuer die "Stream" Abstraktion, die quasi ein async iterator ist. Die ist aber nicht im std drin, siehe hier fuer mehr
LGTM!