Skip to content
This repository has been archived by the owner on Oct 23, 2022. It is now read-only.

Commit

Permalink
added simple versioning system (1.0.1.0)
Browse files Browse the repository at this point in the history
  • Loading branch information
djetelina committed Jun 5, 2016
1 parent c118004 commit 40f9359
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 3 deletions.
42 changes: 42 additions & 0 deletions cogs/versioning.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import logging

from discord.ext import commands

from helpers import descriptions as desc, simplify as s

log = logging.getLogger(__name__)


class Versioning:
"""
This versioning system probably isn't perfect, but since this is not a pip package,
I didn't find any good practices online. I'm open to discussion
"""
version = ""
changelog = ""

def __init__(self, bot):
self.bot = bot

with open('cogs/versioning/changelog.md', 'r') as changes:
Versioning.changelog = changes.read()
log.debug("Changelog loaded from file")

with open('cogs/versioning/version.txt', 'r') as v:
Versioning.version = v.readline()
log.debug("version loaded from file")

@commands.command(name='version', description=desc.v_command, brief=desc.v_command)
async def v(self):
await self.bot.say("Current version: {}".format(Versioning.version))

@commands.command(name='changelog', pass_context=True, description=desc.changelog, brief=desc.changelog)
async def chlog(self, ctx):
# Test that your markdown looks pretty in ```md``` tag in Discord
# Split minor versions (major.minor.patch.bugfixes) with '** **'
chlog = "```md\n{0}```".format(Versioning.changelog.split("** **")[0])
await s.whisper(ctx.message.author, chlog, self.bot)


def setup(bot):
bot.add_cog(Versioning(bot))
13 changes: 13 additions & 0 deletions cogs/versioning/changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Changelog
=========

1.0
===

1.0.1
-----
* Added Versioning system
* Everything up to this point is only found in commits
* [!version][] says bot's version out loud
* [!changelog][] whispers caller last changes
** **
1 change: 1 addition & 0 deletions cogs/versioning/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0.1.0
17 changes: 15 additions & 2 deletions helpers/descriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,21 @@
Description strings
"""

main = """Bot for Idiotech's Discord
try:
with open('cogs/versioning/version.txt', 'r') as v:
version = " (v{})".format(v.readline())
except:
version = ""

main = """Bot for Idiotech's Discord{}
Owner: iScrE4m
Contributors: Extra_Random, Otter
Source code: https://github.com/iScrE4m/IdiotechDiscordBot
Request a feature: https://github.com/iScrE4m/IdiotechDiscordBot/issues
Commands can have subcommands, you can type !help for those too
For example: !help giveaway open"""
For example: !help giveaway open""".format(version)

"""
GIVEAWAY RELATED
Expand Down Expand Up @@ -118,3 +124,10 @@

stats = "I'll show you how much you need me!"
statsga = "I'll show you how much giveaways I helped you organize"

"""
VERSIONING
"""

v_command = "My version number"
changelog = "My latest changes"
3 changes: 2 additions & 1 deletion helpers/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
'cogs.weather',
'cogs.swear',
'cogs.overwatch',
'cogs.versioning',
]

# Status message for bot
Expand All @@ -34,5 +35,5 @@
"tabletop": "188081332834926592",
"technology": "188085243478147074",
"programming": "188083195470807040",
"giveaways": "188087131070005248"
"giveaways": "188087131070005248",
}

0 comments on commit 40f9359

Please sign in to comment.