From 958d1c934e554405fbd5cf985c8a0104cf646480 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Tue, 25 Mar 2003 08:38:14 +0000 Subject: [PATCH] Added kernel command --- plugins/ThreadedFunCommands.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/plugins/ThreadedFunCommands.py b/plugins/ThreadedFunCommands.py index 85d862fd8..01b3b5592 100644 --- a/plugins/ThreadedFunCommands.py +++ b/plugins/ThreadedFunCommands.py @@ -34,11 +34,13 @@ Provides fun/useless commands that require threads. Commands include: dns + kernel """ from baseplugin import * import socket +import telnetlib import ircutils import privmsgs @@ -47,7 +49,7 @@ import callbacks class ThreadedFunCommands(callbacks.Privmsg): threaded = True def dns(self, irc, msg, args): - "" + """""" host = privmsgs.getArgs(args) if ircutils.isIP(host): hostname = socket.getfqdn(host) @@ -62,6 +64,19 @@ class ThreadedFunCommands(callbacks.Privmsg): except socket.error: irc.error(msg, 'Host not found.') - + def kernel(self, irc, msg, args): + """takes no arguments""" + conn = telnetlib.Telnet('kernel.org', 79) + conn.write('\n') + text = connection.read_all() + for line in text.splitlines(): + (name, version) = line.split(':') + if name.find('latest stable') != -1: + stable = version.strip() + elif name.find('latest beta') != -1: + beta = version.strip() + irc.reply(msg, 'The latest stable kernel is %s; ' \ + 'the latest beta kernel is %s.' % (stable, beta)) + Class = ThreadedFunCommands # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: