Skip to content

Commit 82d5e37

Browse files
Merge pull request #57 from charslab/development
Update master to PTB 21.10
2 parents 0b515fe + a674c47 commit 82d5e37

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1504
-1560
lines changed

.coverage

Lines changed: 0 additions & 1 deletion
This file was deleted.

.github/workflows/build_image.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: DockerBuildAndPush
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- developement
8+
- ptb-async
9+
10+
env:
11+
IMAGE_NAME: transcriberbot
12+
13+
jobs:
14+
push:
15+
runs-on: ubuntu-latest
16+
if: github.event_name == 'push'
17+
18+
steps:
19+
- uses: actions/checkout@v2
20+
21+
- name: Login to ghcr registry
22+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin
23+
24+
- name: Build image
25+
run: docker build . --file Dockerfile --tag $IMAGE_NAME
26+
27+
- name: Push image
28+
run: |
29+
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
30+
# Change all uppercase to lowercase
31+
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
32+
# Strip git ref prefix from version
33+
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
34+
# Strip "v" prefix from tag name
35+
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
36+
# Use Docker `latest` tag convention
37+
[ "$VERSION" == "master" ] && VERSION=latest
38+
echo IMAGE_ID=$IMAGE_ID
39+
echo VERSION=$VERSION
40+
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
41+
docker push $IMAGE_ID:$VERSION

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# TranscriberBot-specific ignores
2-
config/
32
media/
43

54
# Generic data-related ignores

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
transcriber-bot-wonda

.travis.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.9-slim
1+
FROM python:3.12.0-slim
22

33
# Set global configs
44
WORKDIR /

README.md

Lines changed: 37 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -9,88 +9,73 @@
99

1010
2. Edit the file **config/telegram.json**
1111

12-
`{
12+
```json
13+
{
1314
"username": "BOT USERNAME",
1415
"token": "BOT TOKEN",
1516
"admins": [ "YOUR TELEGRAM ID" ]
16-
}`
17+
}
18+
```
1719

1820
3. Create your own Wit token on [Wit website](https://wit.ai/docs/quickstart)
1921

2022
4. Edit the file **config/wit.json** (for example with italian token)
2123

22-
`{
24+
```json
25+
{
2326
"it-IT": "WIT TOKEN FOR Italian"
24-
}`
27+
}
28+
```
2529

2630
You can repeat the points 3 and 4 for support multiple languages.
2731

28-
You can test if your token is working by running:
29-
30-
`
31-
$ python src/audiotools/speech.py wit_api_key some_file.mp3 transcription.txt
32-
`
32+
You can test if your token is working by running: `python src/audiotools/speech.py wit_api_key some_file.mp3 transcription.txt`
3333

3434
5. Create your own Yandex translate token on [Yandex website](https://tech.yandex.com/translate/)
3535

3636
6. Edit the file **config/yandex.json**
3737

38-
`{
38+
```json
39+
{
3940
"translate_key": "YOUR YANDEX TOKEN"
40-
}`
41-
42-
43-
44-
## Installation with virtualenv
45-
46-
1. Install virtualenv and setuptools package
47-
48-
`$ python3 -m pip install --upgrade pip`
49-
`$ pip3 install virtualenv setuptools`
50-
51-
2. Make a note of the full file path to the custom version of Python you just installed
52-
53-
`$ which python3 `
41+
}
42+
```
5443

55-
3. Create the virtual environment while you specify the version of Python you wish to use
44+
## Running with Docker
5645

57-
`$ virtualenv -p /usr/bin/python3 venv`
46+
We provide prebuilt images on [ghcr.io](https://github.com/charslab/TranscriberBot/pkgs/container/transcriberbot).
47+
See **[run.sh](https://github.com/charslab/TranscriberBot/blob/developement/run.sh)** to start a docker container with the latest release.
5848

59-
4. Activate the new virtual environment
49+
Altenratevely, you can build the image from the Dockerfile with **[build.sh](https://github.com/charslab/TranscriberBot/blob/developement/build.sh)**
6050

61-
`$ source venv/bin/activate`
51+
In **[run.sh](https://github.com/charslab/TranscriberBot/blob/developement/run.sh)**, the docker directories **config**, **data** and **values** are binding with the repository directory.
52+
If you want to edit the files in the configuration directories you can do this simply by stopping the container.
53+
As soon as you finish editing the files, just restart the container to make them active.
6254

63-
5. Install the requirement packages
6455

65-
`(venv) $ pip3 install -r requirements.txt`
56+
## Running with virtualenv
6657

67-
6. Run the bot
58+
Tested with: `python 3.12.0`
6859

69-
`(venv) $ python3 src/main.py`
60+
First, install the required dependencies (Ubuntu):
7061

71-
## Installation with Docker
62+
```bash
63+
sudo apt install tesseract-ocr libtesseract-dev libleptonica-dev libpython3-dev libzbar-dev
64+
```
65+
Create a virtual environment and install the required packages:
7266

73-
You can install easily with Docker.
67+
```bash
68+
python3 -m venv transcriber-bot
69+
source transcriber-bot/bin/activate
70+
pip install -r requirements.txt
71+
```
72+
Run the bot:
7473

75-
1. Run the script **dockerBuild.sh** to generate the docker image from the Dockerfile.
74+
```
75+
cd src
76+
python3 main.py
77+
```
7678

77-
2. Run the script **dockerRun.sh** to create and start the docker container.
7879

79-
In the run script, the docker directories **config**, **data** and **values** are binding with the repository directory.
80-
If you want to edit the files in the configuration directories you can do this simply by stopping the container.
81-
As soon as you finish editing the files, just restart the container to make them active.
8280

83-
## TODO
8481

85-
- [x] Voice Messages
86-
- [x] Audio Files
87-
- [x] Video notes
88-
- [x] Pictures
89-
- [x] Multithreading
90-
- [x] Stop callback
91-
- [ ] Stats
92-
- [x] Admin commands only in groups
93-
- [x] Antiflood
94-
- [x] Translations
95-
- [ ] Voice ask
96-
- [x] Channels support
File renamed without changes.

config/app.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,24 @@
4949
"webm"
5050
],
5151

52+
"ocr": {
53+
"tesseract_path": "/usr/share/tesseract-ocr/5/tessdata/"
54+
},
55+
5256
"antiflood": {
5357
"age_threshold": 10,
5458
"flood_ratio": 2,
5559
"max_flood_ratio": 6,
5660
"time_threshold_warning": 4,
5761
"time_threshold_flood": 5,
5862
"timeout": 10
63+
},
64+
65+
"whisper": {
66+
"api_endpoint": "http://127.0.0.1:8000"
67+
},
68+
69+
"logging": {
70+
"level": "APP"
5971
}
6072
}

config/sentry.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"dsn": "xxx"
3+
}

0 commit comments

Comments
 (0)