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

Python magic.sign函数代码示例

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

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



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

示例1: h_general

def h_general(bot, *args, **kwds):
    e, id = kwds['e'], kwds['a'](*args)
    for chan, names in track_channels.iteritems():
        if id and id.nick.lower() not in map(str.lower, names): continue
        eargs = args + (chan,)
        yield sign(e,            bot, *eargs)
        yield sign(e + '_FINAL', bot, *eargs)
开发者ID:joodicator,项目名称:PageBot,代码行数:7,代码来源:channel.py


示例2: privmsg

def privmsg(bot, nick, user, host, target, msg, *args):
    #    msg = re.sub('^:', '', msg) # not needed since xirclib updated
    if target == bot.nick:
        target = None
    id = ID(nick, user, host)
    yield sign("MESSAGE", bot, id, target, msg)
    yield sign(("MESSAGE", target), bot, id, msg)
    match = re.match("(?P<cmd>!\S+)\s*(?P<arg>.*)$", msg)
    if match:
        cmd, arg = match.group("cmd", "arg")
        yield sign(cmd, bot, id, target, arg)
        yield sign((cmd, target), bot, id, arg)
开发者ID:joodicator,项目名称:DungeonBot,代码行数:12,代码来源:message.py


示例3: h_buffer

def h_buffer(work, data):
    if work.terraria_protocol.version_number > 155:
        while len(data) > 2:
            length, type = struct.unpack('<hB', data[:3])
            if len(data) < length: break
            yield sign('MESSAGE', work, type, data[:length][3:])
            data = data[length:]
    else:
        while len(data) > 4:
            length, type = struct.unpack('<iB', data[:5])
            if len(data) < length + 4: break
            yield sign('MESSAGE', work, type, data[4:][1:length])
            data = data[4:][length:]
    work.stack = data
开发者ID:joodicator,项目名称:PageBot,代码行数:14,代码来源:terraria_protocol.py


示例4: h_url

def h_url(bot, id, target, args, full_msg, reply):
    channel = (target or ('%s!%[email protected]%s' % id)).lower()

    if args:
        dice = sys.modules.get('dice')
        match = re.match(r'!r(oll)?\s+(?P<args>.*)', args)
        if match and dice and bot in dice.link.installed_modes:
            args = match.group('args')
            args = dice.roll(bot, id, target, args, error_reply=reply)
            if args is None: return
            reply(args)

        urls = url_collect.extract_urls(args)
        yield sign('URL_CMD_URLS', bot, urls, target, id, full_msg)
    elif url_collect.history[channel]:
        urls = url_collect.history[channel].pop(-1)
    else:
        urls = None

    if not urls:
        reply('No URL found.')
        return

    for url in urls:
        try:
            result = get_title_proxy(url)
            reply(result['title'])

            # Generate a URL-suppressed proxy message for the basic component.
            btitle = result['title_bare']
            p_target = '%s!%[email protected]%s' % id if target is None else target
            if isinstance(btitle, unicode):
                btitle = btitle.encode('utf-8')
            yield later(sign('PROXY_MSG', bot, None, p_target, btitle,
                             no_url=True))

            if result.get('proxy'):
                # Generate a quiet proxy message for the parenthetical component.
                pmsg, fmsg = result['proxy'], result['proxy_full']
                if isinstance(pmsg, unicode): pmsg = pmsg.encode('utf-8')
                if isinstance(fmsg, unicode): fmsg = fmsg.encode('utf-8')
                yield later(sign('PROXY_MSG', bot, None, p_target, pmsg,
                                 full_msg=fmsg, quiet=True, no_url=True))

            yield runtime.sleep(0.01)
        except Exception as e:
            traceback.print_exc()
            url, is_nsfw = url_collect.url_nsfw(url)
            reply('Error: %s [%s%s]' %
                (e, abbrev_url(url), ' \2NSFW\2' if is_nsfw else ''))
开发者ID:joodicator,项目名称:PageBot,代码行数:50,代码来源:url.py


示例5: refresh

    def refresh(self, bot):
        try:
            quotes, title = self.quotes_title()
            url_state = state.get(self.index_url, {})
            chan_state = url_state.get(self.channel.lower(), {})
            last_quote = chan_state.get('last_quote')

            quotes = sorted(
                (qid, quote) for (qid, quote) in quotes if qid > last_quote)
            sample = quotes if len(quotes) <= MAX_REPORT else \
                     quotes[:MAX_REPORT-1]
            for qid, quote in sample:
                quote_url = '%s?%s' % (self.remote_index_url, qid)
                fquote = format_quote(quote)
                msg = '%s: new quote added: %s "%s"' % (title, quote_url, fquote)
                bot.send_msg(self.channel, msg)
                yield later(sign('PROXY_MSG', bot, None, self.channel, fquote,
                                 quiet=True))

            if len(quotes) > len(sample):
                msg = '%s: ...and %d others. See: <%s>.' % (
                    title, len(quotes)-len(sample), self.remote_index_url)
                bot.send_msg(self.channel, msg)

            if quotes:
                last_quote = max(
                    last_quote, max(qid for (qid, quote) in quotes))
                chan_state['last_quote'] = last_quote
                url_state[self.channel.lower()] = chan_state
                state[self.index_url] = url_state
                write_state(state)
        except:
            traceback.print_exc()
开发者ID:joodicator,项目名称:PageBot,代码行数:33,代码来源:qdbs.py


示例6: h_bridge

def h_bridge(bot, target_chan, msg, source, no_proxy=False, **kwds):
    if not target_chan.startswith('#'): return
    bot.send_msg(target_chan, msg, no_bridge=True)
    if isinstance(msg, unicode): msg = msg.encode('utf-8')
    if not no_proxy:
        yield later(sign('PROXY_MSG', bot, None, target_chan, msg,
                         no_auto = source.startswith('#')))
开发者ID:joodicator,项目名称:PageBot,代码行数:7,代码来源:bridge.py


示例7: h_names

def h_names(bot, chan, include_prefix):
    if chan.lower() in track_channels and chan.lower() in umode_channels:
        # Return the cached names if they exist.
        nicks = track_channels[chan.lower()]
        umode = umode_channels[chan.lower()]
    else:
        # Otherwise, retrieves the names from the server.
        bot.send_cmd('NAMES %s' % chan)
        while True:
            event, data = yield hold(bot, 'NAMES_SYNC')
            e_bot, e_chan, nicks, umode = data
            if e_chan.lower() == chan.lower(): break
    # Reconstruct the nick prefixes from the nicks and their modes.
    pre_ms, pre_cs = bot.isupport['PREFIX']
    names = []
    for nick in nicks:
        for pre_m, pre_c in izip(pre_ms, pre_cs):
            if pre_m in umode.get(nick.lower(), ''):
                prefix, sort_key = pre_c, (-pre_cs.index(pre_c), nick.lower())
                break
        else:
            prefix, sort_key = '', (None, nick.lower())
        names.append((sort_key, prefix+nick if include_prefix else nick))
    names = [n for (_,n) in sorted(names, reverse=True)]
    yield sign(('channel.names', bot, chan, include_prefix), names)
开发者ID:joodicator,项目名称:PageBot,代码行数:25,代码来源:channel.py


示例8: h_message

def h_message(work, head, body):
    if head == 0x02:
        yield sign('DISCONNECT', work, body)
    elif head == 0x03:
        slot, = struct.unpack('<B', body[:1])
        yield sign('CONNECTION_APPROVED', work, slot)
    elif head == 0x04:
        slot, = struct.unpack('<B', body[:1])
        if work.terraria_protocol.version_number < 156:
            name = body[25:]
        else:
            name = unpack_string(work, body[3:])
        yield sign('PLAYER_APPEARANCE', work, slot, name)
    elif head == 0x09:
        count, = struct.unpack('<i', body[:4])
        text = unpack_string(work, body[4:])
        yield sign('STATUSBAR_TEXT', work, count, text)
    elif head == 0x0E:
        slot, active = struct.unpack('<B?', body)
        yield sign('SET_PLAYER_ACTIVITY', work, slot, active)
#    elif head == 0x0D:
#        slot, cflags, islot, x,y, dx,dy, flags \
#            = struct.unpack('<BBBffffB', body)
#        yield sign('PLAYER_CONTROL', work, slot, (x, y))
    elif head == 0x19:
        slot, = struct.unpack('<B', body[:1])
        colour = struct.unpack('<BBB', body[1:4])
        text = unpack_string(work, body[4:])
        yield sign('CHAT', work, slot, colour, text)
    elif head == 0x31:
        yield sign('SPAWN', work)
    elif head == 0x07:
        if work.terraria_protocol.version_number < 69:
            spawn = struct.unpack('<ii', body[15:23])
            world_name = body[36:]
        elif work.terraria_protocol.version_number < 156:
            spawn = struct.unpack('<ii', body[16:24])
            world_name = body[91:]
        else:
            spawn = struct.unpack('<hh', body[10:14])
            world_name = unpack_string(work, body[22:])
        yield sign('WORLD_INFORMATION', work, spawn, world_name)
    elif head == 0x25:
        yield sign('REQUEST_PASSWORD', work)
    elif head not in (0x0a, 0x14, 0x17, 0x1a, 0x1b, 0x1c, 0x1d):
        yield sign('UNKNOWN', work, '$%02X' % head, body)
开发者ID:joodicator,项目名称:PageBot,代码行数:46,代码来源:terraria_protocol.py


示例9: kakasi

def kakasi(bot, id, target, msg, prefix=True, auto=False, **kwds):
    if auto and not kakasi_lib.is_ja(msg): return
    raw_reply = kakasi_lib.kakasi(msg)
    if auto and len(raw_reply) > 200: return
    reply = ('<%s> %s' % (id.nick, raw_reply)) if prefix and id else raw_reply
    bot.send_msg(target, reply)
    bot.drive('runtime.later', sign(
        'PROXY_MSG', bot, id, target, raw_reply, **dict(kwds, no_kakasi=True)))
开发者ID:joodicator,项目名称:PageBot,代码行数:8,代码来源:kakasi.py


示例10: nickserv_notice

def nickserv_notice(bot, id, msg):
    if conf('prompt') and conf('password') and msg.startswith(conf('prompt')):
        bot.send_msg(id.nick, 'IDENTIFY %s' % conf('password'))
        return
    final = conf('final')
    if final and msg.startswith(final):
        yield sign('NICKSERV_REGISTERED', bot)
        return
开发者ID:joodicator,项目名称:PageBot,代码行数:8,代码来源:nickserv.py


示例11: tick

def tick(bot):
    global ping_sent
    elapsed = time.time() - last_ping
    if elapsed > bot.conf['timeout']/2 and not ping_sent:
        bot.dump('PING :%s\r\n' % bot.nick)
        ping_sent = True
    elif elapsed > bot.conf['timeout']:
        print '! ping timeout: %ss' % elapsed
        yield sign(CLOSE, bot)
开发者ID:joodicator,项目名称:PageBot,代码行数:9,代码来源:head.py


示例12: notice

def notice(bot, id, target, msg):
    if target is not None: return
    if not conf('nickserv'): return
    nickserv = conf('nickserv')
    if id.nick.lower() != nickserv.nick.lower(): return
    if (id.user, id.host) != (nickserv.user, nickserv.host):
        raise Exception('%s is %[email protected]%s; %[email protected]%s expected.'
            % (id.nick, id.user, id.host, nickserv.user, nickserv.host))
    yield sign('NICKSERV_NOTICE', bot, id, msg)
开发者ID:joodicator,项目名称:PageBot,代码行数:9,代码来源:nickserv.py


示例13: examine_message

def examine_message(bot, id, source, message, full_msg=None):
    if isinstance(source, tuple): source = '%s!%[email protected]%s' % source
    source = source.lower()
    urls = extract_urls(message, full_msg=full_msg)
    if not urls: return

    history[source].append(urls)
    del history[source][:-HISTORY_SIZE]

    yield sign('URL_COLLECT_URLS', bot, urls, source, id, message)
开发者ID:joodicator,项目名称:PageBot,代码行数:10,代码来源:url_collect.py


示例14: further_fun

 def further_fun(bot, id, target, args, full_msg):
     match = re.search(r'(^|(?<=\s))(?P<cmd>!\S+)\s*(?P<args>.*)', args)
     if match:
         scmd = match.group('cmd').lower()
         if scmd in bot._base or ('SIMPLE', scmd) in bot._base:
             sargs = match.group('args')
             args = args[:match.start()]
             cont = sign('COMMAND', bot, id, target, scmd, sargs, full_msg)
             return func(bot, id, target, args, full_msg, cont)
     return func(bot, id, target, args, full_msg, lambda *args: None)
开发者ID:joodicator,项目名称:PageBot,代码行数:10,代码来源:util.py


示例15: h_spawn

def h_spawn(work):
    if not hasattr(work, 'terraria_protocol'): return
    if work.terraria_protocol.stage != 2: return
    work.terraria_protocol.stage = 3
    spawn = (0, 9999)
    send_spawn_player(work, work.terraria_protocol.slot, *spawn)
    for text in work.terraria_protocol.chat_queue:
        chat(work, text)
    work.terraria_protocol.chat_queue = []
    yield sign('HEARTBEAT', work)
开发者ID:joodicator,项目名称:PageBot,代码行数:10,代码来源:terraria_protocol.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python network.xmap函数代码示例发布时间:2022-05-27
下一篇:
Python untangle.parse函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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