mirror of
https://github.com/house-of-vanity/desubot.git
synced 2025-07-06 20:24:08 +00:00
Merge branch 'main' of github.com:house-of-vanity/desubot
This commit is contained in:
35
.github/workflows/build-push.yml
vendored
35
.github/workflows/build-push.yml
vendored
@ -31,6 +31,41 @@ jobs:
|
||||
with:
|
||||
name: desubot.exe
|
||||
path: ./target/release/desubot.exe
|
||||
build-push-docker:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Branch name
|
||||
id: branch_name
|
||||
run: |
|
||||
echo ::set-output name=SOURCE_NAME::${GITHUB_REF#refs/*/}
|
||||
echo ::set-output name=SOURCE_BRANCH::${GITHUB_REF#refs/heads/}
|
||||
echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/}
|
||||
-
|
||||
name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
-
|
||||
name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
-
|
||||
name: Build and push
|
||||
id: docker_build_latest
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
push: true
|
||||
tags: ultradesu/desubot:latest
|
||||
-
|
||||
name: Build and push
|
||||
id: docker_build_tag
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
push: true
|
||||
tags: ultradesu/desubot:${{ steps.branch_name.outputs.SOURCE_TAG }}
|
||||
|
||||
publish:
|
||||
name: Publish release
|
||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -6,4 +6,5 @@ memory.sqlite3
|
||||
/video
|
||||
/voice
|
||||
/.idea
|
||||
Cargo.lock
|
||||
Cargo.lock
|
||||
k8s/k8s-deploy.yaml
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "desubot"
|
||||
version = "0.5.5"
|
||||
version = "0.5.7"
|
||||
authors = ["AB <ab@hexor.ru>"]
|
||||
edition = "2018"
|
||||
|
||||
@ -12,7 +12,8 @@ tokio = { version = "0.2", features = ["full"]}
|
||||
tracing = "0.1.9"
|
||||
tracing-futures = "0.2"
|
||||
multipart = { version = "0.16", default-features = false, features = ["client"] }
|
||||
telegram-bot = "0.8.0"
|
||||
#telegram-bot = "0.8.0"
|
||||
telegram-bot = { git = "https://github.com/ayrat555/telegram-bot", branch = "ayrat555/api-fixes-10" }
|
||||
silicon = "0.4.0"
|
||||
hyper = "0.13"
|
||||
hyper-tls = { version = "0.4", optional = true }
|
||||
|
14
Dockerfile
Normal file
14
Dockerfile
Normal file
@ -0,0 +1,14 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
FROM rust:latest AS builder
|
||||
WORKDIR /desubot
|
||||
ADD ./ /desubot/
|
||||
RUN cargo build --release
|
||||
|
||||
FROM ubuntu:latest
|
||||
WORKDIR /storage
|
||||
COPY --from=builder /desubot/target/release/desubot /usr/bin/
|
||||
COPY mystem /usr/bin/
|
||||
RUN apt update && apt install -y fontconfig openssl ca-certificates && rm -rf /var/lib/apt/lists/*
|
||||
ENTRYPOINT desubot
|
||||
|
@ -1,3 +1,5 @@
|
||||
[](https://app.fossa.com/projects/git%2Bgithub.com%2Fhouse-of-vanity%2Fdesubot?ref=badge_shield)
|
||||
|
||||
Desubot
|
||||
Telegram bot with light group statistic and heavy spy features.
|
||||
|
||||
@ -12,3 +14,7 @@ Telegram bot with light group statistic and heavy spy features.
|
||||
== Important ==
|
||||
* Desubot uses MyStem by Yandex for word stemming and assume that mystem binary is available in PATH.
|
||||
On Windows it may be placed on working directory. Both Linux and Windows mystem binary is in repo.
|
||||
|
||||
|
||||
## License
|
||||
[](https://app.fossa.com/projects/git%2Bgithub.com%2Fhouse-of-vanity%2Fdesubot?ref=badge_large)
|
43
k8s/k8s-deploy-example.yaml
Normal file
43
k8s/k8s-deploy-example.yaml
Normal file
@ -0,0 +1,43 @@
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: desubot-api-token
|
||||
data:
|
||||
token: 123.... # Base64 encoded token.
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: desubot
|
||||
spec:
|
||||
serviceName: "desubot"
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: desubot
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: desubot
|
||||
spec:
|
||||
containers:
|
||||
- name: desubot
|
||||
image: ultradesu/desubot:latest
|
||||
volumeMounts:
|
||||
- name: storage
|
||||
mountPath: /storage
|
||||
env:
|
||||
- name: TELEGRAM_BOT_TOKEN
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: desubot-api-token
|
||||
key: token
|
||||
volumeClaimTemplates:
|
||||
- metadata:
|
||||
name: storage
|
||||
spec:
|
||||
accessModes: [ "ReadWriteOnce" ]
|
||||
resources:
|
||||
requests:
|
||||
storage: 50Gi
|
@ -53,7 +53,12 @@ pub async fn handler(
|
||||
}
|
||||
}
|
||||
}
|
||||
s if s.contains("/here") || s.contains("@here") || s.contains("/хере") || s.contains("@хере") || s.contains("\"хере") => {
|
||||
s if s.contains("/here")
|
||||
|| s.contains("@here")
|
||||
|| s.contains("/хере")
|
||||
|| s.contains("@хере")
|
||||
|| s.contains("\"хере") =>
|
||||
{
|
||||
db::add_sentence(&message, mystem).await?;
|
||||
Here {
|
||||
data: "".to_string(),
|
||||
|
41
src/main.rs
41
src/main.rs
@ -1,4 +1,6 @@
|
||||
#![allow(unreachable_code)]
|
||||
use std::{env, process};
|
||||
use tokio::time::{delay_for, Duration};
|
||||
|
||||
use futures::StreamExt;
|
||||
use telegram_bot::*;
|
||||
@ -16,7 +18,7 @@ use mystem::MyStem;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), errors::Error> {
|
||||
env_logger::from_env(Env::default().default_filter_or("info")).init();
|
||||
env_logger::Builder::from_env(Env::default().default_filter_or("info")).init();
|
||||
let mut mystem = match MyStem::new() {
|
||||
Ok(mystem) => mystem,
|
||||
Err(e) => {
|
||||
@ -48,18 +50,33 @@ async fn main() -> Result<(), errors::Error> {
|
||||
me.first_name,
|
||||
me.id
|
||||
);
|
||||
while let Some(update) = stream.next().await {
|
||||
let update = update?;
|
||||
if let UpdateKind::Message(message) = update.kind {
|
||||
db::add_conf(message.clone()).await?;
|
||||
db::add_user(message.clone()).await?;
|
||||
match handlers::handler(api.clone(), message, token.clone(), &mut mystem, me.clone())
|
||||
.await
|
||||
{
|
||||
Ok(_) => {}
|
||||
Err(e) => warn!("An error occurred handling command. {:?}", e),
|
||||
}
|
||||
loop {
|
||||
while let Some(update) = stream.next().await {
|
||||
match update {
|
||||
Ok(u) => {
|
||||
if let UpdateKind::Message(message) = u.kind {
|
||||
db::add_conf(message.clone()).await?;
|
||||
db::add_user(message.clone()).await?;
|
||||
match handlers::handler(
|
||||
api.clone(),
|
||||
message,
|
||||
token.clone(),
|
||||
&mut mystem,
|
||||
me.clone(),
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(_) => {}
|
||||
Err(e) => warn!("An error occurred handling command. {:?}", e),
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
warn!("Telegram API Error: {:?}", e);
|
||||
}
|
||||
};
|
||||
}
|
||||
delay_for(Duration::from_secs(2)).await;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
Reference in New Issue
Block a user