mirror of
https://github.com/house-of-vanity/desubot.git
synced 2025-07-08 04:54:08 +00:00
Compare commits
19 Commits
Author | SHA1 | Date | |
---|---|---|---|
5a6cb37ebb | |||
6c2837a76f | |||
d97eaf4284 | |||
e7e0c6923e | |||
382cc56492 | |||
6f48f116c9 | |||
282efe5be4 | |||
4175fe9029 | |||
f1dc1d0897 | |||
d5879a82b6 | |||
456c887a53 | |||
d8b37b32df | |||
47c68ee432 | |||
da53927288 | |||
ac2be9929a | |||
7432ce6398 | |||
049a3c4987 | |||
0831e3f503 | |||
a0f4c40be0 |
35
.github/workflows/build-push.yml
vendored
35
.github/workflows/build-push.yml
vendored
@ -31,6 +31,41 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
name: desubot.exe
|
name: desubot.exe
|
||||||
path: ./target/release/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:
|
publish:
|
||||||
name: Publish release
|
name: Publish release
|
||||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -6,4 +6,5 @@ memory.sqlite3
|
|||||||
/video
|
/video
|
||||||
/voice
|
/voice
|
||||||
/.idea
|
/.idea
|
||||||
Cargo.lock
|
Cargo.lock
|
||||||
|
k8s/k8s-deploy.yaml
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "desubot"
|
name = "desubot"
|
||||||
version = "0.5.5"
|
version = "0.5.7"
|
||||||
authors = ["AB <ab@hexor.ru>"]
|
authors = ["AB <ab@hexor.ru>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
@ -12,7 +12,8 @@ tokio = { version = "0.2", features = ["full"]}
|
|||||||
tracing = "0.1.9"
|
tracing = "0.1.9"
|
||||||
tracing-futures = "0.2"
|
tracing-futures = "0.2"
|
||||||
multipart = { version = "0.16", default-features = false, features = ["client"] }
|
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"
|
silicon = "0.4.0"
|
||||||
hyper = "0.13"
|
hyper = "0.13"
|
||||||
hyper-tls = { version = "0.4", optional = true }
|
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
|
||||||
|
|
6
README
6
README
@ -1,3 +1,5 @@
|
|||||||
|
[](https://app.fossa.com/projects/git%2Bgithub.com%2Fhouse-of-vanity%2Fdesubot?ref=badge_shield)
|
||||||
|
|
||||||
Desubot
|
Desubot
|
||||||
Telegram bot with light group statistic and heavy spy features.
|
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 ==
|
== Important ==
|
||||||
* Desubot uses MyStem by Yandex for word stemming and assume that mystem binary is available in PATH.
|
* 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.
|
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 if s.contains("/here")
|
||||||
|
|| s.contains("@here")
|
||||||
|
|| s.contains("/хере")
|
||||||
|
|| s.contains("@хере")
|
||||||
|
|| s.contains("\"хере") =>
|
||||||
|
{
|
||||||
db::add_sentence(&message, mystem).await?;
|
db::add_sentence(&message, mystem).await?;
|
||||||
Here {
|
Here {
|
||||||
data: "".to_string(),
|
data: "".to_string(),
|
||||||
|
41
src/main.rs
41
src/main.rs
@ -1,4 +1,6 @@
|
|||||||
|
#![allow(unreachable_code)]
|
||||||
use std::{env, process};
|
use std::{env, process};
|
||||||
|
use tokio::time::{delay_for, Duration};
|
||||||
|
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use telegram_bot::*;
|
use telegram_bot::*;
|
||||||
@ -16,7 +18,7 @@ use mystem::MyStem;
|
|||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), errors::Error> {
|
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() {
|
let mut mystem = match MyStem::new() {
|
||||||
Ok(mystem) => mystem,
|
Ok(mystem) => mystem,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
@ -44,18 +46,33 @@ async fn main() -> Result<(), errors::Error> {
|
|||||||
me.first_name,
|
me.first_name,
|
||||||
me.id
|
me.id
|
||||||
);
|
);
|
||||||
while let Some(update) = stream.next().await {
|
loop {
|
||||||
let update = update?;
|
while let Some(update) = stream.next().await {
|
||||||
if let UpdateKind::Message(message) = update.kind {
|
match update {
|
||||||
db::add_conf(message.clone()).await?;
|
Ok(u) => {
|
||||||
db::add_user(message.clone()).await?;
|
if let UpdateKind::Message(message) = u.kind {
|
||||||
match handlers::handler(api.clone(), message, token.clone(), &mut mystem, me.clone())
|
db::add_conf(message.clone()).await?;
|
||||||
.await
|
db::add_user(message.clone()).await?;
|
||||||
{
|
match handlers::handler(
|
||||||
Ok(_) => {}
|
api.clone(),
|
||||||
Err(e) => warn!("An error occurred handling command. {:?}", e),
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user