2017-05-28 11:27:28 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2017-05-29 21:32:45 +00:00
|
|
|
import random
|
|
|
|
|
|
|
|
import irc3
|
2022-11-08 00:25:05 +00:00
|
|
|
import requests
|
2017-08-22 13:57:57 +00:00
|
|
|
from docopt import Dict
|
2017-05-28 11:27:28 +00:00
|
|
|
from irc3.plugins.command import command
|
|
|
|
from irc3.utils import IrcString
|
|
|
|
|
|
|
|
from . import Plugin
|
2017-08-22 15:43:48 +00:00
|
|
|
from .utils import re_generator
|
2017-05-28 11:27:28 +00:00
|
|
|
|
2017-05-29 21:32:45 +00:00
|
|
|
GNU_LINUX = """I'd Just Like To Interject For A Moment. What you're referring
|
2021-12-06 20:07:29 +00:00
|
|
|
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."""
|
2017-05-29 21:32:45 +00:00
|
|
|
|
2017-05-28 11:27:28 +00:00
|
|
|
|
2017-05-30 11:51:45 +00:00
|
|
|
class Linux(Plugin):
|
2022-11-08 00:25:05 +00:00
|
|
|
KERNEL_FEED = 'https://www.kernel.org/releases.json'
|
2017-05-28 11:27:28 +00:00
|
|
|
|
2019-09-19 19:24:06 +00:00
|
|
|
@irc3.event(r'(?i)^:\S+ PRIVMSG (?P<target>\S+) :(?:.* )?(debian|ubuntu|apt|dpkg|flash)(?: .*|$)')
|
2017-06-29 20:56:32 +00:00
|
|
|
def debillian(self, target: str):
|
2017-07-04 13:22:20 +00:00
|
|
|
"""Annoying RE trigger for debian with variable count of E."""
|
2022-11-07 20:20:11 +00:00
|
|
|
if random.randint(0, 3) == 0:
|
2017-07-07 00:11:20 +00:00
|
|
|
self.bot.privmsg(target, re_generator())
|
2017-06-01 15:38:34 +00:00
|
|
|
|
2017-07-07 00:11:20 +00:00
|
|
|
@irc3.event(r'(?i)^:\S+ PRIVMSG (?P<target>\S+) :.*(?<!gnu[/+])linux(?! kernel).*')
|
2017-06-29 20:56:32 +00:00
|
|
|
def linux(self, target: str):
|
2017-07-04 13:22:20 +00:00
|
|
|
"""Super annoying, useless 'Stallman is mad' trigger."""
|
2022-11-07 20:20:11 +00:00
|
|
|
if random.randint(0, 12) == 0:
|
2017-06-29 20:56:32 +00:00
|
|
|
self.bot.privmsg(target, GNU_LINUX)
|
2017-05-29 21:32:45 +00:00
|
|
|
|
2017-05-28 11:27:28 +00:00
|
|
|
@command
|
2017-08-22 13:57:57 +00:00
|
|
|
def kernel(self, mask: IrcString, target: IrcString, args: Dict):
|
2017-08-22 14:15:52 +00:00
|
|
|
"""Get Linux kernel releases
|
2017-05-28 11:27:28 +00:00
|
|
|
|
|
|
|
%%kernel
|
|
|
|
"""
|
2022-11-08 00:25:05 +00:00
|
|
|
try:
|
|
|
|
res = requests.get(self.KERNEL_FEED, timeout=10).json()
|
|
|
|
except requests.exceptions.RequestException:
|
|
|
|
return '\x02[Kernel]\x02 Error fetching kernel.org releases'
|
2023-07-21 11:47:54 +00:00
|
|
|
except requests.exceptions.JSONDecodeError:
|
|
|
|
return '\x02[Kernel]\x02 Error decoding kernel.org releases'
|
2017-07-04 13:22:20 +00:00
|
|
|
|
|
|
|
# Make list of releases
|
2017-05-28 11:27:28 +00:00
|
|
|
releases = []
|
2022-11-08 00:25:05 +00:00
|
|
|
for release in res['releases']:
|
|
|
|
releases.append('\x02{}\x02 ({}{})'.format(release['version'], release['moniker'],
|
|
|
|
', \x1DEOL\x1D' if release['iseol'] else ''))
|
2017-07-04 13:22:20 +00:00
|
|
|
|
2017-08-22 13:52:49 +00:00
|
|
|
return '\x02[Kernel]\x02 {}'.format(', '.join(releases))
|