diff --git a/config.json b/config.json index d8a37a4..b656afc 100644 --- a/config.json +++ b/config.json @@ -14,8 +14,8 @@ "nxy.plugins.admin", "nxy.plugins.bitcoin", "nxy.plugins.ctcp", + "nxy.plugins.kernel", "nxy.plugins.mcmaniac", - "nxy.plugins.youtube", "nxy.plugins.quotes", "nxy.plugins.tell", "nxy.plugins.timer", diff --git a/nxy/plugins/kernel.py b/nxy/plugins/kernel.py new file mode 100644 index 0000000..cab4627 --- /dev/null +++ b/nxy/plugins/kernel.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +import feedparser +from docopt import Dict as DocOptDict +from irc3.plugins.command import command +from irc3.utils import IrcString + +from . import Plugin +from ..utils import fmt + + +class Kernel(Plugin): + URL = 'https://www.kernel.org/feeds/kdist.xml' + + @command + def kernel(self, mask: IrcString, channel: IrcString, args: DocOptDict): + """Get Linux kernel releases. + + %%kernel + """ + feed = feedparser.parse(self.URL) + releases = [] + for e in feed['entries']: + version, branch = e['title'].split(': ') + if '(EOL)' in e['description']: + branch = '%s, {italic}EOL{reset}' % branch + releases.append('{bold}%s{reset} (%s)' % (version, branch)) + return fmt('[Kernel] {releases}'.format(releases=', '.join(releases))) diff --git a/requirements.txt b/requirements.txt index d655d74..aa4cd6a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ git+https://github.com/gawel/irc3.git#egg=irc3 aiocron==0.6 requests==2.14.2 +feedparser==5.2.1 python_dotenv==0.6.4