add option for timed messages or reply-based messages

master
xenofem 2020-05-14 10:55:03 -04:00
parent 2907cbc325
commit 537b2a11fd
1 changed files with 11 additions and 3 deletions

View File

@ -6,6 +6,9 @@ import json
import random
import sys
TIMED = 0
REPLY = 1
mode = REPLY
START = "__START"
END = "__END"
@ -28,7 +31,8 @@ class MyClient(discord.Client):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.bg_task = self.loop.create_task(self.background())
if mode == TIMED:
self.bg_task = self.loop.create_task(self.background())
async def on_ready(self):
print('logged in as {0.user}'.format(self), file=sys.stderr)
@ -37,10 +41,14 @@ class MyClient(discord.Client):
if message.author == self.user:
return
if self.user not in message.mentions and self.user not in [m for role in message.role_mentions for m in role.members]:
if self.user in message.mentions or self.user in [m for role in message.role_mentions for m in role.members]):
await message.channel.send(gen_sentence())
return
await message.channel.send(gen_sentence())
if mode == REPLY and random.randrange(50) == 0:
await asyncio.sleep(random.randrange(180))
await message.channel.send(gen_sentence())
return
async def background(self):
await self.wait_until_ready()