3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-01 01:09:22 +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.')
_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):
irc.start_ts = ts = int(time.time())
irc.uidgen = {}

View File

@ -40,8 +40,10 @@ class TS6UIDGenerator():
return uid
def msg(irc, target, text, notice=False):
command = 'NOTICE' if notice else 'PRIVMSG'
irc.proto._sendFromUser(irc, irc.pseudoclient.uid, '%s %s :%s' % (command, target, text))
if notice:
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):
if name is None: