mirror of
https://github.com/house-of-vanity/desubot.git
synced 2025-07-08 13:04:06 +00:00
Rebase
This commit is contained in:
@ -13,6 +13,7 @@ use mystem::Tense::{Inpresent, Past};
|
||||
use rand::seq::SliceRandom;
|
||||
use rand::Rng;
|
||||
use regex::Regex;
|
||||
use silicon;
|
||||
use sqlparser::ast::Statement;
|
||||
use sqlparser::dialect::GenericDialect;
|
||||
use sqlparser::parser::Parser;
|
||||
@ -38,6 +39,10 @@ pub struct Sql {
|
||||
pub data: String,
|
||||
}
|
||||
|
||||
pub struct Code {
|
||||
pub data: String,
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
pub trait Execute {
|
||||
async fn exec(&self, api: &Api, message: &Message) -> Result<(), Error>;
|
||||
@ -541,3 +546,28 @@ impl Execute for Omedeto {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl Execute for Code {
|
||||
async fn run(&self, api: &Api, message: &Message) -> Result<(), Error> {
|
||||
let lang = "Rust";
|
||||
let theme = "Dracula";
|
||||
let code = &self.data;
|
||||
let (ps, ts) = silicon::utils::init_syntect();
|
||||
let syntax = ps
|
||||
.find_syntax_by_token(lang)
|
||||
.ok_or_else(|| ps.find_syntax_by_token("js"));
|
||||
let theme = ts.themes.get(theme).ok_or_else(|| ts.themes.get("1337"));
|
||||
debug!("{:?}", code);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn run_mystem(
|
||||
&self,
|
||||
api: &Api,
|
||||
message: &Message,
|
||||
mystem: &mut MyStem,
|
||||
) -> Result<(), Error> {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user