More docs to the discord bot

This commit is contained in:
klemek
2020-04-26 22:22:47 +02:00
parent 27a3ef87c5
commit 345ad32664
5 changed files with 53 additions and 33 deletions
+10 -3
View File
@@ -100,14 +100,20 @@ async def on_message(message):
debug(message, str(args))
if len(args) == 0 or args[0].lower().strip() == "help":
await message.channel.send(f"Hey {message.author.mention},\n"
f"You can generate a meme with the syntax\n"
f"You can generate a meme with the syntax:\n"
f"```\n"
f"[template] \"text 1\" \"text 2\" ...\n"
f"```\n"
f"```"
f"I also work with DM to keep your server clean of spam.\n"
f"You can find a more detailed help and a list of templates at:\n"
f"Use `delete` to remove my last message\n"
f"Use `list` to get a simple list\n"
f"You can find a more detailed help and a full list of templates at:\n"
f"<https://github.com/klemek/meme-otron/tree/master/discord>")
return
if len(args) > 0 and args[0].lower().strip() == "list":
await message.channel.send(f"Here is a list of all known templates:\n"
f"```{', '.join(db.LIST)}```")
return
if len(args) > 0 and args[0].lower().strip() == "delete":
if mid in SENT and len(SENT[mid]) > 0 and await delete(SENT[mid][-1]):
if not direct:
@@ -157,6 +163,7 @@ async def on_message(message):
if not direct:
await delete(message)
# Launch client and rerun on errors
while True:
try:
+12
View File
@@ -15,6 +15,18 @@ Depending of the number of `"text"` arguments, several behavior occurs:
> * You don't have to use all texts shown on templates
> * You can use an empty text argument ( `""` ) to skip a text and keep it blank
## Discord features
Tag the bot and use the above syntax to get started. In addition, you can use the following commands:
* Use `help` to get a simple help message
* Use `list` to get a list of all meme ids
* Use `delete` to delete the last message sent by the bot (directed to you)
Enjoy the full experience of this bot by using direct messages to keep your server free of spam.
## List of templates
You can find here the full list of templates.
+1 -2
View File
@@ -31,7 +31,7 @@ def make_empty(target_dir):
make_empty(dst_dir)
make_empty(prev_dir)
ids = sorted(meme_db.DATA.keys())
ids = sorted(meme_db.LIST)
doc_content = "|" * (COLUMNS + 1) \
+ "\n|" + ":---:|" * COLUMNS
@@ -42,7 +42,6 @@ img_line = None
i = None
for i, meme_id in enumerate(ids):
meme = meme_db.get_meme(meme_id)
if meme is not None:
img = imgf.make(meme.template, meme.texts, debug=True)
if img is not None:
img.save(path.join(dst_dir, meme.template))
+3
View File
@@ -8,6 +8,7 @@ DATA_FILE = utils.relative_path(__file__, "..", "memes.json")
DATA = {}
ALIASES = {}
LIST = []
logger = logging.getLogger("meme_db")
@@ -45,6 +46,7 @@ def load_item(i, item):
:param (int) i:
:param (dict) item:
"""
global LIST
item_id = ""
try:
if not (isinstance(item, dict)):
@@ -102,6 +104,7 @@ def load_item(i, item):
else:
DATA[item_id] = meme
if not meme.abstract:
LIST += [item_id]
ALIASES[item_id] = item_id
for alias in meme.aliases:
if alias in ALIASES:
+1 -2
View File
@@ -28,9 +28,8 @@ while True:
time.sleep(0.1)
meme_db.load_memes(purge=True)
count = 0
for meme_id in meme_db.DATA:
for meme_id in meme_db.LIST:
meme = meme_db.get_meme(meme_id)
if meme is not None:
img = imgf.make(meme.template, meme.texts, debug=True)
if img is not None:
img.save(path.join(dst_dir, meme.template))