Better file structure
This commit is contained in:
parent
6a58e7514b
commit
87714529b0
|
@ -1,31 +1,2 @@
|
||||||
[bot]
|
[bot]
|
||||||
token=
|
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
|
|
||||||
|
|
|
@ -1,26 +1,5 @@
|
||||||
[bot]
|
[bot]
|
||||||
token=
|
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]
|
[updates]
|
||||||
mode=polling
|
mode=polling
|
||||||
|
@ -32,5 +11,3 @@ cert=
|
||||||
|
|
||||||
[redis]
|
[redis]
|
||||||
host=localhost
|
host=localhost
|
||||||
port=6379
|
|
||||||
db=0
|
|
||||||
|
|
|
@ -11,5 +11,5 @@ services:
|
||||||
redis:
|
redis:
|
||||||
image: redis:3.2.8-alpine
|
image: redis:3.2.8-alpine
|
||||||
volumes:
|
volumes:
|
||||||
- ./data:/data
|
- ./storage:/data
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
|
@ -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
|
Before Width: | Height: | Size: 233 KiB After Width: | Height: | Size: 233 KiB |
|
@ -19,9 +19,11 @@ def getlist(self, section, option, type=str):
|
||||||
|
|
||||||
configparser.ConfigParser.getlist = getlist
|
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 = 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():
|
for section, options in sections.items():
|
||||||
if not config.has_section(section):
|
if not config.has_section(section):
|
||||||
|
|
|
@ -4,7 +4,7 @@ from src.utils import read_to_string
|
||||||
|
|
||||||
class Help(Base):
|
class Help(Base):
|
||||||
name = 'help'
|
name = 'help'
|
||||||
text = read_to_string('info/help.txt')
|
text = read_to_string('resources/info/help.txt')
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def execute(bot, command):
|
def execute(bot, command):
|
||||||
|
|
|
@ -10,7 +10,7 @@ class Vzhuh(Base):
|
||||||
text = Vzhuh.format_text('вжух ' + ' '.join(command.args))
|
text = Vzhuh.format_text('вжух ' + ' '.join(command.args))
|
||||||
Vzhuh.create_image(text)
|
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
|
@staticmethod
|
||||||
def format_text(text):
|
def format_text(text):
|
||||||
|
@ -33,8 +33,8 @@ class Vzhuh(Base):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_image(text):
|
def create_image(text):
|
||||||
img = Image.open("data/vzhuh_sample.png")
|
img = Image.open("resources/vzhuh/sample.png")
|
||||||
draw = ImageDraw.Draw(img)
|
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)
|
draw.text((222, 280), text, (0, 0, 0), font=font)
|
||||||
img.save('data/sample-out.png')
|
img.save('storage/vzhuh.png')
|
||||||
|
|
|
@ -8,8 +8,8 @@ class Woof(Base):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def execute(bot, command):
|
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"})
|
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.write(urlopen(req).read())
|
||||||
output.close()
|
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'))
|
||||||
|
|
Loading…
Reference in New Issue