diff --git a/markov-bot.py b/markov-bot.py index 22d74c6..fcd7c25 100755 --- a/markov-bot.py +++ b/markov-bot.py @@ -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()