From d9770c886a44c96847bae5a5370fcf4e83eee040 Mon Sep 17 00:00:00 2001 From: Joel Williams Date: Fri, 26 Apr 2019 01:49:44 +0200 Subject: [PATCH 1/3] Display id on recipe and fix brew commands on search results --- bot.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bot.py b/bot.py index 50633b2..dbd7ccd 100644 --- a/bot.py +++ b/bot.py @@ -187,7 +187,7 @@ def craft_cb(bot: Bot, update: Update, groups: tuple) -> None: kb_markup = None if item.complex: - recipe_text = '{name}\n\n'.format(name=item.name) + recipe_text = '{id} - {name}\n\n'.format(id=item.id, name=item.name) recipe_text += gen_craft_tree(item) kb_markup = build_craft_kb(item) else: @@ -318,7 +318,12 @@ def item_search(bot: Bot, update: Update, args: list=None) -> None: for item in items: result_text += '{:>3} - {}'.format(item.id, item.name) - result_text += ' (/craft_{})\n'.format(item.id) if item.complex else ' (/i_{})\n'.format(item.id) + command = 'craft' + if item.id.isdigit() and 39 <= int(item.id) <= 69: + command = 'brew' + elif item.id.startswith('p'): + command = 'brew' + result_text += ' (/{}_{})\n'.format(command, item.id) if item.complex else ' (/i_{})\n'.format(item.id) elif len(items) == 1: for item in items: return craft_cb(bot, update, (item.id, )) From df26311a22435eb8937baaaaad001bae42fe1963 Mon Sep 17 00:00:00 2001 From: Joel Williams Date: Fri, 26 Apr 2019 02:30:29 +0200 Subject: [PATCH 2/3] Get heroku app_name from env --- config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.py b/config.py index 7952e95..a1cf8f7 100644 --- a/config.py +++ b/config.py @@ -33,6 +33,6 @@ 'dsn': os.getenv('DATABASE_URL')} WEBHOOK_PORT = int(os.getenv('PORT')) - WEBHOOK_URL = 'cw-crafts-bot.herokuapp.com' + WEBHOOK_URL = '{}.herokuapp.com'.format(os.getenv('HEROKU_APP_NAME')) else: LOGLEVEL = 'DEBUG' From 29d540a6a899e231051ad985c489626a90bd109e Mon Sep 17 00:00:00 2001 From: Joel Williams Date: Sat, 27 Apr 2019 18:23:13 +0200 Subject: [PATCH 3/3] Refine basic item sql query to return less items --- bot.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bot.py b/bot.py index 1e2c43f..fe6f03f 100644 --- a/bot.py +++ b/bot.py @@ -163,7 +163,8 @@ def craft_list(bot: Bot, update: Update, groups: tuple) -> None: if item_filter == 'all': items = dbItem.select(lambda i: i).order_by(lambda i: i.id) elif item_filter == 'basic': - items = dbItem.select(lambda i: not i.complex).order_by(lambda i: i.id) + #items = dbItem.select(lambda i: not i.complex).order_by(lambda i: i.id) + items = dbItem.select(lambda i: orm.raw_sql(r"i.id ~ E'^\\d+$$'") and orm.between(orm.raw_sql("i.id::integer"), 1, 69) and not i.complex).order_by(lambda i: i.id) elif item_filter == 'complex': items = dbItem.select(lambda i: i.complex).order_by(lambda i: i.id) elif item_filter == 'armour':