fix warnings in botscript.rs

This commit is contained in:
Akulij 2025-06-07 02:27:05 +05:00
parent 0c3fb0788a
commit e6c9cfb0c1

View File

@ -760,7 +760,11 @@ impl NotificationFilter {
NotificationFilter::Random { random } => Ok(db.get_random_users(*random).await?),
NotificationFilter::BotFunction(f) => {
let users = f.call()?;
let users = from_js(f.context().unwrap(), &users)?;
// we just called function, so context is definetly valid
let users = from_js(
f.context().expect("Context invalid after function call"),
&users,
)?;
Ok(users)
}
}
@ -768,7 +772,7 @@ impl NotificationFilter {
}
impl Parcelable<BotFunction> for NotificationFilter {
fn get_field(&mut self, name: &str) -> ParcelableResult<ParcelType<BotFunction>> {
fn get_field(&mut self, _name: &str) -> ParcelableResult<ParcelType<BotFunction>> {
todo!()
}
@ -798,7 +802,7 @@ pub enum NotificationMessage {
}
impl Parcelable<BotFunction> for NotificationMessage {
fn get_field(&mut self, name: &str) -> ParcelableResult<ParcelType<BotFunction>> {
fn get_field(&mut self, _name: &str) -> ParcelableResult<ParcelType<BotFunction>> {
todo!()
}
@ -1060,7 +1064,6 @@ impl Runner {
#[allow(clippy::unwrap_used)]
#[allow(clippy::print_stdout)]
mod tests {
use quickjs_rusty::OwnedJsObject;
use serde_json::json;
use super::*;
@ -1106,22 +1109,6 @@ mod tests {
assert_eq!(sres, "cancelation");
}
fn recursive_format(o: OwnedJsObject) -> String {
let props: Vec<_> = o.properties_iter().unwrap().map(|x| x.unwrap()).collect();
let sp: Vec<String> = props
.into_iter()
.map(|v| {
if v.is_object() {
recursive_format(v.try_into_object().unwrap())
} else {
format!("{:?}", v)
}
})
.collect();
format!("{:?}", sp)
}
#[test]
fn test_run_script_invalid() {
let runner = Runner::init().unwrap();