mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-12 22:49:53 -05:00
commit
25367e4849
53
sopel_modules/SpiceBot/ReleaseNotes.py
Normal file
53
sopel_modules/SpiceBot/ReleaseNotes.py
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
# coding=utf8
|
||||||
|
from __future__ import unicode_literals, absolute_import, division, print_function
|
||||||
|
"""This is a method to read files, online and local, and cache them"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
from .Read import read as botread
|
||||||
|
from .Database import db as botdb
|
||||||
|
|
||||||
|
|
||||||
|
class BotNotes():
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.notes = botdb.get_plugin_value('SpiceBot_Release_Notes', 'notes') or dict()
|
||||||
|
self.dir_to_scan = botread.get_config_dirs("SpiceBot_Release_Notes")
|
||||||
|
self.load_txt_files(self.dir_to_scan)
|
||||||
|
self.save_notes()
|
||||||
|
|
||||||
|
def save_notes(self):
|
||||||
|
savenotes = {}
|
||||||
|
for notefile in list(self.notes.keys()):
|
||||||
|
savenotes[notefile] = {"old": self.notes[notefile]["old"]}
|
||||||
|
botdb.set_plugin_value('SpiceBot_Release_Notes', 'notes', savenotes)
|
||||||
|
|
||||||
|
def load_txt_files(self, dir_to_scan):
|
||||||
|
# iterate over files within
|
||||||
|
for directory in dir_to_scan:
|
||||||
|
for file in os.listdir(directory):
|
||||||
|
filepath = os.path.join(directory, file)
|
||||||
|
filepath = os.path.join(directory, file)
|
||||||
|
if os.path.isfile(filepath) and filepath.endswith('.txt'):
|
||||||
|
# gather file stats
|
||||||
|
slashsplit = str(filepath).split("/")
|
||||||
|
filename = slashsplit[-1]
|
||||||
|
filename_base = str(os.path.basename(filename).rsplit('.', 1)[0]).lower()
|
||||||
|
|
||||||
|
if filename_base not in list(self.notes.keys()):
|
||||||
|
self.notes[filename_base] = {}
|
||||||
|
if "old" not in list(self.notes[filename_base].keys()):
|
||||||
|
self.notes[filename_base]["old"] = []
|
||||||
|
if "new" not in list(self.notes[filename_base].keys()):
|
||||||
|
self.notes[filename_base]["new"] = []
|
||||||
|
|
||||||
|
text_file = open(filepath, 'r')
|
||||||
|
lines = text_file.readlines()
|
||||||
|
for line in lines:
|
||||||
|
if str(line) not in self.notes[filename_base]["old"]:
|
||||||
|
self.notes[filename_base]["new"].append(str(line))
|
||||||
|
self.notes[filename_base]["old"].append(str(line))
|
||||||
|
text_file.close()
|
||||||
|
|
||||||
|
|
||||||
|
releasenotes = BotNotes()
|
||||||
@ -39,6 +39,7 @@ from .Read import *
|
|||||||
from .Translate import *
|
from .Translate import *
|
||||||
from .Version import *
|
from .Version import *
|
||||||
from .RegNicks import *
|
from .RegNicks import *
|
||||||
|
from .ReleaseNotes import *
|
||||||
|
|
||||||
|
|
||||||
__author__ = 'Sam Zick'
|
__author__ = 'Sam Zick'
|
||||||
|
|||||||
@ -107,6 +107,7 @@ def setup_startupmonologue(bot):
|
|||||||
botevents.BOT_STARTUPMONOLOGUE_COMMANDS,
|
botevents.BOT_STARTUPMONOLOGUE_COMMANDS,
|
||||||
botevents.BOT_STARTUPMONOLOGUE_AI,
|
botevents.BOT_STARTUPMONOLOGUE_AI,
|
||||||
botevents.BOT_STARTUPMONOLOGUE_VERSION,
|
botevents.BOT_STARTUPMONOLOGUE_VERSION,
|
||||||
|
botevents.BOT_STARTUPMONOLOGUE_RNOTES,
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1 @@
|
|||||||
|
First release of Release Notes
|
||||||
@ -0,0 +1 @@
|
|||||||
|
Search API can extend to Urban dictionary
|
||||||
21
sopel_modules/SpiceBot_Core_Commands/ReleaseNotes.py
Normal file
21
sopel_modules/SpiceBot_Core_Commands/ReleaseNotes.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# coding=utf8
|
||||||
|
from __future__ import unicode_literals, absolute_import, division, print_function
|
||||||
|
"""
|
||||||
|
This is the SpiceBot Users system.
|
||||||
|
"""
|
||||||
|
import sopel
|
||||||
|
|
||||||
|
import sopel_modules.SpiceBot as SpiceBot
|
||||||
|
from sopel_modules.spicemanip import spicemanip
|
||||||
|
|
||||||
|
|
||||||
|
@SpiceBot.prerun('nickname')
|
||||||
|
@sopel.module.nickname_commands('releasenotes')
|
||||||
|
def nickname_comand_releasenotes(bot, trigger, botcom):
|
||||||
|
newnotes = False
|
||||||
|
for notefile in list(SpiceBot.releasenotes.notes.keys()):
|
||||||
|
if len(SpiceBot.releasenotes.notes[notefile]["new"]):
|
||||||
|
bot.osd(["[" + str(notefile) + "]", spicemanip(SpiceBot.releasenotes.notes[notefile]["new"], 'andlist')])
|
||||||
|
newnotes = True
|
||||||
|
if not newnotes:
|
||||||
|
bot.osd("This bot restart contains no new release notes.")
|
||||||
@ -24,6 +24,7 @@ from .DictComs import *
|
|||||||
from .TODO import *
|
from .TODO import *
|
||||||
from .Version import *
|
from .Version import *
|
||||||
from .RegNicks import *
|
from .RegNicks import *
|
||||||
|
from .ReleaseNotes import *
|
||||||
|
|
||||||
__author__ = 'Sam Zick'
|
__author__ = 'Sam Zick'
|
||||||
__email__ = 'sam@deathbybandaid.net'
|
__email__ = 'sam@deathbybandaid.net'
|
||||||
|
|||||||
@ -67,6 +67,20 @@ def bot_startup_monologue_ai(bot, trigger):
|
|||||||
SpiceBot.events.trigger(bot, SpiceBot.events.BOT_STARTUPMONOLOGUE_AI, "SpiceBot_StartupMonologue")
|
SpiceBot.events.trigger(bot, SpiceBot.events.BOT_STARTUPMONOLOGUE_AI, "SpiceBot_StartupMonologue")
|
||||||
|
|
||||||
|
|
||||||
|
@sopel.module.event(SpiceBot.events.BOT_READY)
|
||||||
|
@sopel.module.rule('.*')
|
||||||
|
def bot_startup_monologue_releasenotes(bot, trigger):
|
||||||
|
newnotes = False
|
||||||
|
for notefile in list(SpiceBot.releasenotes.notes.keys()):
|
||||||
|
if len(SpiceBot.releasenotes.notes[notefile]["new"]):
|
||||||
|
newnotes = True
|
||||||
|
if newnotes:
|
||||||
|
displayval = "Check Release Notes for News"
|
||||||
|
SpiceBot.startupmonologue.dict["releasenotes"] = displayval
|
||||||
|
SpiceBot.logs.log('SpiceBot_StartupMonologue', displayval)
|
||||||
|
SpiceBot.events.trigger(bot, SpiceBot.events.BOT_STARTUPMONOLOGUE_RNOTES, "SpiceBot_StartupMonologue")
|
||||||
|
|
||||||
|
|
||||||
@sopel.module.event(SpiceBot.events.BOT_LOADED)
|
@sopel.module.event(SpiceBot.events.BOT_LOADED)
|
||||||
@sopel.module.rule('.*')
|
@sopel.module.rule('.*')
|
||||||
def bot_startup_monologue_display(bot, trigger):
|
def bot_startup_monologue_display(bot, trigger):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user