Browse Source

v1.2.2, move persistent storage into persist/ subdir, in preparation for docker

master
Zac Herd 5 years ago
parent
commit
b0b64a835e
6 changed files with 4 additions and 9 deletions
  1. +0
    -5
      admincommands.py
  2. +2
    -2
      bot.py
  3. +1
    -1
      commands.py
  4. +1
    -1
      common.py
  5. +0
    -0
      helpers.py
  6. +0
    -0
      persist/markovs/.gitignore

+ 0
- 5
admincommands.py View File

@@ -24,11 +24,6 @@ def cmd_die(client, msg):
yield from client.send_message(msg.channel, "But will I dream? ;-;")
yield from client.logout()

if msg.content[5:] == "reload":
# touch file to signal reload
with open("reload", "a"):
os.utime("reload", None)


@asyncio.coroutine
def cmd_quiet(client, msg):


+ 2
- 2
bot.py View File

@@ -70,14 +70,14 @@ def on_message(msg):
if msg.content != "":
history[msg.server.id + msg.author.id] = (msg.server.id,
time.time(), msg.content)
with open('hist.json', 'w') as fp:
with open('./persist/hist.json', 'w') as fp:
json.dump(history, fp)

# log user messages for markov chains, ignoring messages with certain substrings
filters = ['`', 'http://', 'https://']
if not any(x in msg.content for x in filters):
try:
with open('./markovs/' + msg.server.id + '-' + msg.author.id,
with open('./persist/markovs/' + msg.server.id + '-' + msg.author.id,
'a') as fp:
fp.write('\n' + msg.content)
except PermissionError:


+ 1
- 1
commands.py View File

@@ -123,7 +123,7 @@ def cmd_markov(client, msg):
reponse = "I can't find `{}`".format(tmp)

if target != "":
mfile = "./markovs/" + target
mfile = "./persist/markovs/" + target
if os.path.isfile(mfile):
mc = markov.Markov(open(mfile))
response = mc.generate_text(random.randint(20, 40))


+ 1
- 1
common.py View File

@@ -10,7 +10,7 @@ import os
import json

# bot version
version = "v1.2.0"
version = "v1.2.2"

# TODO: generate this on the fly and make it look acceptable
# text shown by .help command


+ 0
- 0
helpers.py View File


markovs/.gitignore → persist/markovs/.gitignore View File


Loading…
Cancel
Save