lastseen.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:pinhook-tilde 作者: archangelic 项目源码 文件源码
def last_seen(msg):
    entries = []
    with open('/home/archangelic/irc/log', 'rb') as f:
        lines = f.readlines()
    for line in lines:
        try:
            l = line.split(b'\t')
            d = l[0]
            u = l[1]
            if u.decode() == msg.arg[:9]:
                entries.append(float(d))
        except:
            continue
    if entries:
        entries.sort()
        last_entry = entries[-1]
        if msg.arg in msg.nick_list:
            leader = '{} is currently online and in the channel!'.format(msg.arg)
        else:
            leader = msg.arg
        out = '{} last spoke in chat on {}'.format(leader, datetime.fromtimestamp(last_entry))
    else:
        out = 'Sorry, {} was not found'.format(msg.arg)
    return pinhook.plugin.message(out)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号