3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-27 21:19:31 +01:00

move messaging functions to protocol (#35)

Closes #36.
This commit is contained in:
James Lu 2015-07-09 16:23:20 -07:00
parent e7922be9fb
commit c8f12f2ab1
2 changed files with 20 additions and 2 deletions

View File

@ -153,6 +153,22 @@ def modeServer(irc, numeric, target, modes):
raise LookupError('No such PyLink PseudoClient exists.') raise LookupError('No such PyLink PseudoClient exists.')
_sendModes(irc, numeric, target, modes) _sendModes(irc, numeric, target, modes)
def messageClient(irc, numeric, target, text):
"""<irc object> <client numeric> <text>
Sends PRIVMSG <text> from PyLink client <client numeric>."""
if not utils.isInternalClient(irc, numeric):
raise LookupError('No such PyLink PseudoClient exists.')
_sendFromUser(irc, numeric, 'PRIVMSG %s :%s' % (target, text))
def noticeClient(irc, numeric, target, text):
"""<irc object> <client numeric> <text>
Sends NOTICE <text> from PyLink client <client numeric>."""
if not utils.isInternalClient(irc, numeric):
raise LookupError('No such PyLink PseudoClient exists.')
_sendFromUser(irc, numeric, 'NOTICE %s :%s' % (target, text))
def connect(irc): def connect(irc):
irc.start_ts = ts = int(time.time()) irc.start_ts = ts = int(time.time())
irc.uidgen = {} irc.uidgen = {}

View File

@ -40,8 +40,10 @@ class TS6UIDGenerator():
return uid return uid
def msg(irc, target, text, notice=False): def msg(irc, target, text, notice=False):
command = 'NOTICE' if notice else 'PRIVMSG' if notice:
irc.proto._sendFromUser(irc, irc.pseudoclient.uid, '%s %s :%s' % (command, target, text)) irc.proto.noticeClient(irc, irc.pseudoclient.uid, target, text)
else:
irc.proto.messageClient(irc, irc.pseudoclient.uid, target, text)
def add_cmd(func, name=None): def add_cmd(func, name=None):
if name is None: if name is None: