Commit 3411cbbf authored by root's avatar root

Fix: Error photo reply

parent e1b7f01e
......@@ -124,10 +124,10 @@ class Bot(ABC):
""" Responses with the error message. Sometimes send a meme! """
logging.error("Update '%s' caused error '%s'", update, context.error)
try:
num = randint(0,10)
num = randint(0,6)
if num == 0:
file = open("Media/meme-errors.jpg", "rb", encoding="utf8")
update.reply_photo(photo=file)
file = open("Media/meme-errors.jpg", "rb")
update.message.reply_photo(photo=file)
except Exception:
logging.error("Cannot send error-meme!")
update.message.reply_text("Ups, something went wrong!\n'" + str(context.error)[:15] + "'")
\ No newline at end of file
......@@ -12,8 +12,6 @@ with the Pattern command_* (command_help).
Call {QuizzBot.run()} to start the bot.
#TODO I added id to tg option
"""
import re
......@@ -140,6 +138,7 @@ class QuizzBot(Bot):
logging.debug(user)
message = self.get_or_add(update.message, chat.id, user.id)
logging.debug(message)
self.error_callback(update, context)
def private_all(self, update, context):
logging.debug("Got private all message")
......@@ -162,7 +161,7 @@ class QuizzBot(Bot):
Commands
"""
def command_info(self, update, context):
def command_commands(self, update, context):
"""
Get an info about all possible commands
"""
......@@ -174,6 +173,22 @@ class QuizzBot(Bot):
text += "/" + command.get_name() + "\n"
update.message.reply_text(text)
def command_info(self, update, context):
"""
Get an info
"""
text = "I am the Bot for the groups __t.me/Chatquizz__ and __t.me/Nerdquiz.\n"+\
"I manage these and give them some extra favor. ;) Also i eject a kind of the group every Week/Month.\n"+\
"Mostly im passive. But when you wanna talk to me, than type /commands to see some interactions."
update.message.reply_text(text)
def command_elect(self, update, context):
"""
Elect the quiz master king in all groups
"""
if(update.message.from_user.username in self._admins):
print("TODO")
def command_restart(self, update, context):
"""
Restart bot by Admin
......@@ -208,9 +223,9 @@ class QuizzBot(Bot):
""" It handles new users. """
text = "Hello "+tg_user.first_name+", I am the QuizMaster for the Group you recently joined!\n"+\
"I will just inform you about the Group: The group uses the new verions of polls of Telegram.\n"+\
"You can now create a quiz-poll by checking a option under the question and then select the right answer! :) \n"+\
"You can now create a quiz-poll by checking a option under the question and then select the right answer! :)\n"+\
"Look into the group-status for more infos or contact me by wirting: /info \n"+\
"I also elect the king of the quizzes, the quiz master, every month. See you in the group! :D"
"I also elect the king of the quizzes, the quiz master, every week/month. See you in the group! :D"
# Contact new users
file = open("Media/quiz1.jpg", "rb")
tg_user.send_photo(photo=file)
......
......@@ -11,7 +11,20 @@ emoji_pattern = re.compile("["
u"\U0001F300-\U0001F5FF" # symbols & pictographs
u"\U0001F680-\U0001F6FF" # transport & map symbols
u"\U0001F1E0-\U0001F1FF" # flags (iOS)
"]+", flags=re.UNICODE)
u"\U00002702-\U000027B0" # ...
u"\U00002702-\U000027B0"
u"\U000024C2-\U0001F251"
u"\U0001f926-\U0001f937"
u"\U00010000-\U0010ffff"
u"\u2640-\u2642"
u"\u2600-\u2B55"
u"\u200d"
u"\u23cf"
u"\u23e9"
u"\u231a"
u"\ufe0f"
u"\u3030"
"]+", flags=re.UNICODE)
def emoji_decode(text):
""" Decodes a string for db by removing emojis """
text = emoji_pattern.sub(r':)', str(text))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment