本文整理汇总了Python中twisted.words.protocols.irc.IRCClient.msg方法的典型用法代码示例。如果您正苦于以下问题:Python IRCClient.msg方法的具体用法?Python IRCClient.msg怎么用?Python IRCClient.msg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.words.protocols.irc.IRCClient
的用法示例。
在下文中一共展示了IRCClient.msg方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: msg
# 需要导入模块: from twisted.words.protocols.irc import IRCClient [as 别名]
# 或者: from twisted.words.protocols.irc.IRCClient import msg [as 别名]
def msg(self, user, message, length=None):
"""
Send a message to a channel, enforces message encoding
"""
encoded_message = unicode(message).encode("ascii", "ignore")
log.msg("Sending %r to %r" % (encoded_message, user))
IRCClient.msg(self, user, encoded_message, length)
示例2: msg
# 需要导入模块: from twisted.words.protocols.irc import IRCClient [as 别名]
# 或者: from twisted.words.protocols.irc.IRCClient import msg [as 别名]
def msg(self, user, message, length=None):
"""
Send a message to a user or channel.
The message will be split into multiple commands to the server if:
- The message contains any newline characters
- Any span between newline characters is longer than the given
line-length.
@type user: Destination, Hostmask or str
@param user: The user or channel to send a notice to.
@type message: str
@param message: The contents of the notice to send.
@type length: int
@param length: Maximum number of octets to send in a single command, including the IRC protocol framing.
If None is given then IRCClient._safeMaximumLineLength is used to determine a value.
"""
if isinstance(user, Destination):
self._log.debug('Implicitly converting Destination to raw format for message delivery: %s --> %s',
repr(user), user.raw)
user = user.raw
if isinstance(user, Hostmask):
self._log.debug('Implicitly converting Hostmask to nick format for message delivery: %s --> %s',
repr(user), user.nick)
user = user.nick
self._log.debug('Delivering message to %s : %s', user, (message[:35] + '..') if len(message) > 35 else message)
IRCClient.msg(self, user, message.encode('utf-8'), length)
示例3: msg
# 需要导入模块: from twisted.words.protocols.irc import IRCClient [as 别名]
# 或者: from twisted.words.protocols.irc.IRCClient import msg [as 别名]
def msg(self, channel, message, log, length=None):
""" Sends ``message`` to ``channel``.
Depending on ``log``, the message will be logged or not.
Do not use this method from plugins, use :meth:`lala.util.msg` instead."""
if log:
self.factory.logger.info("%s: %s" % (self.nickname, message))
message = message.rstrip().encode("utf-8")
IRCClient.msg(self, channel, message, length)
示例4: signedOn
# 需要导入模块: from twisted.words.protocols.irc import IRCClient [as 别名]
# 或者: from twisted.words.protocols.irc.IRCClient import msg [as 别名]
def signedOn(self):
password = yield self.config.get("pass")
if password:
IRCClient.msg(self, "NickServ","IDENTIFY {}".format(password.encode("utf8")))
self.factory.resetDelay()
self.factory.connection = self
self.nick_check = LoopingCall(self.nickCheck)
self.nick_check.start(60)
self.channels = {}
channels = yield self.master.modules["db"].channelList()
for c, p in channels.items():
self.join(u"{} {}".format(c, p) if p else c, True)
示例5: msg
# 需要导入模块: from twisted.words.protocols.irc import IRCClient [as 别名]
# 或者: from twisted.words.protocols.irc.IRCClient import msg [as 别名]
def msg(self, user, message, length=None):
"""
Send a message to a channel, enforces message encoding
"""
encoded_message = unicode(message).encode('ascii', 'ignore')
if user.startswith('#') and not Channel(self, user).is_active():
log.msg(
"ERROR: Trying to send message to inactive channel %s. "
"Message blocked!" % user
)
else:
log.msg("Sending %r to %r" % (encoded_message, user))
IRCClient.msg(self, user, encoded_message, length)
示例6: _msg
# 需要导入模块: from twisted.words.protocols.irc import IRCClient [as 别名]
# 或者: from twisted.words.protocols.irc.IRCClient import msg [as 别名]
def _msg(self, target, msg, talk=False):
msg_utf = msg.decode('utf-8')
skip = False
if not talk and self.re_tweets.search(msg) and target in self.filters:
low_msg_utf = msg_utf.lower()
for keyword in self.filters[target]:
if keyword and ("%s" % keyword in low_msg_utf or (keyword.startswith('@') and low_msg_utf.startswith(keyword[1:]+': '))):
skip = True
reason = keyword
break
if not talk and target in self.silent and self.silent[target] > datetime.today():
skip = True
reason = "fuckoff until %s" % self.silent[target]
self.log(msg_utf, self.nickname, target, filtered=skip)
if not skip:
IRCClient.msg(self, target, msg, 450)
elif config.DEBUG:
try:
loggvar("FILTERED: %s [%s]" % (str(msg), reason), target)
except:
print colr("ERROR encoding filtered msg", 'red'), msg, reason
loggvar("FILTERED: %s [%s]" % (msg, reason), target)
示例7: msg
# 需要导入模块: from twisted.words.protocols.irc import IRCClient [as 别名]
# 或者: from twisted.words.protocols.irc.IRCClient import msg [as 别名]
def msg(self, target, message):
log.msg('<%(nickname)s> %(message)s' %
dict(nickname=self.nickname, message=message))
IRCClient.msg(self, target, message)
示例8: msg
# 需要导入模块: from twisted.words.protocols.irc import IRCClient [as 别名]
# 或者: from twisted.words.protocols.irc.IRCClient import msg [as 别名]
def msg(self, channel, msg, length=None):
"""Log messages sent by the client"""
log.msg('<%(nickname)s> %(message)s' %
dict(nickname=self.nickname, message=msg))
IRCClient.msg(self, channel, msg.encode("utf-8"), length)
示例9: msg
# 需要导入模块: from twisted.words.protocols.irc import IRCClient [as 别名]
# 或者: from twisted.words.protocols.irc.IRCClient import msg [as 别名]
def msg(self, channel, message):
IRCClient.msg(self, channel.encode("utf8"), message.encode("utf8"))
nick = normalize(self.nickname)
self.dispatch("sent_message", channel, nick, message)
示例10: msg
# 需要导入模块: from twisted.words.protocols.irc import IRCClient [as 别名]
# 或者: from twisted.words.protocols.irc.IRCClient import msg [as 别名]
def msg(self, channel, message):
IRCClient.msg(self, channel.encode("utf8"), message.encode("utf8")) # _reallySendLine handles this for us
nick = normalize(self.nickname)
self.dispatch("sent_message", channel, nick, message)
示例11: msg
# 需要导入模块: from twisted.words.protocols.irc import IRCClient [as 别名]
# 或者: from twisted.words.protocols.irc.IRCClient import msg [as 别名]
def msg(self, destination, message, length=400):
"""IRCClient.msg re-implementation to split messages in 400bytes parts by default."""
IRCClient.msg(self, destination, message, length)
示例12: msg
# 需要导入模块: from twisted.words.protocols.irc import IRCClient [as 别名]
# 或者: from twisted.words.protocols.irc.IRCClient import msg [as 别名]
def msg(self, user, message, length=None):
''' Send message to user '''
IRCClient.msg(self, user, message, length)
echo('[IRC] You->%s: %s' % (user, message))
示例13: say
# 需要导入模块: from twisted.words.protocols.irc import IRCClient [as 别名]
# 或者: from twisted.words.protocols.irc.IRCClient import msg [as 别名]
def say(self, channel, message, length=None):
''' Say to channel and echo back '''
IRCClient.msg(self, channel, message, length)
echo('[%s] <%s> %s' % (channel, self.nickname, message))
示例14: msg
# 需要导入模块: from twisted.words.protocols.irc import IRCClient [as 别名]
# 或者: from twisted.words.protocols.irc.IRCClient import msg [as 别名]
def msg(self, user, msg, length=None):
msg = msg.encode("utf-8")
if length:
IRCClient.msg(self, user, msg, length)
else:
IRCClient.msg(self, user, msg)
示例15: msg
# 需要导入模块: from twisted.words.protocols.irc import IRCClient [as 别名]
# 或者: from twisted.words.protocols.irc.IRCClient import msg [as 别名]
def msg(self, to, msg):
print('-> {0}'.format((to, msg)))
IRCClient.msg(self, to, msg)