61 lines
2.0 KiB
Python
61 lines
2.0 KiB
Python
# -*- coding: utf-8 -*-
|
|
import random
|
|
|
|
import irc3
|
|
import feedparser
|
|
from docopt import Dict
|
|
from irc3.plugins.command import command
|
|
from irc3.utils import IrcString
|
|
|
|
from . import Plugin
|
|
from ..utils import re_generator
|
|
|
|
|
|
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|ubuntu|apt|dpkg).*')
|
|
def debillian(self, target: str):
|
|
"""Annoying RE trigger for debian with variable count of E."""
|
|
if random.randint(0, 3) is 0:
|
|
self.bot.privmsg(target, re_generator())
|
|
|
|
@irc3.event(r'(?i)^:\S+ PRIVMSG (?P<target>\S+) :.*(?<!gnu[/+])linux(?! kernel).*')
|
|
def linux(self, target: str):
|
|
"""Super annoying, useless 'Stallman is mad' trigger."""
|
|
if random.randint(0, 12) is 0:
|
|
self.bot.privmsg(target, GNU_LINUX)
|
|
|
|
@command
|
|
def kernel(self, mask: IrcString, target: IrcString, args: Dict):
|
|
"""Get Linux kernel releases.
|
|
|
|
%%kernel
|
|
"""
|
|
feed = feedparser.parse(self.KERNEL_FEED)
|
|
|
|
# Cancel if no feed or entries
|
|
if not feed or not feed.get('entries'):
|
|
self.log.error('Error fetching kernel.org releases feed')
|
|
return
|
|
|
|
# Make list of releases
|
|
releases = []
|
|
for e in feed['entries']:
|
|
version, branch = e['title'].split(': ')
|
|
|
|
if '(EOL)' in e['description']:
|
|
branch = '{}, \x1DEOL\x1D'.format(branch)
|
|
|
|
releases.append('\x02{}\x02 ({})'.format(version, branch))
|
|
|
|
return '\x02[Kernel]\x02 {}'.format(', '.join(releases))
|