Quellcode durchsuchen

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

master
Zac Herd vor 5 Jahren
Ursprung
Commit
b0b64a835e
6 geänderte Dateien mit 4 neuen und 9 gelöschten Zeilen
  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 Datei anzeigen

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


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



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


+ 2
- 2
bot.py Datei anzeigen

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


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


+ 1
- 1
commands.py Datei anzeigen

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


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


+ 1
- 1
common.py Datei anzeigen

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


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


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


+ 0
- 0
helpers.py Datei anzeigen


markovs/.gitignore → persist/markovs/.gitignore Datei anzeigen


Laden…
Abbrechen
Speichern