add option for timed messages or reply-based messages
This commit is contained in:
parent
2907cbc325
commit
537b2a11fd
|
@ -6,6 +6,9 @@ import json
|
||||||
import random
|
import random
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
TIMED = 0
|
||||||
|
REPLY = 1
|
||||||
|
mode = REPLY
|
||||||
|
|
||||||
START = "__START"
|
START = "__START"
|
||||||
END = "__END"
|
END = "__END"
|
||||||
|
@ -28,7 +31,8 @@ class MyClient(discord.Client):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*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):
|
async def on_ready(self):
|
||||||
print('logged in as {0.user}'.format(self), file=sys.stderr)
|
print('logged in as {0.user}'.format(self), file=sys.stderr)
|
||||||
|
@ -37,10 +41,14 @@ class MyClient(discord.Client):
|
||||||
if message.author == self.user:
|
if message.author == self.user:
|
||||||
return
|
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
|
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):
|
async def background(self):
|
||||||
await self.wait_until_ready()
|
await self.wait_until_ready()
|
||||||
|
|
Loading…
Reference in a new issue