Merge branch 'master' of github.com:telegram-bots/imaginaryfriend
This commit is contained in:
commit
a029a4ce31
|
@ -2,11 +2,14 @@
|
||||||
*.pyc
|
*.pyc
|
||||||
*.rb
|
*.rb
|
||||||
*.sublime-workspace
|
*.sublime-workspace
|
||||||
|
*.sublime-project
|
||||||
*.txt
|
*.txt
|
||||||
logging.cfg
|
logging.cfg
|
||||||
storage
|
storage
|
||||||
venv
|
venv
|
||||||
ruby*/
|
ruby*/
|
||||||
|
.idea
|
||||||
|
*.ipynb
|
||||||
|
|
||||||
### Linux ###
|
### Linux ###
|
||||||
*~
|
*~
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
FROM python:3.6.2-alpine3.6
|
FROM python:3.6.2-alpine3.6
|
||||||
ENV CONFIG_PATH "cfg/main.docker.cfg"
|
ENV CONFIG_PATH "cfg/main.docker.cfg"
|
||||||
|
ENV LIBRARY_PATH=/lib:/usr/lib
|
||||||
RUN mkdir /code/
|
RUN mkdir /code/
|
||||||
WORKDIR /code
|
WORKDIR /code
|
||||||
ADD requirements.txt /code/
|
ADD requirements.txt /code/
|
||||||
RUN pip install -r requirements.txt
|
RUN apk add --no-cache build-base jpeg-dev zlib-dev && pip install -r requirements.txt && apk del build-base
|
||||||
ADD . /code/
|
ADD . /code/
|
||||||
CMD ["python", "-u", "run.py"]
|
CMD ["python", "-u", "run.py"]
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
python-telegram-bot==6.1.0
|
python-telegram-bot==6.1.0
|
||||||
redis==2.10.6
|
redis==2.10.6
|
||||||
Pillow==4.1.0
|
retry==0.9.2
|
||||||
|
Pillow==4.2.1
|
||||||
|
|
|
@ -7,8 +7,9 @@ mod_f - (ADMIN ONLY) Find word to remove
|
||||||
mod_d - (ADMIN ONLY) Remove given word
|
mod_d - (ADMIN ONLY) Remove given word
|
||||||
meow - Random cat pic
|
meow - Random cat pic
|
||||||
borscht - Random borscht pic
|
borscht - Random borscht pic
|
||||||
vzhuh и текст - Create вжух meme with «вжух и текст» caption
|
|
||||||
woof - Random dog pic
|
woof - Random dog pic
|
||||||
boobs - Random boobs pic
|
boobs - Random boobs pic
|
||||||
butts - Random butt pic
|
butts - Random butt pic
|
||||||
xkcd - Random xkcd comic
|
xkcd - Random xkcd comic
|
||||||
|
o – Random facepalm pic
|
||||||
|
vzhuh и текст - Create вжух meme with «вжух и текст» caption
|
||||||
|
|
|
@ -12,7 +12,8 @@ Available commands:
|
||||||
• /woof: show random dog pic,
|
• /woof: show random dog pic,
|
||||||
• /boobs: show random boobs pic,
|
• /boobs: show random boobs pic,
|
||||||
• /butts: show random butt pic,
|
• /butts: show random butt pic,
|
||||||
• /xkcd: show random xkcd comic.
|
• /xkcd: show random xkcd comic
|
||||||
|
• /o: send random facepalm pic.
|
||||||
|
|
||||||
If you get tired of me, you can kick me from the group.
|
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!
|
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!
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
from telegram import Update
|
from telegram import Update
|
||||||
from telegram.ext import Handler
|
from telegram.ext import Handler
|
||||||
|
from telegram.ext.dispatcher import run_async
|
||||||
|
|
||||||
from src.domain.command import Command
|
from src.domain.command import Command
|
||||||
from .commands import commands
|
from .commands import commands
|
||||||
|
@ -25,6 +26,7 @@ class CommandHandler(Handler):
|
||||||
|
|
||||||
return self.callback(dispatcher.bot, update, **optional_args)
|
return self.callback(dispatcher.bot, update, **optional_args)
|
||||||
|
|
||||||
|
@run_async
|
||||||
def handle(self, bot, update):
|
def handle(self, bot, update):
|
||||||
command = Command(update.message)
|
command = Command(update.message)
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,19 @@
|
||||||
from src.handler.commands.base import Base
|
from src.handler.commands.base import Base
|
||||||
from src.handler.commands.start import Start
|
|
||||||
from src.handler.commands.help import Help
|
|
||||||
from src.handler.commands.ping import Ping
|
|
||||||
from src.handler.commands.get_stats import GetStats
|
|
||||||
from src.handler.commands.moderate import Moderate
|
|
||||||
from src.handler.commands.chance import Chance
|
from src.handler.commands.chance import Chance
|
||||||
|
from src.handler.commands.get_stats import GetStats
|
||||||
|
from src.handler.commands.help import Help
|
||||||
|
from src.handler.commands.moderate import Moderate
|
||||||
|
from src.handler.commands.ping import Ping
|
||||||
|
from src.handler.commands.start import Start
|
||||||
|
|
||||||
from src.handler.commands.butts import Butts
|
|
||||||
from src.handler.commands.boobs import Boobs
|
from src.handler.commands.boobs import Boobs
|
||||||
from src.handler.commands.meow import Meow
|
|
||||||
from src.handler.commands.woof import Woof
|
|
||||||
from src.handler.commands.borscht import Borscht
|
from src.handler.commands.borscht import Borscht
|
||||||
from src.handler.commands.xkcd import XKCD
|
from src.handler.commands.butts import Butts
|
||||||
|
from src.handler.commands.facepalm import Facepalm
|
||||||
|
from src.handler.commands.meow import Meow
|
||||||
from src.handler.commands.vzhuh import Vzhuh
|
from src.handler.commands.vzhuh import Vzhuh
|
||||||
|
from src.handler.commands.woof import Woof
|
||||||
|
from src.handler.commands.xkcd import XKCD
|
||||||
|
|
||||||
commands = {}
|
commands = {}
|
||||||
for clazz in Base.__subclasses__():
|
for clazz in Base.__subclasses__():
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
from .base import Base
|
||||||
|
from urllib.request import urlopen, Request
|
||||||
|
|
||||||
|
|
||||||
|
class Facepalm(Base):
|
||||||
|
name = 'facepalm'
|
||||||
|
aliases = ['o']
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def execute(bot, command):
|
||||||
|
req = Request("http://loremflickr.com/500/410/facepalm", 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("storage/facepalm.jpg", "wb")
|
||||||
|
output.write(urlopen(req).read())
|
||||||
|
output.close()
|
||||||
|
|
||||||
|
bot.send_photo(chat_id=command.chat_id, photo=open('storage/facepalm.jpg', 'rb'))
|
|
@ -4,7 +4,7 @@ from src.config import config, trigram_repository
|
||||||
|
|
||||||
class Moderate(Base):
|
class Moderate(Base):
|
||||||
aliases = ['mod_f', 'mod_d']
|
aliases = ['mod_f', 'mod_d']
|
||||||
super_admins = config.getlist('bot', 'god_mode')
|
super_admins = [int(id) for id in config.getlist('bot', 'god_mode')]
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def execute(bot, command):
|
def execute(bot, command):
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
import redis
|
import redis
|
||||||
|
from redis.exceptions import BusyLoadingError
|
||||||
|
from retry import retry
|
||||||
|
|
||||||
|
|
||||||
class Redis:
|
class Redis:
|
||||||
|
@ -9,6 +11,11 @@ class Redis:
|
||||||
self.pool = redis.ConnectionPool(host=config['redis']['host'],
|
self.pool = redis.ConnectionPool(host=config['redis']['host'],
|
||||||
port=config.getint('redis', 'port'),
|
port=config.getint('redis', 'port'),
|
||||||
db=config['redis']['db'])
|
db=config['redis']['db'])
|
||||||
|
self.__ensure_dataset_loaded()
|
||||||
|
|
||||||
def instance(self):
|
def instance(self):
|
||||||
return redis.Redis(connection_pool=self.pool)
|
return redis.Redis(connection_pool=self.pool)
|
||||||
|
|
||||||
|
@retry(BusyLoadingError, tries=5, delay=10)
|
||||||
|
def __ensure_dataset_loaded(self):
|
||||||
|
self.instance().ping()
|
||||||
|
|
Loading…
Reference in New Issue