diff --git a/cfg/main.docker.cfg.example b/cfg/main.docker.cfg.example index 5a1fffe..0fb43fc 100644 --- a/cfg/main.docker.cfg.example +++ b/cfg/main.docker.cfg.example @@ -1,31 +1,2 @@ [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 diff --git a/cfg/main.plain.cfg.example b/cfg/main.plain.cfg.example index 46de57d..1d7e6ac 100644 --- a/cfg/main.plain.cfg.example +++ b/cfg/main.plain.cfg.example @@ -1,26 +1,5 @@ [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 @@ -32,5 +11,3 @@ cert= [redis] host=localhost -port=6379 -db=0 diff --git a/docker-compose.yml b/docker-compose.yml index 237d0e9..79632c3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,5 +11,5 @@ services: redis: image: redis:3.2.8-alpine volumes: - - ./data:/data + - ./storage:/data restart: unless-stopped diff --git a/info/about.txt b/resources/info/about.txt similarity index 100% rename from info/about.txt rename to resources/info/about.txt diff --git a/info/commands.txt b/resources/info/commands.txt similarity index 100% rename from info/commands.txt rename to resources/info/commands.txt diff --git a/info/description.txt b/resources/info/description.txt similarity index 100% rename from info/description.txt rename to resources/info/description.txt diff --git a/info/help.txt b/resources/info/help.txt similarity index 100% rename from info/help.txt rename to resources/info/help.txt diff --git a/resources/main.cfg b/resources/main.cfg new file mode 100644 index 0000000..27db26f --- /dev/null +++ b/resources/main.cfg @@ -0,0 +1,36 @@ +[bot] +token= +name=ImaginaryFriend +anchors=bot,бот,imaginary_friend,ImaginaryFriend,ImaginaryFriendBot,@ImaginaryFriendBot +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=[:||||||||||||:],🐢,:slow: + +[updates] +mode=polling +host= +port= +url= +key= +cert= + +[redis] +host=redis +port=6379 +db=0 diff --git a/data/Impact.ttf b/resources/vzhuh/Impact.ttf similarity index 100% rename from data/Impact.ttf rename to resources/vzhuh/Impact.ttf diff --git a/data/vzhuh_sample.png b/resources/vzhuh/sample.png similarity index 100% rename from data/vzhuh_sample.png rename to resources/vzhuh/sample.png diff --git a/src/config.py b/src/config.py index 50df5d0..0b07b9c 100644 --- a/src/config.py +++ b/src/config.py @@ -19,9 +19,11 @@ def getlist(self, section, option, type=str): configparser.ConfigParser.getlist = getlist -config_path = os.getenv('CONFIG_PATH', 'cfg/main.plain.cfg') +root_config = 'resources/main.cfg' +user_config = os.getenv('CONFIG_PATH', 'cfg/main.plain.cfg') config = configparser.ConfigParser() -config.read(config_path, encoding=encoding) +config.read(root_config, encoding=encoding) +config.read(user_config, encoding=encoding) for section, options in sections.items(): if not config.has_section(section): diff --git a/src/handler/commands/help.py b/src/handler/commands/help.py index 7065b8f..af43c7e 100644 --- a/src/handler/commands/help.py +++ b/src/handler/commands/help.py @@ -4,7 +4,7 @@ from src.utils import read_to_string class Help(Base): name = 'help' - text = read_to_string('info/help.txt') + text = read_to_string('resources/info/help.txt') @staticmethod def execute(bot, command): diff --git a/src/handler/commands/vzhuh.py b/src/handler/commands/vzhuh.py index 12dde37..5128842 100644 --- a/src/handler/commands/vzhuh.py +++ b/src/handler/commands/vzhuh.py @@ -10,7 +10,7 @@ class Vzhuh(Base): text = Vzhuh.format_text('вжух ' + ' '.join(command.args)) Vzhuh.create_image(text) - bot.send_photo(chat_id=command.chat_id, photo=open('data/sample-out.png', 'rb')) + bot.send_photo(chat_id=command.chat_id, photo=open('storage/vzhuh.png', 'rb')) @staticmethod def format_text(text): @@ -33,8 +33,8 @@ class Vzhuh(Base): @staticmethod def create_image(text): - img = Image.open("data/vzhuh_sample.png") + img = Image.open("resources/vzhuh/sample.png") draw = ImageDraw.Draw(img) - font = ImageFont.truetype("data/Impact.ttf", 44, index=0) + font = ImageFont.truetype('resources/vzhuh/Impact.ttf', 44, index=0) draw.text((222, 280), text, (0, 0, 0), font=font) - img.save('data/sample-out.png') + img.save('storage/vzhuh.png') diff --git a/src/handler/commands/woof.py b/src/handler/commands/woof.py index ea073a0..47b0a46 100644 --- a/src/handler/commands/woof.py +++ b/src/handler/commands/woof.py @@ -8,8 +8,8 @@ class Woof(Base): @staticmethod def execute(bot, command): req = Request("http://loremflickr.com/500/410/dog", headers={'User-Agent': "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36"}) - output = open("data/woof-photo.jpg", "wb") + output = open("storage/woof.jpg", "wb") output.write(urlopen(req).read()) output.close() - bot.send_photo(chat_id=command.chat_id, photo=open('data/woof-photo.jpg', 'rb')) + bot.send_photo(chat_id=command.chat_id, photo=open('storage/woof.jpg', 'rb')) diff --git a/storage/.gitkeep b/storage/.gitkeep new file mode 100644 index 0000000..e69de29