3
0
mirror of https://github.com/jlu5/PyLink.git synced 2025-02-17 14:01:03 +01:00

Implement /TIME support (#228)

This commit is contained in:
James Lu 2016-08-12 19:19:09 -07:00
parent a76bd8c5b2
commit 94aee8f05c
2 changed files with 12 additions and 0 deletions

View File

@ -1,9 +1,11 @@
""" """
handlers.py - Implements miscellaneous IRC command handlers (WHOIS, services login, etc.) handlers.py - Implements miscellaneous IRC command handlers (WHOIS, services login, etc.)
""" """
import time
from pylinkirc import utils, conf from pylinkirc import utils, conf
from pylinkirc.log import log from pylinkirc.log import log
def handle_whois(irc, source, command, args): def handle_whois(irc, source, command, args):
"""Handle WHOIS queries.""" """Handle WHOIS queries."""
target = args['target'] target = args['target']
@ -146,3 +148,9 @@ def handle_version(irc, source, command, args):
fullversion = irc.version() fullversion = irc.version()
irc.proto.numeric(irc.sid, 351, source, fullversion) irc.proto.numeric(irc.sid, 351, source, fullversion)
utils.add_hook(handle_version, 'VERSION') utils.add_hook(handle_version, 'VERSION')
def handle_time(irc, source, command, args):
"""Handles requests for the PyLink server time."""
timestring = time.ctime()
irc.proto.numeric(irc.sid, 391, source, '%s :%s' % (irc.hostname(), timestring))
utils.add_hook(handle_time, 'TIME')

View File

@ -82,3 +82,7 @@ class IRCS2SProtocol(Protocol):
# <- ABAAB Q :Killed (GL_ (bangbang)) # <- ABAAB Q :Killed (GL_ (bangbang))
self.removeClient(numeric) self.removeClient(numeric)
return {'text': args[0]} return {'text': args[0]}
def handle_time(self, numeric, command, args):
"""Handles incoming /TIME requests."""
return {'target': args[0]}