fmt
This commit is contained in:
parent
5007f5ddba
commit
298c0a7f6f
|
@ -101,7 +101,7 @@ impl<'de> Deserialize<'de> for Meme {
|
||||||
}
|
}
|
||||||
|
|
||||||
keyword = Some(map.next_value()?);
|
keyword = Some(map.next_value()?);
|
||||||
}
|
},
|
||||||
|
|
||||||
Field::Ident(i) => {
|
Field::Ident(i) => {
|
||||||
if ident.is_some() {
|
if ident.is_some() {
|
||||||
|
@ -113,12 +113,12 @@ impl<'de> Deserialize<'de> for Meme {
|
||||||
match i {
|
match i {
|
||||||
IdentField::Id => {
|
IdentField::Id => {
|
||||||
ident = Some(MemeIdent::Id(map.next_value()?));
|
ident = Some(MemeIdent::Id(map.next_value()?));
|
||||||
}
|
},
|
||||||
IdentField::RandomCat => {
|
IdentField::RandomCat => {
|
||||||
ident = Some(MemeIdent::RandomCat(map.next_value()?));
|
ident = Some(MemeIdent::RandomCat(map.next_value()?));
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
|
||||||
Field::Matcher => {
|
Field::Matcher => {
|
||||||
if matcher.is_some() {
|
if matcher.is_some() {
|
||||||
|
@ -126,7 +126,7 @@ impl<'de> Deserialize<'de> for Meme {
|
||||||
}
|
}
|
||||||
|
|
||||||
matcher = Some(map.next_value()?);
|
matcher = Some(map.next_value()?);
|
||||||
}
|
},
|
||||||
|
|
||||||
Field::MatchCase => {
|
Field::MatchCase => {
|
||||||
if match_case.is_some() {
|
if match_case.is_some() {
|
||||||
|
@ -134,7 +134,7 @@ impl<'de> Deserialize<'de> for Meme {
|
||||||
}
|
}
|
||||||
|
|
||||||
match_case = Some(map.next_value()?);
|
match_case = Some(map.next_value()?);
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
13
src/main.rs
13
src/main.rs
|
@ -10,11 +10,14 @@ use matrix_sdk::{
|
||||||
member::MemberEventContent,
|
member::MemberEventContent,
|
||||||
message::{MessageEventContent, MessageType, TextMessageEventContent},
|
message::{MessageEventContent, MessageType, TextMessageEventContent},
|
||||||
},
|
},
|
||||||
AnyToDeviceEvent, StrippedStateEvent, SyncMessageEvent,
|
AnyToDeviceEvent,
|
||||||
|
StrippedStateEvent,
|
||||||
|
SyncMessageEvent,
|
||||||
},
|
},
|
||||||
room::Room,
|
room::Room,
|
||||||
verification::Verification,
|
verification::Verification,
|
||||||
EventHandler, LoopCtrl,
|
EventHandler,
|
||||||
|
LoopCtrl,
|
||||||
};
|
};
|
||||||
use rand::{rngs::StdRng, SeedableRng};
|
use rand::{rngs::StdRng, SeedableRng};
|
||||||
use sled::Db;
|
use sled::Db;
|
||||||
|
@ -230,7 +233,7 @@ async fn on_response(response: &SyncResponse, client: &Client) -> anyhow::Result
|
||||||
error!("Error accepting key verification request: {}", e);
|
error!("Error accepting key verification request: {}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
|
||||||
AnyToDeviceEvent::KeyVerificationKey(e) => {
|
AnyToDeviceEvent::KeyVerificationKey(e) => {
|
||||||
if let Some(Verification::SasV1(sas)) = &client
|
if let Some(Verification::SasV1(sas)) = &client
|
||||||
|
@ -241,9 +244,9 @@ async fn on_response(response: &SyncResponse, client: &Client) -> anyhow::Result
|
||||||
error!("Error confirming key verification request: {}", e);
|
error!("Error confirming key verification request: {}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
|
||||||
_ => {}
|
_ => {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
16
src/meme.rs
16
src/meme.rs
|
@ -36,19 +36,17 @@ impl Meme {
|
||||||
msg.starts_with(&keyword) &&
|
msg.starts_with(&keyword) &&
|
||||||
// msg must have one of allowed chars after keyword
|
// msg must have one of allowed chars after keyword
|
||||||
msg.chars().nth(keyword.len()).map(|c| ALLOWED_SPACES.contains(c)).unwrap_or(true)
|
msg.chars().nth(keyword.len()).map(|c| ALLOWED_SPACES.contains(c)).unwrap_or(true)
|
||||||
}
|
},
|
||||||
|
|
||||||
Matcher::Contains => msg
|
Matcher::Contains => msg
|
||||||
.match_indices(&keyword)
|
.match_indices(&keyword)
|
||||||
.map(|(idx, subs)| {
|
.map(|(idx, subs)| {
|
||||||
(idx == 0
|
(idx == 0 ||
|
||||||
|| msg
|
msg.chars()
|
||||||
.chars()
|
|
||||||
.nth(idx - 1)
|
.nth(idx - 1)
|
||||||
.map(|c| ALLOWED_SPACES.contains(c))
|
.map(|c| ALLOWED_SPACES.contains(c))
|
||||||
.unwrap_or(true))
|
.unwrap_or(true)) &&
|
||||||
&& msg
|
msg.chars()
|
||||||
.chars()
|
|
||||||
.nth(idx + subs.len())
|
.nth(idx + subs.len())
|
||||||
.map(|c| ALLOWED_SPACES.contains(c))
|
.map(|c| ALLOWED_SPACES.contains(c))
|
||||||
.unwrap_or(true)
|
.unwrap_or(true)
|
||||||
|
@ -76,13 +74,13 @@ impl Meme {
|
||||||
&meme.id, &meme
|
&meme.id, &meme
|
||||||
);
|
);
|
||||||
Err(e.into())
|
Err(e.into())
|
||||||
}
|
},
|
||||||
Ok(id) => Ok(Some(id)),
|
Ok(id) => Ok(Some(id)),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,8 @@ pub mod mime_serialize {
|
||||||
use mime::Mime;
|
use mime::Mime;
|
||||||
use serde::{
|
use serde::{
|
||||||
de::{self, Unexpected, Visitor},
|
de::{self, Unexpected, Visitor},
|
||||||
Deserializer, Serializer,
|
Deserializer,
|
||||||
|
Serializer,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn serialize<S>(data: &Mime, serializer: S) -> Result<S::Ok, S::Error>
|
pub fn serialize<S>(data: &Mime, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
|
|
Loading…
Reference in a new issue