1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-27 13:34:28 +00:00

Fix pycharm saying useless things

This commit is contained in:
Steffo 2019-02-10 02:37:34 +01:00
parent 9f70c1cacf
commit 944371b32d

View file

@ -85,6 +85,7 @@ def command(func: "function"):
except TimedOut: except TimedOut:
logger.warning(f"Telegram timed out in {update}") logger.warning(f"Telegram timed out in {update}")
except Exception: except Exception:
# noinspection PyUnreachableCode
if __debug__: if __debug__:
raise raise
logger.error(f"Critical error: {sys.exc_info()}") logger.error(f"Critical error: {sys.exc_info()}")
@ -109,12 +110,14 @@ def command(func: "function"):
return new_func return new_func
# noinspection PyUnresolvedReferences
def database_access(func: "function"): def database_access(func: "function"):
def new_func(bot: telegram.Bot, update: telegram.Update): def new_func(bot: telegram.Bot, update: telegram.Update):
try: try:
session = db.Session() session = db.Session()
return func(bot, update, session) return func(bot, update, session)
except Exception: except Exception:
# noinspection PyUnreachableCode
if __debug__: if __debug__:
raise raise
logger.error(f"Database error: {sys.exc_info()}") logger.error(f"Database error: {sys.exc_info()}")
@ -363,7 +366,7 @@ def cmd_mm(bot: telegram.Bot, update: telegram.Update, session: db.Session):
if user is None: if user is None:
reply(bot, update, strings.LINK.ERRORS.ROYALNET_NOT_LINKED) reply(bot, update, strings.LINK.ERRORS.ROYALNET_NOT_LINKED)
return return
match = re.match(r"/(?:mm|matchmaking)(?:@royalgamesbot)?(?: (?:([0-9]+)-)?([0-9]+))? (?:per )?([A-Za-z0-9!\-_\. ]+)(?:.*\n(.+))?", match = re.match(r"/(?:mm|matchmaking)(?:@royalgamesbot)?(?: (?:([0-9]+)-)?([0-9]+))? (?:per )?([A-Za-z0-9!\-_. ]+)(?:.*\n(.+))?",
update.message.text) update.message.text)
if match is None: if match is None:
reply(bot, update, strings.MATCHMAKING.ERRORS.INVALID_SYNTAX) reply(bot, update, strings.MATCHMAKING.ERRORS.INVALID_SYNTAX)
@ -665,7 +668,7 @@ def cmd_calendar(bot: telegram.Bot, update: telegram.Update, session: db.Session
@command @command
def cmd_markov(bot: telegram.Bot, update: telegram.Update): def cmd_markov(bot: telegram.Bot, update: telegram.Update):
if model is None: if model is None:
bot.send_message(update.message.chat.id, strings.MARKOV.ERRORS.NO_MODEL) reply(bot, update, strings.MARKOV.ERRORS.NO_MODEL)
return return
try: try:
first_word = update.message.text.split(" ")[1] first_word = update.message.text.split(" ")[1]
@ -673,20 +676,20 @@ def cmd_markov(bot: telegram.Bot, update: telegram.Update):
# Any word # Any word
sentence = model.make_sentence(tries=1000) sentence = model.make_sentence(tries=1000)
if sentence is None: if sentence is None:
bot.send_message(update.message.chat.id, strings.MARKOV.ERRORS.GENERATION_FAILED) reply(bot, update, strings.MARKOV.ERRORS.GENERATION_FAILED)
return return
bot.send_message(update.message.chat.id, sentence) reply(bot, update, sentence)
return return
# Specific word # Specific word
try: try:
sentence = model.make_sentence_with_start(first_word, tries=1000) sentence = model.make_sentence_with_start(first_word, tries=1000)
except KeyError: except KeyError:
bot.send_message(update.message.chat.id, strings.MARKOV.ERRORS.MISSING_WORD) reply(bot, update, strings.MARKOV.ERRORS.MISSING_WORD)
return return
if sentence is None: if sentence is None:
bot.send_message(update.message.chat.id, strings.MARKOV.ERRORS.SPECIFIC_WORD_FAILED) reply(bot, update, strings.MARKOV.ERRORS.SPECIFIC_WORD_FAILED)
return return
bot.send_message(update.message.chat.id, sentence) reply(bot, update, sentence)
@command @command