|
|
|
@ -6,9 +6,8 @@ import json
|
|
|
|
|
import random
|
|
|
|
|
import sys
|
|
|
|
|
|
|
|
|
|
TIMED = 0
|
|
|
|
|
REPLY = 1
|
|
|
|
|
mode = REPLY
|
|
|
|
|
TIMED = "timed"
|
|
|
|
|
REPLY = "reply"
|
|
|
|
|
|
|
|
|
|
START = "__START"
|
|
|
|
|
END = "__END"
|
|
|
|
@ -16,6 +15,9 @@ END = "__END"
|
|
|
|
|
with open('markov.json') as f:
|
|
|
|
|
markov = json.load(f)
|
|
|
|
|
|
|
|
|
|
with open('config.json') as f:
|
|
|
|
|
config = json.load(f)
|
|
|
|
|
|
|
|
|
|
def gen_sentence():
|
|
|
|
|
cur = START
|
|
|
|
|
output = []
|
|
|
|
@ -31,7 +33,7 @@ class MyClient(discord.Client):
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
|
super().__init__(*args, **kwargs)
|
|
|
|
|
|
|
|
|
|
if mode == TIMED:
|
|
|
|
|
if config['mode'] == TIMED:
|
|
|
|
|
self.bg_task = self.loop.create_task(self.background())
|
|
|
|
|
|
|
|
|
|
async def on_ready(self):
|
|
|
|
@ -45,8 +47,8 @@ class MyClient(discord.Client):
|
|
|
|
|
await message.channel.send(gen_sentence())
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
if mode == REPLY and random.randrange(50) == 0:
|
|
|
|
|
await asyncio.sleep(random.randrange(180))
|
|
|
|
|
if config['mode'] == REPLY and random.randrange(config['reply_invfreq']) == 0:
|
|
|
|
|
await asyncio.sleep(random.randrange(config['reply_delay_min'], config['reply_delay_max']))
|
|
|
|
|
await message.channel.send(gen_sentence())
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
@ -59,11 +61,9 @@ class MyClient(discord.Client):
|
|
|
|
|
await channel.send(gen_sentence())
|
|
|
|
|
except:
|
|
|
|
|
pass
|
|
|
|
|
await asyncio.sleep((2700 + random.randrange(1800)) // min(max(len(self.guilds), 1), 100))
|
|
|
|
|
await asyncio.sleep(max(30, random.randrange(config['timed_interval_min'], config['timed_interval_max']) // max(1, len(self.guilds))))
|
|
|
|
|
if self.is_closed():
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
client = MyClient()
|
|
|
|
|
with open('token') as f:
|
|
|
|
|
token = f.read().strip()
|
|
|
|
|
client.run(token)
|
|
|
|
|
client.run(config['token'])
|
|
|
|
|