(guild admin): Add greeting messages.

New `SettingType` `Message` for general message settings.
New setting `greeting_message`.
New setting `greeting_channel`.
New setting `starting_funds`.
New setting `returning_message`.
Add a greeting message hook.
Add initial funds on lion creation.
Data migration v3 -> v4.
This commit is contained in:
2021-10-04 18:13:53 +03:00
parent a3b339d1cf
commit b31a34e725
13 changed files with 499 additions and 14 deletions

View File

@@ -17,7 +17,7 @@ tick = '✅'
cross = ''
def prop_tabulate(prop_list, value_list, indent=True):
def prop_tabulate(prop_list, value_list, indent=True, colon=True):
"""
Turns a list of properties and corresponding list of values into
a pretty string with one `prop: value` pair each line,
@@ -39,7 +39,7 @@ def prop_tabulate(prop_list, value_list, indent=True):
max_len = max(len(prop) for prop in prop_list)
return "".join(["`{}{}{}`\t{}{}".format(" " * (max_len - len(prop)) if indent else "",
prop,
":" if len(prop) else " " * 2,
(":" if len(prop) else " " * 2) if colon else '',
value_list[i],
'' if str(value_list[i]).endswith("```") else '\n')
for i, prop in enumerate(prop_list)])
@@ -528,3 +528,14 @@ def utc_now():
Return the current timezone-aware utc timestamp.
"""
return datetime.datetime.utcnow().replace(tzinfo=datetime.timezone.utc)
def multiple_replace(string, rep_dict):
if rep_dict:
pattern = re.compile(
"|".join([re.escape(k) for k in sorted(rep_dict, key=len, reverse=True)]),
flags=re.DOTALL
)
return pattern.sub(lambda x: str(rep_dict[x.group(0)]), string)
else:
return string