def privmsg_out(msg, server, query, command=False):
    if not query:
        return 0

    nick = query.name

    if command:
        msg = msg.split()
        if len(msg) < 2:
            return 0

        command, msg = msg[0], ' '.join(msg[1:])

        if command != '/me':
            return 0

    if nick in keys and len(msg) == 384:
        return 0

    if nick[0] == '#':
        return 0

    if nick in keys and nick not in chats:
        chats[nick] = Chats(keys['my_key'],
                            keys[nick],
                            max_length=400,
                            chaff_block_size=8,
                            debug=debug)
        silent_send(server, nick, chats[nick].encrypt_initial_keyx())
    elif nick not in keys:
        return 0

    send_msg(server, nick, msg, command=command)
    irssi.signal_stop()
    return 1
示例#2
0
def send(msg, server, witem):
	prefix = irssi.settings_get_str("prefix")
	targets = irssi.settings_get_str("prefix_targets")
	cmdchars = irssi.settings_get_str("cmdchars")
	if re.match("^([%s]|%s)" % (cmdchars, prefix), msg):
		return
	if not check_target(witem.name, targets):
		return
	signal = irssi.signal_get_emitted()
	msg = "%s%s" % (prefix, msg)
	irssi.signal_stop()
	irssi.signal_emit(signal, msg, server, witem)
示例#3
0
文件: accent.py 项目: vmiklos/vmexam
def send(msg, server, witem):
    global stripped_out

    if stripped_out:
        return
    signal = irssi.signal_get_emitted()
    if msg.startswith("/nounaccent"):
        msg = msg[len("/nounaccent") + 1 :]
    elif not msg.startswith("/dict") and not msg.startswith("/spell"):
        msg = unaccent(msg)
    stripped_out = True
    irssi.signal_stop()
    irssi.signal_emit(signal, msg, server, witem)
    stripped_out = False
def privmsg_in(server, msg, nick, user):
    omsg = msg

    window = server.window_item_find(nick)
    if not create_chats(nick):
        return 0

    if re.match(r'^\[\d\d:\d\d:\d\d\] ', msg):
        msg = msg[11:]

    try:
        msg = chats[nick].decrypt_msg(b64decode(msg))
    except ChatsError:
        if len(msg) != 384:
            window = server.window_item_find(nick)
            printformat(window, irssi.MSGLEVEL_MSGS, 'pubmsg',
                        [nick, '\x0305' + omsg])
        elif not chats[nick].initialized or chats[nick].established():
            keyx(nick, server, None)
        msg = None
    except TypeError:
        return 0

    if msg and 'keyx' in msg:
        if msg['keyx'] == True:
            window.prnt('Key exchange with %s completed.' % nick)
        else:
            if 'msg' not in msg:
                window.prnt('Received key exchange from %s.' % nick)
            silent_send(server, nick, msg['keyx'])

    if msg and 'msg' in msg:
        msg['msg'] = msg['msg'].replace('\0', '')

        action = re.search('^\x01ACTION (.*)\x01$', msg['msg'])
        if action:
            form, prntmsg = 'action_public', action.group(1)
        else:
            form, prntmsg = 'pubmsg', msg['msg']

        printformat(window, irssi.MSGLEVEL_MSGS, form,
                    [nick, '\x0303' + prntmsg])

    if msg and 'msgs' in msg and msg['msgs']:
        window.prnt('Re-sending un-acked messages to %s.' % nick)
        for msg in msg['msgs']:
            send_msg(server, nick, msg, resent=True)

    irssi.signal_stop()
    return 1
示例#5
0
def sig_beep():
    global might_beep

    beep_cmd = irssi.settings_get_str('beep_cmd')
    if not beep_cmd:
        return

    beep_flood = irssi.settings_get_int('beep_flood')
    if beep_flood <= 0:
        beep_flood = 1000
   
    if might_beep:
        os.system(beep_cmd)
        might_beep = False
        irssi.timeout_add(beep_flood, beep_overflow_timeout)

    irssi.signal_stop()