コード例 #1
0
ファイル: listbuffer.py プロジェクト: norrs/weechat-plugins
def lb_list_chan(data, signal, message):
    global lb_channels, lb_buffer, lb_list_started

    # Work-around for IRCds which don't send 321 Numeric (/List start)
    if not lb_list_started:
        lb_initialise_list(signal)

    for chan_data in re.findall(lb_channel_list_expression, message):
        lb_channels.append({
            'server':
            chan_data[0][1:-1],
            'numeric':
            chan_data[1],
            'nick':
            chan_data[2],
            'channel':
            chan_data[3],
            'users':
            chan_data[4],
            'nomodes':
            chan_data[5] == '',
            'modes':
            chan_data[6],
            'topic':
            weechat.hook_modifier_exec("irc_color_decode", "1", chan_data[7])
        })
    return weechat.WEECHAT_RC_OK
コード例 #2
0
ファイル: dechoder.py プロジェクト: fofp/cocktography
def dechoder_cmd(data, buffer, args):
    dechoded = api.dechode(args)
    for text, strokes in dechoded:
        payload = b'[dechoded {}-strokes] {}'.format(strokes, text)
        weechat.prnt(
            buffer,
            weechat.hook_modifier_exec(b'irc_color_decode', b'1', payload))
    return weechat.WEECHAT_RC_OK
コード例 #3
0
ファイル: dechoder.py プロジェクト: fofp/cocktography
 def result(text):
     destroked_text, strokes = api.destroke(text)
     msg_format = MULTI_STROKE_FORMAT if strokes > 0 else ZERO_STROKE_FORMAT
     return weechat.hook_modifier_exec(
         b'irc_color_decode', b'1',
         msg_format.format(strokes=strokes,
                           prefix=prefix,
                           cockstring=text,
                           dechoded=message[:cb_begin] + destroked_text +
                           message[cb_end:]))
コード例 #4
0
ファイル: dechoder.py プロジェクト: fofp/cocktography
def enchoder_cmd(data, buffer, args):
    # Usage
    #  /enchode [-flags] [/me]
    # Flags
    #  sN: strokes, where N is the number of strokes to apply
    #  lN: length, where N is the maximum length message to output
    # The following three flags are mutually exclusive:
    #  m: mixed chodes
    #  t: thin chodes
    #  w: wide chodes
    cmd = b'/say '
    flags = {b'strokes': 2, 'mode': b't', b'length': 340}
    modes = {
        b'm': cpi.CyphallicMethod.MIXED_CHODE,
        b't': cpi.CyphallicMethod.THIN_CHODE,
        b'w': cpi.CyphallicMethod.WIDE_CHODE
    }
    if args[0:2] == b'--':
        args = args[1:]
    else:
        matches = RE_CMD.match(args)
        if matches:
            groups = matches.groupdict()
            for key in set(groups).intersection(flags):
                val = groups[key]
                if val is not None:
                    flags[key] = int(val) if val.isdigit() else val
            args = args[matches.end(0):]
    if args[0:2] == b'//':
        args = args[1:]
    elif args[0] == b'/':
        if args[0:4] == b'/me ':
            args = args[4:]
            cmd = b'/me '
        else:
            weechat.prnt(
                b'', b'"{0}" not allowed here. Did you mean "/{0}"?'.format(
                    args[:args.find(b' ')]))
            return weechat.WEECHAT_RC_ERROR
    text = api.enchode(bytearray(args), flags[b'strokes'],
                       modes[flags[b'mode']], flags[b'length'])
    text = weechat.hook_modifier_exec(b'irc_color_decode', b'1', text)
    for line in text.splitlines():
        weechat.command(buffer, cmd + line)
    return weechat.WEECHAT_RC_OK
コード例 #5
0
ファイル: listbuffer.py プロジェクト: norrs/weechat-plugins
def lb_list_chan(data, signal, message):
  global lb_channels, lb_buffer, lb_list_started

  # Work-around for IRCds which don't send 321 Numeric (/List start)
  if not lb_list_started:
    lb_initialise_list(signal)

  for chan_data in re.findall(lb_channel_list_expression,message):
    lb_channels.append({
      'server':  chan_data[0][1:-1],
      'numeric': chan_data[1],
      'nick':    chan_data[2],
      'channel': chan_data[3],
      'users':   chan_data[4],
      'nomodes': chan_data[5] == '',
      'modes':   chan_data[6],
      'topic':   weechat.hook_modifier_exec("irc_color_decode", "1", chan_data[7])
    })
  return weechat.WEECHAT_RC_OK
コード例 #6
0
ファイル: hipchat.py プロジェクト: recht/weechat-plugins
def img_cb(data, command, rc, out, err):
    out = weechat.hook_modifier_exec('color_decode_ansi', '1', out)
    weechat.prnt(weechat.current_buffer(), out)
    return weechat.WEECHAT_RC_OK
コード例 #7
0
def colorize(text):
    if isinstance(text, unicode):
        text = text.encode('utf-8')
    result = weechat.hook_modifier_exec("irc_color_decode", "1", text)
    result = unicode(result, 'utf-8', errors='ignore')
    return (result)
コード例 #8
0
ファイル: 8bitmush.py プロジェクト: IllegalLeft/dotfiles
def telnet_read(data):
    rcv = tnet.read_all().decode("UTF-8")
    rcv = weechat.hook_modifier_exec("color_decode_ansi","1", rcv)
    return rcv