More docs to the discord bot
This commit is contained in:
+10
-3
@@ -100,14 +100,20 @@ async def on_message(message):
|
|||||||
debug(message, str(args))
|
debug(message, str(args))
|
||||||
if len(args) == 0 or args[0].lower().strip() == "help":
|
if len(args) == 0 or args[0].lower().strip() == "help":
|
||||||
await message.channel.send(f"Hey {message.author.mention},\n"
|
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"```\n"
|
||||||
f"[template] \"text 1\" \"text 2\" ...\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"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>")
|
f"<https://github.com/klemek/meme-otron/tree/master/discord>")
|
||||||
return
|
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 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 mid in SENT and len(SENT[mid]) > 0 and await delete(SENT[mid][-1]):
|
||||||
if not direct:
|
if not direct:
|
||||||
@@ -157,6 +163,7 @@ async def on_message(message):
|
|||||||
if not direct:
|
if not direct:
|
||||||
await delete(message)
|
await delete(message)
|
||||||
|
|
||||||
|
|
||||||
# Launch client and rerun on errors
|
# Launch client and rerun on errors
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -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 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
|
> * 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
|
## List of templates
|
||||||
|
|
||||||
You can find here the full list of templates.
|
You can find here the full list of templates.
|
||||||
|
|||||||
+1
-2
@@ -31,7 +31,7 @@ def make_empty(target_dir):
|
|||||||
make_empty(dst_dir)
|
make_empty(dst_dir)
|
||||||
make_empty(prev_dir)
|
make_empty(prev_dir)
|
||||||
|
|
||||||
ids = sorted(meme_db.DATA.keys())
|
ids = sorted(meme_db.LIST)
|
||||||
|
|
||||||
doc_content = "|" * (COLUMNS + 1) \
|
doc_content = "|" * (COLUMNS + 1) \
|
||||||
+ "\n|" + ":---:|" * COLUMNS
|
+ "\n|" + ":---:|" * COLUMNS
|
||||||
@@ -42,7 +42,6 @@ img_line = None
|
|||||||
i = None
|
i = None
|
||||||
for i, meme_id in enumerate(ids):
|
for i, meme_id in enumerate(ids):
|
||||||
meme = meme_db.get_meme(meme_id)
|
meme = meme_db.get_meme(meme_id)
|
||||||
if meme is not None:
|
|
||||||
img = imgf.make(meme.template, meme.texts, debug=True)
|
img = imgf.make(meme.template, meme.texts, debug=True)
|
||||||
if img is not None:
|
if img is not None:
|
||||||
img.save(path.join(dst_dir, meme.template))
|
img.save(path.join(dst_dir, meme.template))
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ DATA_FILE = utils.relative_path(__file__, "..", "memes.json")
|
|||||||
|
|
||||||
DATA = {}
|
DATA = {}
|
||||||
ALIASES = {}
|
ALIASES = {}
|
||||||
|
LIST = []
|
||||||
|
|
||||||
logger = logging.getLogger("meme_db")
|
logger = logging.getLogger("meme_db")
|
||||||
|
|
||||||
@@ -45,6 +46,7 @@ def load_item(i, item):
|
|||||||
:param (int) i:
|
:param (int) i:
|
||||||
:param (dict) item:
|
:param (dict) item:
|
||||||
"""
|
"""
|
||||||
|
global LIST
|
||||||
item_id = ""
|
item_id = ""
|
||||||
try:
|
try:
|
||||||
if not (isinstance(item, dict)):
|
if not (isinstance(item, dict)):
|
||||||
@@ -102,6 +104,7 @@ def load_item(i, item):
|
|||||||
else:
|
else:
|
||||||
DATA[item_id] = meme
|
DATA[item_id] = meme
|
||||||
if not meme.abstract:
|
if not meme.abstract:
|
||||||
|
LIST += [item_id]
|
||||||
ALIASES[item_id] = item_id
|
ALIASES[item_id] = item_id
|
||||||
for alias in meme.aliases:
|
for alias in meme.aliases:
|
||||||
if alias in ALIASES:
|
if alias in ALIASES:
|
||||||
|
|||||||
+1
-2
@@ -28,9 +28,8 @@ while True:
|
|||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
meme_db.load_memes(purge=True)
|
meme_db.load_memes(purge=True)
|
||||||
count = 0
|
count = 0
|
||||||
for meme_id in meme_db.DATA:
|
for meme_id in meme_db.LIST:
|
||||||
meme = meme_db.get_meme(meme_id)
|
meme = meme_db.get_meme(meme_id)
|
||||||
if meme is not None:
|
|
||||||
img = imgf.make(meme.template, meme.texts, debug=True)
|
img = imgf.make(meme.template, meme.texts, debug=True)
|
||||||
if img is not None:
|
if img is not None:
|
||||||
img.save(path.join(dst_dir, meme.template))
|
img.save(path.join(dst_dir, meme.template))
|
||||||
|
|||||||
Reference in New Issue
Block a user