Added feed parser for linux kernel releases

This commit is contained in:
mrhanky 2017-05-28 13:27:28 +02:00
parent 63eb1e3889
commit d921f0de7b
No known key found for this signature in database
GPG Key ID: 67D772C481CB41B8
3 changed files with 29 additions and 1 deletions

View File

@ -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",

27
nxy/plugins/kernel.py Normal file
View File

@ -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)))

View File

@ -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