Improvements and fixes
This commit is contained in:
parent
c812c992d5
commit
6a58e7514b
|
@ -1,5 +1,5 @@
|
|||
FROM python:3.6.1-slim
|
||||
ENV CONFIG_PATH "./main.cfg"
|
||||
ENV CONFIG_PATH "cfg/main.docker.cfg"
|
||||
RUN mkdir /code
|
||||
WORKDIR /code
|
||||
ADD requirements.txt /code/
|
||||
|
|
16
README.md
16
README.md
|
@ -1,6 +1,6 @@
|
|||
My great plan is to create a Telegram chat bot that would be like [shizoid](https://github.com/top4ek/shizoid), but in Python and maybe with some extra features.
|
||||
|
||||
A-a-a-a-and... it works! Thanks to [@REDNBLACK](https://github.com/REDNBLACK).
|
||||
A-a-a-a-and... it works ([@ImaginaryFriendBot](https://t.me/ImaginaryFriendBot))! Thanks to [@REDNBLACK](https://github.com/REDNBLACK).
|
||||
|
||||
## Features
|
||||
|
||||
|
@ -56,17 +56,17 @@ ImaginaryFriend can:
|
|||
|
||||
### 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
|
||||
2. Open `cfg` dir and rename `main.docker.cfg.example` to `main.docker.cfg`.
|
||||
3. Talk to [@botfather](https://t.me/botfather) and create your own bot.
|
||||
4. Open `main.docker.cfg` file in text editor and paste your newly created bot token into `bot`.`token` property.
|
||||
5. Execute `docker-compose up`. Congrats! You now have ImaginaryFriend of your own!
|
||||
|
||||
### 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. Rename `main.cfg.example` to `main.cfg`
|
||||
5. Talk to [@botfather](https://telegram.me/botfather) and create your own bot.
|
||||
6. Open `main.cfg` file in text editor and paste your newly created bot token into `bot`.`token` property
|
||||
7. (Optionally) Configure `updates` property for websocket support
|
||||
4. Open `cfg` dir and rename `main.plain.cfg.example` to `main.plain.cfg`
|
||||
5. Talk to [@botfather](https://t.me/botfather) and create your own bot.
|
||||
6. Open `main.plain.cfg` file in text editor and paste your newly created bot token into `bot`.`token` property.
|
||||
7. (Optionally) Configure `updates` property for websocket support and `redis` property to point to your Redis instance.
|
||||
8. Execute the `python run.py`
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
[bot]
|
||||
token=
|
||||
name=ImaginaryFriend
|
||||
anchors=bot
|
||||
purge_interval=43200.0
|
||||
default_chance=5
|
||||
spam_stickers=BQADAgADSAIAAkcGQwU-G-9SZUDTWAI
|
||||
|
||||
[logging]
|
||||
level=INFO
|
||||
|
||||
[grammar]
|
||||
chain_length=2
|
||||
separator=\x02
|
||||
stop_word='\x00'
|
||||
max_words=30
|
||||
max_messages=5
|
||||
end_sentence=.....!!?
|
||||
all=.!?;()\-—"[]{}«»/*&^#$
|
||||
|
||||
[media_checker]
|
||||
lifetime=28800.0
|
||||
messages=[:||||||||||||:]
|
||||
|
||||
[updates]
|
||||
mode=polling
|
||||
|
||||
[redis]
|
||||
host=redis
|
||||
port=6379
|
||||
db=0
|
|
@ -31,6 +31,6 @@ key=
|
|||
cert=
|
||||
|
||||
[redis]
|
||||
host=redis
|
||||
host=localhost
|
||||
port=6379
|
||||
db=0
|
|
@ -19,7 +19,7 @@ def getlist(self, section, option, type=str):
|
|||
|
||||
configparser.ConfigParser.getlist = getlist
|
||||
|
||||
config_path = os.environ['CONFIG_PATH']
|
||||
config_path = os.getenv('CONFIG_PATH', 'cfg/main.plain.cfg')
|
||||
config = configparser.ConfigParser()
|
||||
config.read(config_path, encoding=encoding)
|
||||
|
||||
|
|
|
@ -1,31 +1,11 @@
|
|||
from .base import Base
|
||||
from src.utils import read_to_string
|
||||
|
||||
|
||||
class Help(Base):
|
||||
name = 'help'
|
||||
text = read_to_string('info/help.txt')
|
||||
|
||||
@staticmethod
|
||||
def execute(bot, command):
|
||||
Help.reply(
|
||||
bot,
|
||||
command,
|
||||
"""Add me to your group and let me listen to your chat for a while.
|
||||
When I learn enough word pairs, I'll start bringing fun and absurdity to your conversations.
|
||||
|
||||
Available commands:
|
||||
• /ping: u know the drill,
|
||||
• /get_stats: get the number of word pairs I've learned in this chat,
|
||||
• /chance <n>: set the chance that I'll reply to a random message (must be in range 1-50, default: 5),
|
||||
• /chance: get the current chance of my random reply,
|
||||
• /meow: show random cat pic,
|
||||
• /borscht: show random borscht pic,
|
||||
• /vzhuh и текст: create вжух meme with «вжух и текст» caption,
|
||||
• /woof: show random dog pic,
|
||||
• /boobs: show random boobs pic,
|
||||
• /butts: show random butt pic,
|
||||
• /xkcd: show random xkcd comic.
|
||||
|
||||
If you get tired of me, you can kick me from the group.
|
||||
In 12 hours, I'll forget everything that have been learned in your chat, so you can add me again and teach me new things!
|
||||
"""
|
||||
)
|
||||
Help.reply(bot, command, Help.text)
|
||||
|
|
|
@ -34,3 +34,9 @@ def safe_cast(val, to_type, default=None):
|
|||
return to_type(val)
|
||||
except (ValueError, TypeError):
|
||||
return default
|
||||
|
||||
|
||||
def read_to_string(file_path):
|
||||
with open(file_path, 'r') as file:
|
||||
data = file.read()
|
||||
return data
|
||||
|
|
Loading…
Reference in New Issue