nxy/nxy/plugins/linux.py
2017-06-29 22:56:32 +02:00

52 lines
1.8 KiB
Python

# -*- coding: utf-8 -*-
import random
import irc3
import feedparser
from docopt import Dict as DocOptDict
from irc3.plugins.command import command
from irc3.utils import IrcString
from . import Plugin
GNU_LINUX = """I'd Just Like To Interject For A Moment. What you're referring
to as Linux, is in fact, GNU/Linux, or as I've recently taken to calling it,
GNU plus Linux. Linux is not an operating system unto itself, but rather
another free component of a fully functioning GNU system made useful by the
GNU corelibs, shell utilities and vital system components comprising a full
OS as defined by POSIX."""
class Linux(Plugin):
KERNEL_FEED = 'https://www.kernel.org/feeds/kdist.xml'
@irc3.event(r'(?i)^:\S+ PRIVMSG (?P<target>\S+) :.*(debian|apt|dpkg).*')
def debillian(self, target: str):
if random.randint(0, 12) is 0:
self.bot.privmsg(target, 'REEEEEEEEEEEEEEEEEEEEEEEEEEEEE')
@irc3.event(r'(?i)^:\S+ PRIVMSG (?P<target>\S+) :'
r'.*(?<!gnu[/+])linux(?! kernel).*')
def linux(self, target: str):
if random.randint(0, 12) is 0:
self.bot.privmsg(target, GNU_LINUX)
@command
def kernel(self, mask: IrcString, target: IrcString, args: DocOptDict):
"""Get Linux kernel releases.
%%kernel
"""
feed = feedparser.parse(self.KERNEL_FEED)
releases = []
for e in feed['entries']:
version, branch = e['title'].split(': ')
if '(EOL)' in e['description']:
branch = '{branch}, \x1DEOL\x1D'.format(branch=branch)
releases.append('\x02{version}\x02 ({branch})'.format(
version=version,
branch=branch,
))
return '[Kernel] {releases}'.format(releases=', '.join(releases))