本文整理汇总了Python中jsb.utils.lazydict.LazyDict.target方法的典型用法代码示例。如果您正苦于以下问题:Python LazyDict.target方法的具体用法?Python LazyDict.target怎么用?Python LazyDict.target使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jsb.utils.lazydict.LazyDict
的用法示例。
在下文中一共展示了LazyDict.target方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: formatevent
# 需要导入模块: from jsb.utils.lazydict import LazyDict [as 别名]
# 或者: from jsb.utils.lazydict.LazyDict import target [as 别名]
def formatevent(bot, ievent, channels, forwarded=False):
m = {
'datetime': datetime.now(),
'separator': format_opt('separator'),
'event_prefix': format_opt('event_prefix'),
'network': bot.cfg.networkname,
'nick': ievent.nick,
'target': stripname(ievent.channel),
'botname': bot.cfg.name,
'txt': ievent.txt,
'type': ievent.cbtype
}
m = LazyDict(m)
if ievent.cmnd == 'PRIVMSG':
if ievent.txt.startswith('\001ACTION'): m.txt = '* %s %s' % (m.nick, ievent.txt[7:-1].strip())
else:
if bot.type == "irc": m.txt = '<%s> %s' % (m.nick, striphtml(ievent.txt))
elif not forwarded: m.txt = '<%s> %s' % (m.nick, bot.normalize(ievent.txt))
else: m.txt = bot.normalize(ievent.txt)
elif ievent.cmnd == 'NOTICE':
m.target = ievent.arguments[0]
m.txt = "-%s- %s"%(ievent.nick, ievent.txt)
elif ievent.cmnd == 'TOPIC': m.txt = '%s changes topic to "%s"'%(ievent.nick, ievent.txt)
elif ievent.cmnd == 'MODE':
margs = ' '.join(ievent.arguments[1:])
m.txt = '%s sets mode: %s'% (ievent.nick, margs)
elif ievent.cmnd == 'JOIN': m.txt = '%s (%s) has joined %s'%(ievent.nick, ievent.userhost, ievent.channel)
elif ievent.cmnd == 'KICK': m.txt = '%s was kicked by %s (%s)'% (ievent.arguments[1], ievent.nick, ievent.txt)
elif ievent.cmnd == 'PART': m.txt = '%s (%s) has left %s'% (ievent.nick, ievent.userhost, ievent.channel)
elif ievent.cmnd in ('QUIT', 'NICK'):
if not ievent.user or not ievent.user.data.channels:
logging.debug("chatlog - can't find joined channels for %s" % ievent.userhost)
return m
cmd = ievent.cmnd
nick = cmd == 'NICK' and ievent.txt or ievent.nick
for c in event.user.channels:
if [bot.cfg.name, c] in channels:
if True:
if cmd == 'NICK': m.txt = '%s (%s) is now known as %s'% (ievent.nick, ievent.userhost, ievent.txt)
else: m.txt= '%s (%s) has quit: %s'% (ievent.nick, ievent.userhost, ievent.txt)
m.type = ievent.cmnd.lower()
m.target = c
elif ievent.cbtype == 'PRESENCE':
if ievent.type == 'unavailable': m.txt = "%s left" % ievent.nick
else: m.txt = "%s joined" % ievent.nick
elif ievent.cbtype == "MESSAGE": m.txt = "<%s> %s" % (m.nick, ievent.txt)
elif ievent.cbtype == "OUTPUT": m.txt = "<%s> %s" % (bot.cfg.nick, ievent.txt)
return m