Compare commits

...

4 Commits

Author SHA1 Message Date
Sense T
bb06d2678c update flake.lock 2024-10-12 13:41:22 +08:00
Sense T
f5a83a0c90 toolchain 2024-02-29 10:57:21 +08:00
Sense T
064565ff00 bugf 2024-02-29 10:47:45 +08:00
Sense T
90fdef4363 version 2024-02-04 13:29:39 +08:00
4 changed files with 36 additions and 28 deletions

View File

@ -4,7 +4,7 @@ ENV RUSTFLAGS="-C target-feature=-crt-static"
WORKDIR /usr/src/saysthbot
COPY . .
RUN apk add --no-cache rustup openssl-dev build-base && \
rustup-init -y --default-toolchain nightly && \
rustup-init -y --default-toolchain nightly-2024-02-04 && \
source ${HOME}/.cargo/env && cargo build --release
FROM alpine

View File

@ -11,4 +11,4 @@ secretGenerator:
images:
- name: <Image>
newName: ghcr.io/senseab/hangitbot
newTag: v0.0.3
newTag: v0.1.2

24
flake.lock generated
View File

@ -5,11 +5,11 @@
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1698420672,
"narHash": "sha256-/TdeHMPRjjdJub7p7+w55vyABrsJlt5QkznPYy55vKA=",
"lastModified": 1721727458,
"narHash": "sha256-r/xppY958gmZ4oTfLiHN0ZGuQ+RSTijDblVgVLFi1mw=",
"owner": "nix-community",
"repo": "naersk",
"rev": "aeb58d5e8faead8980a807c840232697982d47b9",
"rev": "3fb418eaf352498f6b6c30592e3beb63df42ef11",
"type": "github"
},
"original": {
@ -21,11 +21,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1699186365,
"narHash": "sha256-Pxrw5U8mBsL3NlrJ6q1KK1crzvSUcdfwb9083sKDrcU=",
"lastModified": 1728538411,
"narHash": "sha256-f0SBJz1eZ2yOuKUr5CA9BHULGXVSn6miBuUWdTyhUhU=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "a0b3b06b7a82c965ae0bb1d59f6e386fe755001d",
"rev": "b69de56fac8c2b6f8fd27f2eca01dcda8e0a4221",
"type": "github"
},
"original": {
@ -35,11 +35,11 @@
},
"nixpkgs_2": {
"locked": {
"lastModified": 1699186365,
"narHash": "sha256-Pxrw5U8mBsL3NlrJ6q1KK1crzvSUcdfwb9083sKDrcU=",
"lastModified": 1728538411,
"narHash": "sha256-f0SBJz1eZ2yOuKUr5CA9BHULGXVSn6miBuUWdTyhUhU=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "a0b3b06b7a82c965ae0bb1d59f6e386fe755001d",
"rev": "b69de56fac8c2b6f8fd27f2eca01dcda8e0a4221",
"type": "github"
},
"original": {
@ -76,11 +76,11 @@
"systems": "systems"
},
"locked": {
"lastModified": 1694529238,
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
"lastModified": 1726560853,
"narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
"rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a",
"type": "github"
},
"original": {

View File

@ -7,7 +7,7 @@ use teloxide::{
},
RequestError,
};
use wd_log::{log_error_ln, log_debug_ln};
use wd_log::{log_debug_ln, log_error_ln};
use crate::{
db_controller::Controller,
@ -23,7 +23,7 @@ pub async fn inline_menu(db: &Controller, bot: &Bot, q: InlineQuery) -> Result<(
.iter()
.map(|n| {
InlineQueryResult::Article(InlineQueryResultArticle::new(
n.name.clone(),
format!("{},{}", n.id, n.name),
format!("{} {}", BOT_TEXT_INLINE_HANG, n.name),
InputMessageContent::Text(InputMessageContentText::new(hangit_text(
n.name.clone(),
@ -37,15 +37,19 @@ pub async fn inline_menu(db: &Controller, bot: &Bot, q: InlineQuery) -> Result<(
None => vec![],
};
results.push(InlineQueryResult::Article(InlineQueryResultArticle::new(
name.clone(),
format!("{} {}", BOT_TEXT_INLINE_HANG, name.clone()),
InputMessageContent::Text(InputMessageContentText::new(hangit_text(
name.clone(),
!IS_SELF,
!NEED_ESCAPE,
))),
)));
log_debug_ln!("{:?}", results);
if results.is_empty() {
results.push(InlineQueryResult::Article(InlineQueryResultArticle::new(
format!("{},{}", 0, name),
format!("{} {}", BOT_TEXT_INLINE_HANG, name.clone()),
InputMessageContent::Text(InputMessageContentText::new(hangit_text(
name.clone(),
!IS_SELF,
!NEED_ESCAPE,
))),
)));
}
if name.starts_with("@") {
results = vec![]
@ -58,11 +62,15 @@ pub async fn inline_menu(db: &Controller, bot: &Bot, q: InlineQuery) -> Result<(
pub async fn inline_anwser(db: &Controller, a: ChosenInlineResult) -> Result<(), RequestError> {
log_debug_ln!("{:#?}", a);
if a.result_id == "@" {
let mut c: Vec<&str> = a.result_id.split(",").collect();
c.remove(0);
let result_id = c.concat();
if result_id == "@" {
return Ok(());
}
if let Err(err) = db.hangit(&a.result_id, ChatId(0)).await {
if let Err(err) = db.hangit(&result_id, ChatId(0)).await {
log_error_ln!("{:?}", err);
}