fix: eh regexp

This commit is contained in:
ihciah 2023-04-20 15:05:23 +00:00
parent bf5acd966d
commit b7e1b4e989
No known key found for this signature in database
GPG Key ID: A72018B6522333D3
8 changed files with 486 additions and 348 deletions

View File

@ -5,6 +5,9 @@ on:
tags: tags:
- 'v*' - 'v*'
env:
CARGO_NET_GIT_FETCH_WITH_CLI: true
jobs: jobs:
build: build:
name: 'Build' name: 'Build'
@ -30,14 +33,13 @@ jobs:
registry: ghcr.io registry: ghcr.io
username: qini7-sese username: qini7-sese
password: ${{ secrets.GITHUB_TOKEN }} password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate App Version
run: echo VERSIONED_TAG=`git describe --tags --always` >> $GITHUB_ENV
- name: Build docker image - name: Build docker image
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:
push: true push: true
platforms: linux/amd64,linux/arm64
tags: | tags: |
ghcr.io/qini7-sese/ehbot:amd64 ghcr.io/qini7-sese/ehbot:latest
${{ steps.prep.outputs.tags }} ghcr.io/qini7-sese/ehbot:${{ env.VERSIONED_TAG }}
- name: Docker manifest push
run: |
docker manifest create ghcr.io/qini7-sese/ehbot:latest ghcr.io/qini7-sese/ehbot:amd64
docker manifest push ghcr.io/qini7-sese/ehbot:latest

785
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
[package] [package]
edition = "2021" edition = "2021"
name = "bot" name = "bot"
version = "0.1.10" version = "0.1.11"
[dependencies] [dependencies]
eh2telegraph = {path = "../eh2telegraph"} eh2telegraph = {path = "../eh2telegraph"}
@ -16,7 +16,7 @@ reqwest = {version = "0.11", default-features = false, features = ["json", "mult
serde = {version = "1", features = ["derive"]} serde = {version = "1", features = ["derive"]}
singleflight-async = {version = "0.1", features = ["hardware-lock-elision"]} singleflight-async = {version = "0.1", features = ["hardware-lock-elision"]}
teloxide = {version = "0.11", features = ["macros", "ctrlc_handler", "auto-send"]} teloxide = {version = "0.11", features = ["macros", "ctrlc_handler", "auto-send"]}
time = {version = "0.3", features = ["local-offset", "std", "macros"]} time = {version = "=0.3.17", features = ["local-offset", "std", "macros"]}
tokio = {version = "1", default-features = false, features = ["rt-multi-thread", "macros", "net", "sync", "time", "parking_lot"]} tokio = {version = "1", default-features = false, features = ["rt-multi-thread", "macros", "net", "sync", "time", "parking_lot"]}
tracing = "0.1" tracing = "0.1"
tracing-subscriber = {version = "0.3", features = ["local-time", "parking_lot", "time"]} tracing-subscriber = {version = "0.3", features = ["local-time", "parking_lot", "time"]}

View File

@ -124,7 +124,7 @@ where
.send_message(msg.chat.id, escape("Usage: /sync url")) .send_message(msg.chat.id, escape("Usage: /sync url"))
.reply_to_message_id(msg.id) .reply_to_message_id(msg.id)
.await; .await;
return ControlFlow::BREAK; return ControlFlow::Break(());
} }
info!( info!(
@ -144,7 +144,7 @@ where
} }
}; };
ControlFlow::BREAK ControlFlow::Break(())
} }
pub async fn respond_admin_cmd( pub async fn respond_admin_cmd(
@ -162,7 +162,7 @@ where
.reply_to_message_id(msg.id) .reply_to_message_id(msg.id)
.await; .await;
}); });
ControlFlow::BREAK ControlFlow::Break(())
} }
} }
} }
@ -210,11 +210,11 @@ where
.edit_message_text(msg.chat.id, msg.id, self.sync_response(&url).await) .edit_message_text(msg.chat.id, msg.id, self.sync_response(&url).await)
.await; .await;
}); });
return ControlFlow::BREAK; return ControlFlow::Break(());
} }
// fallback to the next branch // fallback to the next branch
ControlFlow::CONTINUE ControlFlow::Continue(())
} }
pub async fn respond_caption( pub async fn respond_caption(
@ -232,7 +232,6 @@ where
.expect("Url MessageEntry found but caption is None"); .expect("Url MessageEntry found but caption is None");
let encoded: Vec<_> = raw let encoded: Vec<_> = raw
.encode_utf16() .encode_utf16()
.into_iter()
.skip(entry.offset) .skip(entry.offset)
.take(entry.length) .take(entry.length)
.collect(); .collect();
@ -270,9 +269,9 @@ where
.edit_message_text(msg.chat.id, msg.id, self.sync_response(&url).await) .edit_message_text(msg.chat.id, msg.id, self.sync_response(&url).await)
.await; .await;
}); });
ControlFlow::BREAK ControlFlow::Break(())
} }
None => ControlFlow::CONTINUE, None => ControlFlow::Continue(()),
} }
} }
@ -284,7 +283,7 @@ where
let first_photo = match msg.photo().and_then(|x| x.first()) { let first_photo = match msg.photo().and_then(|x| x.first()) {
Some(p) => p, Some(p) => p,
None => { None => {
return ControlFlow::CONTINUE; return ControlFlow::Continue(());
} }
}; };
@ -324,7 +323,7 @@ where
Some(u) => u, Some(u) => u,
None => { None => {
trace!("[photo handler] image not found"); trace!("[photo handler] image not found");
return ControlFlow::CONTINUE; return ControlFlow::Continue(());
} }
}; };
@ -345,7 +344,7 @@ where
}); });
} }
ControlFlow::BREAK ControlFlow::Break(())
} }
pub async fn respond_default( pub async fn respond_default(
@ -362,7 +361,7 @@ where
} }
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
tracing::warn!("{:?}", msg); tracing::warn!("{:?}", msg);
ControlFlow::BREAK ControlFlow::Break(())
} }
async fn sync_response(&self, url: &str) -> String { async fn sync_response(&self, url: &str) -> String {

View File

@ -60,7 +60,7 @@ macro_rules! ok_or_break {
match $e { match $e {
Ok(r) => r, Ok(r) => r,
Err(_) => { Err(_) => {
return ControlFlow::BREAK; return ControlFlow::Break(());
} }
} }
}; };

View File

@ -21,7 +21,7 @@ reqwest = {version = "0.11", default-features = false, features = ["json", "mult
rustls = {version = "0.20", features = ["dangerous_configuration"]} rustls = {version = "0.20", features = ["dangerous_configuration"]}
serde = {version = "1", features = ["derive"]} serde = {version = "1", features = ["derive"]}
serde_with = {version = "1", features = ["macros", "json"]} serde_with = {version = "1", features = ["macros", "json"]}
serde_yaml = "0.8" serde_yaml = "0.9"
thiserror = "1" thiserror = "1"
tokio = {version = "1", default-features = false, features = ["rt-multi-thread", "macros", "net", "sync", "time", "parking_lot"]} tokio = {version = "1", default-features = false, features = ["rt-multi-thread", "macros", "net", "sync", "time", "parking_lot"]}
tracing = "0.1" tracing = "0.1"

View File

@ -21,8 +21,7 @@ use super::{AlbumMeta, Collector, ImageData, ImageMeta};
lazy_static::lazy_static! { lazy_static::lazy_static! {
static ref TITLE_RE: Regex = Regex::new(r#"<span class="pretty">(.*?)</span>"#).unwrap(); static ref TITLE_RE: Regex = Regex::new(r#"<span class="pretty">(.*?)</span>"#).unwrap();
// static ref PAGE_RE: Regex = Regex::new(r#"<noscript><img src="(https://t\d?\.nhentai\.net/galleries/\d+/\d+t\.\w+)"#).unwrap(); static ref PAGE_RE: Regex = Regex::new(r#"<noscript><img src="(https://cdn\.(?:nhentai\.xxx|hentaibomb\.com)/g/\d+/\d+t\.\w+)"#).unwrap();
static ref PAGE_RE: Regex = Regex::new(r#"<noscript><img src="(https://cdn.nhentai.xxx/g/\d+/\d+t\.\w+)"#).unwrap();
static ref RETRY_POLICY: RetryPolicy = RetryPolicy::fixed(Duration::from_millis(200)) static ref RETRY_POLICY: RetryPolicy = RetryPolicy::fixed(Duration::from_millis(200))
.with_max_retries(5) .with_max_retries(5)

View File

@ -1,4 +1,5 @@
#![feature(type_alias_impl_trait)] #![feature(type_alias_impl_trait)]
#![feature(impl_trait_in_assoc_type)]
pub mod buffer; pub mod buffer;
pub mod collector; pub mod collector;