Compare commits

..

No commits in common. "master" and "v0.1.2" have entirely different histories.

4 changed files with 28 additions and 36 deletions

View File

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

View File

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

24
flake.lock generated
View File

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

View File

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