Ver código fonte

Fixed the response size for some /cr sections

master
Mikhail Chernov 8 anos atrás
pai
commit
2ee3eda12b
1 arquivos alterados com 8 adições e 1 exclusões
  1. 8
    1
      magic-judge-telegram-bot.py

+ 8
- 1
magic-judge-telegram-bot.py Ver arquivo

@@ -177,14 +177,21 @@ def comp_rules(bot, update, args):
lang = 'ru'

results = []
other = []
section = words[0].casefold()
pos = len(section)
for name in sorted([name for name in crDataNumbers if name.startswith(section)]):
diff = name[pos:].strip('.')
if len(diff) < 2 and (len(diff) == 0 or diff.isalpha()):
results.append(name)
results.append(name)
elif not diff[-1:].isalpha():
other.append(name)

text = '\n'.join(['<b>{}</b> {}'.format(name, crData['sections'][name][lang]) for name in results])
if other:
text += '\n<i>(Subsections: {}-{})</i>'.format(other[0], other[-1])
if len(text) > 4000:
text = '<b>{}</b> {}\n<i>(See also: {}-{})</i>'.format(results[0], crData['sections'][results[0]][lang], results[1], results[-1])
update.message.reply_text(text, parse_mode='HTML', quote = False)
return


Carregando…
Cancelar
Salvar