16 Commits

Author SHA1 Message Date
5a6cb37ebb Fix CI 2021-08-24 12:59:51 +03:00
6c2837a76f Fix CI 2021-08-24 00:30:27 +03:00
d97eaf4284 Fix CI 2021-08-24 00:06:55 +03:00
AB
e7e0c6923e Fix WF 2021-08-23 01:25:01 +03:00
AB
382cc56492 docker build 2021-08-23 01:16:27 +03:00
6f48f116c9 Merge pull request #15 from house-of-vanity/add-docker-k8s
Add k8s deploy example
2021-08-22 15:07:06 -07:00
AB
282efe5be4 Add k8s deploy example 2021-08-23 01:06:11 +03:00
4175fe9029 Merge pull request #14 from house-of-vanity/add-docker-k8s
Add Dockerfile.
2021-08-22 14:59:22 -07:00
AB
f1dc1d0897 Add Dockerfile. 2021-08-23 00:58:25 +03:00
d5879a82b6 Merge pull request #13 from house-of-vanity/libs-bump
Update telegram-bot for a new UpdateKind
2021-08-20 12:24:53 -07:00
456c887a53 Merge pull request #11 from fossabot/add-license-scan-badge
Add license scan report and status
2021-08-20 11:25:12 -07:00
AB
d8b37b32df Bump version 2021-08-20 21:22:43 +03:00
AB
47c68ee432 Update telegram-bot for a new UPDATEKU 2021-08-20 20:38:13 +03:00
da53927288 Merge pull request #12 from house-of-vanity/libs-bump
Libs bump
2021-08-19 08:42:00 -07:00
AB
ac2be9929a Rollback tokio 2021-08-19 18:40:12 +03:00
049a3c4987 Add license scan report and status
Signed off by: fossabot <badges@fossa.com>
2021-06-15 15:54:38 -07:00
8 changed files with 138 additions and 19 deletions

View File

@ -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

1
.gitignore vendored
View File

@ -7,3 +7,4 @@ memory.sqlite3
/voice /voice
/.idea /.idea
Cargo.lock Cargo.lock
k8s/k8s-deploy.yaml

View File

@ -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"
@ -8,23 +8,24 @@ edition = "2018"
[dependencies] [dependencies]
bytes = "0.5" bytes = "0.5"
tokio = { version = "1.10.0", features = ["full"]} 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.14" hyper = "0.13"
hyper-tls = { version = "0.4", optional = true } hyper-tls = { version = "0.4", optional = true }
futures = "0.3" futures = "0.3"
hyper-rustls = { version = "0.19", optional = true } hyper-rustls = { version = "0.19", optional = true }
rusqlite = { version = "0.24.2", features = ["bundled"]} rusqlite = { version = "0.24.2", features = ["bundled"]}
html-escape = "0.2" html-escape = "0.2"
regex = "1" regex = "1"
reqwest = "0.11.4" reqwest = "0.10.9"
uuid = { version = "0.8", features = ["v4"] } uuid = { version = "0.8", features = ["v4"] }
sha1 = "0.6.0" sha1 = "0.6.0"
env_logger = "0.9.0" env_logger = "0.7"
log = { version = "^0.4.5", features = ["std"] } log = { version = "^0.4.5", features = ["std"] }
subprocess = "0.2.6" subprocess = "0.2.6"
serde_json = "1.0" serde_json = "1.0"
@ -33,7 +34,7 @@ rand = "0.7.3"
mystem = "^0.2" mystem = "^0.2"
#mystem = { path = "../mystem-rs" } #mystem = { path = "../mystem-rs" }
async-trait = "0.1.42" async-trait = "0.1.42"
sqlparser = "0.9.0" sqlparser = "0.7.0"
[dependencies.syntect] [dependencies.syntect]
version = "4.4" version = "4.4"

14
Dockerfile Normal file
View 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
View File

@ -1,3 +1,5 @@
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fhouse-of-vanity%2Fdesubot.svg?type=shield)](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
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fhouse-of-vanity%2Fdesubot.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fhouse-of-vanity%2Fdesubot?ref=badge_large)

View 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

View File

@ -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?; db::add_sentence(&message, mystem).await?;
Here { Here {
data: "".to_string(), data: "".to_string(),

View File

@ -1,5 +1,6 @@
#![allow(unreachable_code)] #![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::*;
@ -47,18 +48,31 @@ async fn main() -> Result<(), errors::Error> {
); );
loop { loop {
while let Some(update) = stream.next().await { while let Some(update) = stream.next().await {
let update = update?; match update {
if let UpdateKind::Message(message) = update.kind { Ok(u) => {
db::add_conf(message.clone()).await?; if let UpdateKind::Message(message) = u.kind {
db::add_user(message.clone()).await?; db::add_conf(message.clone()).await?;
match handlers::handler(api.clone(), message, token.clone(), &mut mystem, me.clone()) db::add_user(message.clone()).await?;
.await match handlers::handler(
{ api.clone(),
Ok(_) => {} message,
Err(e) => warn!("An error occurred handling command. {:?}", e), 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(())
} }