Added untested Docker example
This commit is contained in:
parent
83c9975fbb
commit
ecf86d706a
|
@ -0,0 +1,7 @@
|
|||
FROM python:3.6.1-slim
|
||||
ENV CONFIG_PATH "./main.cfg"
|
||||
RUN mkdir /code
|
||||
WORKDIR /code
|
||||
ADD requirements.txt /code/
|
||||
RUN pip install -r requirements.txt
|
||||
ADD . /code/
|
28
README.md
28
README.md
|
@ -9,6 +9,7 @@ ImaginaryFriend can:
|
|||
* reply to random messages in chat groups,
|
||||
* reply to replies to its messages / messages mentioning it,
|
||||
* send (one!) sticker ("I'm frustrated by all these stickers"),
|
||||
* detect repeating media files and send [:||||||||||||:] to chat,
|
||||
* do some commands.
|
||||
|
||||
### Examples
|
||||
|
@ -42,7 +43,7 @@ ImaginaryFriend can:
|
|||
|
||||
## Commands
|
||||
|
||||
* `/ping`,
|
||||
* `/ping`: you know the drill,
|
||||
* `/get_stats`: get information on how many pairs are known by ImaginaryFriend,
|
||||
* `/chance n`: set the probability that ImaginaryFriend would reply to a random message (must be in range 1-50, default: 5),
|
||||
* `/сhance`: get current probability that ImaginaryFriend would reply to a message,
|
||||
|
@ -53,14 +54,19 @@ ImaginaryFriend can:
|
|||
|
||||
## Installation and Setup
|
||||
|
||||
### Dependencies
|
||||
* `python >= 3.5.2`
|
||||
* `python-telegram-bot==5.2.0`
|
||||
* `redis==2.10.5`
|
||||
### Setup using Docker
|
||||
1. Install [Docker](https://store.docker.com/search?offering=community&type=edition)
|
||||
2. Rename `main.cfg.example` to `main.cfg`
|
||||
3. Talk to [@botfather](https://telegram.me/botfather) and create your own bot.
|
||||
4. Open `main.cfg` file in text editor and paste your newly created bot token into `bot`.`token` property
|
||||
5. Execute `docker-compose up`
|
||||
6. Congrats! You now have ImaginaryFriend of your own!
|
||||
|
||||
### Setup
|
||||
1. Install dependencies with PIP
|
||||
2. Install `Redis`
|
||||
3. Rename `main.cfg.example` to `main.cfg`, set `bot` and `redis` properties
|
||||
4. (Optionally) Configure `updates` property for websocket support
|
||||
5. Run the `run.py` using python
|
||||
## Setup without Docker
|
||||
1. Install [Python >= 3.5.2](https://www.python.org/downloads/)
|
||||
2. Install [Redis >= 3.2](https://redis.io/download)
|
||||
3. Install dependencies with PIP by executing command `pip install -r requirements.txt`
|
||||
4. Talk to [@botfather](https://telegram.me/botfather) and create your own bot.
|
||||
5. Open `main.cfg` file in text editor and paste your newly created bot token into `bot`.`token` property
|
||||
6. (Optionally) Configure `updates` property for websocket support
|
||||
7. Execute the `python run.py`
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
version: '2.1'
|
||||
services:
|
||||
bot:
|
||||
build: .
|
||||
command: python run.py
|
||||
volumes:
|
||||
- .:/code
|
||||
depends_on:
|
||||
- redis
|
||||
redis:
|
||||
image: redis:3.2.8-alpine
|
|
@ -1,8 +1,7 @@
|
|||
[bot]
|
||||
token=
|
||||
name=
|
||||
anchors=
|
||||
messages=
|
||||
name=ImaginaryFriend
|
||||
anchors=bot
|
||||
purge_interval=43200.0
|
||||
default_chance=5
|
||||
spam_stickers=BQADAgADSAIAAkcGQwU-G-9SZUDTWAI
|
||||
|
@ -32,6 +31,6 @@ key=
|
|||
cert=
|
||||
|
||||
[redis]
|
||||
host=
|
||||
port=
|
||||
db=
|
||||
host=redis
|
||||
port=6379
|
||||
db=0
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
python-telegram-bot
|
||||
redis
|
||||
python-telegram-bot==5.3.0
|
||||
redis==2.10.5
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
# Config
|
||||
import configparser
|
||||
import os
|
||||
|
||||
encoding = 'utf-8'
|
||||
|
||||
sections = {
|
||||
'bot': ['token', 'name', 'anchors', 'messages', 'purge_interval', 'default_chance', 'spam_stickers'],
|
||||
'bot': ['token', 'name', 'anchors', 'purge_interval', 'default_chance', 'spam_stickers'],
|
||||
'grammar': ['chain_length', 'separator', 'stop_word', 'end_sentence', 'all'],
|
||||
'logging': ['level'],
|
||||
'updates': ['mode'],
|
||||
|
@ -18,8 +19,9 @@ def getlist(self, section, option, type=str):
|
|||
|
||||
configparser.ConfigParser.getlist = getlist
|
||||
|
||||
config_path = os.environ['CONFIG_PATH']
|
||||
config = configparser.ConfigParser()
|
||||
config.read('./main.cfg', encoding=encoding)
|
||||
config.read(config_path, encoding=encoding)
|
||||
|
||||
for section, options in sections.items():
|
||||
if not config.has_section(section):
|
||||
|
|
Loading…
Reference in New Issue