mirror of
https://github.com/house-of-vanity/desubot.git
synced 2025-07-08 21:04:07 +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!()
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
//use crate::commands::Command;
|
||||
use crate::commands::{Execute, Here, Markov, MarkovAll, Omedeto, Sql, Top};
|
||||
use crate::commands::{Code, Execute, Here, Markov, MarkovAll, Omedeto, Sql, Top};
|
||||
use crate::db;
|
||||
use crate::errors;
|
||||
use crate::utils;
|
||||
@ -60,6 +60,13 @@ pub async fn handler(
|
||||
.await?;
|
||||
}
|
||||
},
|
||||
s if s.to_string().starts_with("/code") => {
|
||||
Code {
|
||||
data: s.to_string(),
|
||||
}
|
||||
.run(&api, &message)
|
||||
.await?
|
||||
}
|
||||
"/top" => {
|
||||
Top {
|
||||
data: "".to_string(),
|
||||
|
Reference in New Issue
Block a user