add a safeguard for empty list categories redeems

remove warnings in readme about it as well
This commit is contained in:
Lili (Tlapka) 2023-01-16 13:30:15 +01:00
parent dc68887c82
commit 0c678d8988
2 changed files with 2 additions and 2 deletions

View File

@ -274,4 +274,4 @@ Each dictionary entry is a redeem, and the dictionary keys are strings that deci
- `"price"` value should be an integer that decides how many points the redeem will cost. - `"price"` value should be an integer that decides how many points the redeem will cost.
- `"type"` value should be either `"list"`, `"counter"` or `"note"`. This decided the redeem's type, and whether it will show up as a counter at the top of the dashboard or as an entry in the "recent redeems" chart. - `"type"` value should be either `"list"`, `"counter"` or `"note"`. This decided the redeem's type, and whether it will show up as a counter at the top of the dashboard or as an entry in the "recent redeems" chart.
- `"info"` value should be a string that describes what the command does. It's optional, but I recommend writing one for all `"list"` and `"note"` redeems (so that chatters know that they should write a note). - `"info"` value should be a string that describes what the command does. It's optional, but I recommend writing one for all `"list"` and `"note"` redeems (so that chatters know that they should write a note).
- `"category"` is an optional list of strings, the categories the redeem is in. If a category from the list is in `ACTIVE_CATEGORIES` from `config.py`, then the redeem will be active. Otherwise it will not appear at all. **If you want a redeem to be always active, leave this field out.** - `"category"` is an optional list of strings, the categories the redeem is in. If a category from the list is in `ACTIVE_CATEGORIES` from `config.py`, then the redeem will be active.

View File

@ -236,7 +236,7 @@ def remove_emoji(message):
def is_redeem_active(redeem, active_categories): def is_redeem_active(redeem, active_categories):
if "category" in redeem[1]: if "category" in redeem[1] and redeem[1]["category"]:
for category in redeem[1]["category"]: for category in redeem[1]["category"]:
if category in active_categories: if category in active_categories:
return True return True