ignores.py 文件源码

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

项目:Python-IRC-Bot 作者: wolfy1339 项目源码 文件源码
def add_ignore(irc, event, args):
    host = args[0]
    base_message = "Ignoring %s for %s seconds"
    indefinite = "Ignoring %s indefinately"
    if len(args) > 1:
        if args[1] == 'random':
            duration = random.randrange(100, 10000)
            expires = duration + int(time.time())
        else:
            duration = int(args[1])
            expires = duration + int(time.time())
    else:
        expires = None
    channel = args[2] if len(args) > 2 else None

    if channel is not None:
        try:
            i = config.ignores['channels'][channel]
        except KeyError:
            i = config.ignores['channels'][channel] = []
        i.append([host, expires])
    else:
        i = config.ignores['global']
        i.append([host, expires])
    if expires is not None:
        if channel is not None:
            logging.info(base_message + " in %s", host, duration, channel)
        else:
            logging.info(base_message, host, duration)
    else:
        if channel is not None:
            logging.info(indefinite + " in %s", host, channel)
        else:
            logging.info(indefinite, host)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号