• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python user.get_hostmask函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中util.user.get_hostmask函数的典型用法代码示例。如果您正苦于以下问题:Python get_hostmask函数的具体用法?Python get_hostmask怎么用?Python get_hostmask使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_hostmask函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: autoop

def autoop(inp, notice=None, bot=None, chan=None, db=None):
    """aop [channel] <enable|disable> OR <add|del> <nick|host> -- Add/Del Autoops."""
    inp,chan = get_chan(inp,chan)
    autoops = database.get(db,'channels','autoops','chan',chan)
    
    channel = chan.lower()
    command = inp.split()[0]
    if 'enable' in command:
        database.set(db,'channels','autoop',True,'chan',chan)
        notice(u"[{}]: Autoops is now enabled.".format(chan))
    elif 'disable' in command:
        database.set(db,'channels','autoop',False,'chan',chan)
        notice(u"[{}]: Autoops is now disabled.".format(chan))
    elif 'add' in command:
        nicks = inp.split()[1:]
        for nick in nicks:  
            nick = user.get_hostmask(nick,db)
            if autoops and nick in autoops:
                notice(u"[{}]: {} is already an autoop.".format(chan,nick))
            else:
                autoops = '{} {}'.format(nick,autoops).replace('False','').strip()
                database.set(db,'channels','autoops',autoops,'chan',chan)
                notice(u"[{}]: {} is now an auto op.".format(chan,nick))
    elif 'del' in command:
        nicks = inp.split()[1:]
        for nick in nicks:  
            nick = user.get_hostmask(nick,db)
            if autoops and nick in autoops:
                autoops = " ".join(autoops.replace(nick,'').strip().split())
                database.set(db,'channels','autoops',autoops,'chan',chan)
                notice(u"[{}]: {} is no longer an auto op.".format(chan,nick))
            else:
                notice(u"[{}]: {} is not an auto op.".format(chan,nick))
    return
开发者ID:edwinfinch,项目名称:uguubot,代码行数:34,代码来源:core_admin_channel.py


示例2: admin

def admin(inp, notice=None, bot=None, chan=None, db=None):
    """admin [channel] <add|del> <nick|host> -- Makes the user an admin."""
    admins = database.get(db, "channels", "admins", "chan", chan)

    channel = chan.lower()
    command = inp.split()[0]
    nicks = inp.split()[1:]

    if "add" in command:
        for nick in nicks:
            nick = user.get_hostmask(nick, db)
            if admins and nick in admins:
                notice(u"[{}]: {} is already an admin.".format(chan, nick))
            else:
                admins = "{} {}".format(nick, admins).replace("False", "").strip()
                database.set(db, "channels", "admins", admins, "chan", chan)
                notice(u"[{}]: {} is now an admin.".format(chan, nick))
    elif "del" in command:
        if "*" in nicks:
            database.set(db, "channels", "admins", "", "chan", chan)
            notice(u"[{}]: All admins have been removed.".format(chan))
        else:
            for nick in nicks:
                nick = user.get_hostmask(nick, db)
                if admins and nick in admins:
                    admins = " ".join(admins.replace(nick, "").strip().split())
                    database.set(db, "channels", "admins", admins, "chan", chan)
                    notice(u"[{}]: {} is no longer an admin.".format(chan, nick))
                else:
                    notice(u"[{}]: {} is not an admin.".format(chan, nick))
    return
开发者ID:akilegaspi,项目名称:uguubot,代码行数:31,代码来源:core_admin_channel.py


示例3: admin

def admin(inp, notice=None, bot=None, chan=None, db=None):
    """admin [channel] <add|del> <nick|host> -- Makes the user an admin."""
    inp,chan = get_chan(inp,chan)
    admins = database.get(db,'channels','admins','chan',chan)
    
    channel = chan.lower()
    command = inp.split()[0]
    nicks = inp.split()[1:]

    if 'add' in command:
        for nick in nicks:  
            nick = user.get_hostmask(nick,db)
            if admins and nick in admins:
                notice(u"[{}]: {} is already an admin.".format(chan,nick))
            else:
                admins = '{} {}'.format(nick,admins).replace('False','').strip()
                database.set(db,'channels','admins',admins,'chan',chan)
                notice(u"[{}]: {} is now an admin.".format(chan,nick))
    elif 'del' in command:
        for nick in nicks:  
            nick = user.get_hostmask(nick,db)
            if admins and nick in admins:
                admins = " ".join(admins.replace(nick,'').strip().split())
                database.set(db,'channels','admins',admins,'chan',chan)
                notice(u"[{}]: {} is no longer an admin.".format(chan,nick))
            else:
                notice(u"[{}]: {} is not an admin.".format(chan,nick))
    return
开发者ID:edwinfinch,项目名称:uguubot,代码行数:28,代码来源:core_admin_channel.py


示例4: gadmin

def gadmin(inp, notice=None, bot=None, config=None, db=None):
    "gadmin <add|del> <nick|host> -- Make <nick|host> an global admin." \
    "(you can delete multiple admins at once)"
    inp = inp.lower()
    command = inp.split()[0]
    targets = inp.split()[1:]

    if 'add' in command:
        for target in targets:
            target = user.get_hostmask(target,db)
            if target in bot.config["admins"]:
                notice(u"%s is already a global admin." % target)
            else:
                notice(u"%s is now a global admin." % target)
                bot.config["admins"].append(target)
                bot.config["admins"].sort()
                json.dump(bot.config, open('config', 'w'), sort_keys=True, indent=2)
        return
    elif 'del' in command:
        for target in targets:
            target = user.get_hostmask(target, db)
            if target in bot.config["admins"]:
                notice(u"%s is no longer a global admin." % target)
                bot.config["admins"].remove(target)
                bot.config["admins"].sort()
                json.dump(bot.config, open('config', 'w'), sort_keys=True, indent=2)
            else:
                notice(u"%s is not a global admin." % target)
        return
开发者ID:inexist3nce,项目名称:Taigabot,代码行数:29,代码来源:core_admin_global.py


示例5: autoop

def autoop(inp, notice=None, bot=None, chan=None, db=None):
    """aop [channel] <enable|disable> OR <add|del> <nick|host> -- Add/Del Autoops."""
    autoops = database.get(db, "channels", "autoops", "chan", chan)

    channel = chan.lower()
    command = inp.split()[0]
    if "enable" in command:
        database.set(db, "channels", "autoop", True, "chan", chan)
        notice(u"[{}]: Autoops is now enabled.".format(chan))
    elif "disable" in command:
        database.set(db, "channels", "autoop", False, "chan", chan)
        notice(u"[{}]: Autoops is now disabled.".format(chan))
    elif "add" in command:
        nicks = inp.split()[1:]
        for nick in nicks:
            nick = user.get_hostmask(nick, db)
            if autoops and nick in autoops:
                notice(u"[{}]: {} is already an autoop.".format(chan, nick))
            else:
                autoops = "{} {}".format(nick, autoops).replace("False", "").strip()
                database.set(db, "channels", "autoops", autoops, "chan", chan)
                notice(u"[{}]: {} is now an auto op.".format(chan, nick))
    elif "del" in command:
        nicks = inp.split()[1:]
        for nick in nicks:
            nick = user.get_hostmask(nick, db)
            if autoops and nick in autoops:
                autoops = " ".join(autoops.replace(nick, "").strip().split())
                database.set(db, "channels", "autoops", autoops, "chan", chan)
                notice(u"[{}]: {} is no longer an auto op.".format(chan, nick))
            else:
                notice(u"[{}]: {} is not an auto op.".format(chan, nick))
    return
开发者ID:akilegaspi,项目名称:uguubot,代码行数:33,代码来源:core_admin_channel.py


示例6: ban

def ban(inp, conn=None, chan=None, notice=None, db=None, nick=None):
    """ban [channel] <user> [reason] [timer] -- Makes the bot ban <user> in [channel].
    If [channel] is blank the bot will ban <user> in
    the channel the command was used in."""
    mode = "+b"
    reason = "#rekt"
    inp,chan = get_chan(inp,chan)
    split = inp.split(" ")
    inp_nick = split[0]

    if conn.nick in inp_nick or 'infinity' in inp_nick: 
        target = nick
        reason = "Youre silly onii-chan."
        conn.send(u"KICK {} {} :{}".format(chan, target, reason))
        return

    if len(split) > 1: reason = " ".join(split[1:])
    target = user.get_hostmask(inp_nick,db)
    if '@' in target and not '!' in target: target = '*!*{}'.format(target)
    timer = scheduler.check_for_timers(inp)
    if timer > 0: reason = "{} Come back in {} seconds!!!".format(reason,timer)
    notice(u"Attempting to ban {} in {}...".format(nick, chan))
    conn.send(u"MODE {} {} {}".format(chan, mode, target))
    conn.send(u"KICK {} {} :{}".format(chan, inp_nick, reason))

    if timer > 0: 
        notice(u"{} will be unbanned in {} seconds".format(target, timer))
        scheduler.schedule(timer, 1, "MODE {} -b {}".format(chan, target), conn)
        #scheduler.schedule(timer, 2, "PRIVMSG ChanServ :unban {} {}".format(channel, nick), conn)
    else:
        banlist = database.get(db,'channels','bans','chan',chan)
        banlist = '{} {}'.format(target,banlist).replace('False','').strip()
        database.set(db,'channels','bans',banlist,'chan',chan)
    return
开发者ID:edwinfinch,项目名称:uguubot,代码行数:34,代码来源:core_admin_channel.py


示例7: ignore

def ignore(inp, notice=None, bot=None, chan=None, db=None):
    """ignore [channel] <nick|host> -- Makes the bot ignore <nick|host>."""
    ignorelist = database.get(db, 'channels', 'ignored', 'chan', chan)
    targets = inp.split()
    for target in targets:
        target = user.get_hostmask(target, db)
        if (user.is_admin(target, chan, db, bot)):
            notice(
                u"[{}]: {} is an admin and cannot be ignored.".format(
                    chan, inp))
        else:
            if ignorelist and target in ignorelist:
                notice(u"[{}]: {} is already ignored.".format(chan, target))
            else:
                ignorelist = '{} {}'.format(target, ignorelist)
                database.set(
                    db,
                    'channels',
                    'ignored',
                    ignorelist,
                    'chan',
                    chan)

                notice(u"[{}]: {} has been ignored.".format(chan, target))
    return
开发者ID:Anonymike,项目名称:pasta-bot,代码行数:25,代码来源:core_admin_channel.py


示例8: process_vote

def process_vote(target,action,chan,mask,db,notice,conn):
    if ' ' in target: 
        notice('Invalid nick')
        return

    try: votes2kick = database.get(db,'channels','votekick','chan',chan)
    except: votes2kick = 10
    try: votes2ban = database.get(db,'channels','voteban','chan',chan)
    except: votes2ban = 10

    if len(target) is 0:
        if action is 'kick': notice('Votes required to kick: {}'.format(votes2kick))
        elif action is 'ban': notice('Votes required to ban: {}'.format(votes2ban))
        return

    votefinished = False
    global db_ready
    if not db_ready: db_init(db)
    chan = chan.lower()
    target = target.lower()
    voter = user.format_hostmask(mask)
    oters = db.execute("SELECT voters FROM votes where chan='{}' and action='{}' and target like '{}'".format(chan,action,target)).fetchone()

    if conn.nick.lower() in target: return "I dont think so Tim."

    if voters: 
        voters = voters[0]
        if voter in voters: 
            notice("You have already voted.")
            return
        else:
            voters = '{} {}'.format(voters,voter).strip()
            notice("Thank you for your vote!")
    else: 
        voters = voter

    votecount = len(voters.split(' '))

    if 'kick' in action: 
        votemax = int(votes2kick)
        if votecount >= votemax:
            votefinished = True
            conn.send("KICK {} {} :{}".format(chan, target, "You have been voted off the island."))
    if 'ban' in action:
        votemax = int(votes2ban)
        if votecount >= votemax:
            votefinished = True
            conn.send("MODE {} +b {}".format(chan, user.get_hostmask(target,db)))
            conn.send("KICK {} {} :".format(chan, target, "You have been voted off the island."))
    
    if votefinished: db.execute("DELETE FROM votes where chan='{}' and action='{}' and target like '{}'".format(chan,action,target))
    else: db.execute("insert or replace into votes(chan, action, target, voters, time) values(?,?,?,?,?)", (chan, action, target, voters, time.time()))
        
    db.commit()
    return ("Votes to {} {}: {}/{}".format(action, target, votecount,votemax))
开发者ID:Anonymike,项目名称:pasta-bot,代码行数:55,代码来源:vote.py


示例9: match

def match(inp,nick=None,chan=None,bot=None,input=None,db=None):
    if inp: mask = user.get_hostmask(inp,db)
    else: mask = input.mask
    # hostmask = format_hostmask(mask)

    channeladmin = user.is_channeladmin(mask, chan, db)
    globaladmin = user.is_globaladmin(mask, chan, bot)
    if channeladmin and globaladmin: return "Global & Local Admin: ({})".format(mask)
    elif channeladmin: return "Local Admin: {}".format(mask)
    elif globaladmin: return "Global Admin: {}".format(mask)
        
    return '{}: is not an admin'.format(mask)
开发者ID:geniusempire,项目名称:uguubot,代码行数:12,代码来源:core_admin_channel.py


示例10: unignore

def unignore(inp, notice=None, bot=None, chan=None, db=None):
    """unignore [channel] <nick|host> -- Makes the bot listen to <nick|host>."""
    ignorelist = database.get(db,'channels','ignored','chan',chan)
    targets = inp.split()
    for target in targets:  
        target = user.get_hostmask(target,db)
        if ignorelist  and target in ignorelist:
            ignorelist = " ".join(ignorelist.replace(target,'').strip().split())
            database.set(db,'channels','ignored',ignorelist,'chan',chan)
            notice(u"[{}]: {} has been unignored.".format(chan,target))
        else:
            notice(u"[{}]: {} is not ignored.".format(chan,target))
    return
开发者ID:geniusempire,项目名称:uguubot,代码行数:13,代码来源:core_admin_channel.py


示例11: gunignore

def gunignore(inp, notice=None, bot=None, chan=None, db=None):
    """unignore [channel] <nick|host> -- Makes the bot listen to <nick|host>."""
    ignorelist = bot.config["ignored"]
    targets = inp.split()
    for target in targets:  
        target = user.get_hostmask(target,db)
        if ignorelist and target in ignorelist:
            bot.config["ignored"].remove(target)
            bot.config["ignored"].sort()
            json.dump(bot.config, open('config', 'w'), sort_keys=True, indent=2)
            notice("[Global]: {} has been unignored.".format(target))
        else:
            notice("[Global]: {} is not ignored.".format(target))
    return
开发者ID:bytebit-ch,项目名称:uguubot,代码行数:14,代码来源:core_admin_global.py


示例12: ban

def ban(inp, conn=None, chan=None, notice=None, db=None, nick=None, bot=None):
    '''
    ban [channel] <user> [reason] [timer]
    Makes the bot ban <user> in [channel].
    If [channel] is blank the bot will ban <user> in
    the channel the command was used in.
    '''

    mode = "+b"
    reason = "#rekt"
    # inp,chan = get_chan(inp,chan)
    split = inp.split(" ")
    inp_nick = split[0]

    if conn.nick in inp_nick or bot.config['owner'] == inp_nick:
        target = nick
        reason = "Your attitude is not conducive to the desired environment"
        conn.send(u"KICK {} {} :{}".format(chan, target, reason))
        return

    if len(split) > 1:
        reason = " ".join(split[1:])

    if '@' not in inp_nick:
        target = user.get_hostmask(inp_nick, db)
    else:
        target = inp_nick

    if '@' in target and '!' not in target:
        target = '*!*{}'.format(target)
    timer = scheduler.check_for_timers(inp)
    if timer > 0:
        reason = "{} Come back in {} seconds!!!".format(reason, timer)
    notice(u"Attempting to ban {} in {}...".format(target, chan))
    conn.send(u"MODE {} {} {}".format(chan, mode, target))
    conn.send(u"KICK {} {} :{}".format(chan, inp_nick, reason))

    if timer > 0:
        notice(u"{} will be unbanned in {} seconds".format(target, timer))
        scheduler.schedule(
            timer, 1, "MODE {} -b {}".format(chan, target), conn)
        # scheduler.schedule(timer, 2,
        #                    "PRIVMSG ChanServ :unban {} {}".format(channel,
        #                                                           nick),
        #                     conn)
    else:
        banlist = database.get(db, 'channels', 'bans', 'chan', chan)
        banlist = '{} {}'.format(target, banlist).replace('False', '').strip()
        database.set(db, 'channels', 'bans', banlist, 'chan', chan)
    return
开发者ID:Anonymike,项目名称:pasta-bot,代码行数:50,代码来源:core_admin_channel.py


示例13: unban

def unban(inp, conn=None, chan=None, notice=None, db=None):
    """unban [channel] <user> -- Makes the bot unban <user> in [channel].
    If [channel] is blank the bot will unban <user> in
    the channel the command was used in."""
    #mode_cmd("-b", "unban", inp, chan, conn, notice)
    inp,chan = get_chan(inp,chan)
    split = inp.split(" ")
    nick = split[0]
    target = user.get_hostmask(nick,db)
    if '@' in target and not '!' in target: target = '*!*{}'.format(target)
    notice(u"Attempting to unban {} in {}...".format(nick, chan))
    conn.send(u"MODE {} -b {}".format(chan, target))
    banlist = database.get(db,'channels','bans','chan',chan)
    banlist = " ".join(banlist.replace(target,'').strip().split())
    database.set(db,'channels','bans',banlist,'chan',chan)
    return
开发者ID:edwinfinch,项目名称:uguubot,代码行数:16,代码来源:core_admin_channel.py


示例14: gignore

def gignore(inp, notice=None, bot=None, chan=None, db=None):
    """gignore <nick|host> -- Makes the bot ignore nick|host."""
    ignorelist = bot.config["ignored"]
    targets = inp.split()
    for target in targets:  
        target = user.get_hostmask(target,db)
        if (user.is_globaladmin(target,db,bot)):
            notice("[Global]: {} is an admin and cannot be ignored.".format(inp))
        else:
            if ignorelist and target in ignorelist:
                notice("[Global]: {} is already ignored.".format(target))
            else:
                bot.config["ignored"].append(target)
                bot.config["ignored"].sort()
                json.dump(bot.config, open('config', 'w'), sort_keys=True, indent=2)
                notice("[Global]: {} has been ignored.".format(target))
    return
开发者ID:bytebit-ch,项目名称:uguubot,代码行数:17,代码来源:core_admin_global.py


示例15: rquote

def rquote(inp, db=None, notice=None, nick=None, bot=None, reply=None):
    """rquote <nick> <number/*> - Deletes a quote from a nick"""
    target = inp.split(' ')[0]
    if nick != target:
	if user.is_globaladmin(user.get_hostmask(nick, db), nick, bot):
            pass
        else:
            notice('You can only remove your own quotes.')
            return
    num = inp.split(' ')[1]
    if num == '*':
        tmp = 0
        while True:
	    if 'No quotes found for' in get_quote_by_nick(db, target, tmp):
                return
            reply('Removing: {}'.format(get_quote_by_nick(db, target, tmp).encode('UTF-8')).decode('UTF-8'))
            del_quote(db, target, tmp)
            time.sleep(0.5)
    else:
        notice(del_quote(db, target, num))
开发者ID:inexist3nce,项目名称:Taigabot,代码行数:20,代码来源:quote.py


示例16: fhost

def fhost(inp, nick=None, conn=None, db=None):
    if not inp: inp = nick
    return user.get_hostmask(inp,db)
开发者ID:FrozenPigs,项目名称:uguubot,代码行数:3,代码来源:core_ctcp.py



注:本文中的util.user.get_hostmask函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python util.raiseNotDefined函数代码示例发布时间:2022-05-26
下一篇:
Python tree_node.TreeNode类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap