Esempio n. 1
0
def callGV(buf=None, number=None, input_data=None, msg_id=None, send=False):
    if send:
        send_hook = weechat.hook_process_hashtable(
            weechat_dir + '/python/wtsend.py', {'stdin': ''}, 0, 'sentCB',
            weechat.buffer_get_string(buf, 'name'))
        proc_data_fmt_str = ("{email}{sep}{passwd}{sep}{number}{sep}"
                             "{input_data}{sep}{msg_id}{sep}{api_key}{sep}")

        proc_data = proc_data_fmt_str.format(email=email,
                                             passwd=passwd,
                                             number=number,
                                             input_data=input_data,
                                             msg_id=msg_id,
                                             api_key=api_key,
                                             sep="\n")
        weechat.hook_set(send_hook, 'stdin', proc_data)
    else:
        proc_data_fmt_str = (
            "{email}{sep}{passwd}{sep}{api_key}{sep}{poll_interval}{sep}")
        proc_data = proc_data_fmt_str.format(
            email=email,
            passwd=passwd,
            api_key=api_key,
            poll_interval=weechat.config_get_plugin('poll_interval'),
            sep="\n")

        recv_hook = weechat.hook_process_hashtable(
            weechat_dir + '/python/wtrecv.py', {'stdin': ''}, 0,
            'renderConversations', '')
        weechat.hook_set(recv_hook, 'stdin', proc_data)
Esempio n. 2
0
def fzf_tmux_command_cb(data: str, buffer: str, args: str) -> int:
    cmd = ("fzf-tmux -- --delimiter='\t' --with-nth=3.. "
           "--preview='tail -$LINES {2} 2>/dev/null'")
    hook = weechat.hook_process_hashtable(cmd, {"stdin": "1"}, 0,
                                          "fzf_process_cb", "")
    for buffer_info in buffers():
        weechat.hook_set(hook, "stdin", "\t".join(buffer_info) + "\n")
    weechat.hook_set(hook, "stdin_close", "")
    return weechat.WEECHAT_RC_OK
Esempio n. 3
0
def fzf_kitty_command_cb(data: str, buffer: str, args: str) -> int:
    # "kitty @ launch --type=overlay --keep-focus --hold --stdin-source=@last_cmd_output --stdin-add-formatting--stdin-add-line-wrap-markers \""
    cmd = ("kitty @ launch --type=overlay --keep-focus --hold "
           "fzf -- --delimiter='\t' --with-nth=3.. "
           "--preview='tail -$LINES {2} 2>/dev/null'")
    hook = weechat.hook_process_hashtable(cmd, {"stdin": "1"}, 0,
                                          "fzf_process_cb", "")
    print_log("Debugging.. hook: {}".format(hook))
    for buffer_info in buffers():
        weechat.hook_set(hook, "stdin", "\t".join(buffer_info) + "\n")
    weechat.hook_set(hook, "stdin_close", "")
    return weechat.WEECHAT_RC_OK
Esempio n. 4
0
def callGV(buf=None, number=None, input_data=None, msg_id=None, send=False):
    if send:
        send_hook = weechat.hook_process_hashtable(weechat_dir + '/python/wtsend.py',
                    { 'stdin': '' }, 0, 'sentCB', weechat.buffer_get_string(buf, 'name'))
        proc_data = email + '\n' + passwd + '\n' + number + '\n' +\
                    input_data + '\n' + msg_id + '\n'
        weechat.hook_set(send_hook, 'stdin', proc_data)
    else:
        proc_data = email + '\n' + passwd + '\n' +\
                    weechat.config_get_plugin('poll_interval') + '\n'
        recv_hook = weechat.hook_process_hashtable(weechat_dir + '/python/wtrecv.py',
                { 'stdin': '' }, 0, 'renderConversations', '')
        weechat.hook_set(recv_hook, 'stdin', proc_data)
Esempio n. 5
0
def callGV(buf=None, number=None, input_data=None, msg_id=None, send=False):
    if send:
        send_hook = weechat.hook_process_hashtable(weechat_dir + '/python/wtsend.py',
                    { 'stdin': '' }, 0, 'sentCB', weechat.buffer_get_string(buf, 'name'))
        proc_data = email + '\n' + passwd + '\n' + number + '\n' +\
                    input_data + '\n' + msg_id + '\n'
        weechat.hook_set(send_hook, 'stdin', proc_data)
    else:
        proc_data = email + '\n' + passwd + '\n' +\
                    weechat.config_get_plugin('poll_interval') + '\n'
        recv_hook = weechat.hook_process_hashtable(weechat_dir + '/python/wtrecv.py',
                { 'stdin': '' }, 0, 'renderConversations', '')
        weechat.hook_set(recv_hook, 'stdin', proc_data)
Esempio n. 6
0
def tts(text):
    """Pronounce the text"""
    engine = weechat.config_get_plugin('tts_engine')
    lang = weechat.config_get_plugin('language')
    if engine == 'espeak':
        args = {'arg1':text}
        if lang:
            args['arg2'] = '-v'
            args['arg3'] = lang
        hook = weechat.hook_process_hashtable('espeak',args,0,'my_process_cb','')
    elif engine == 'festival':
        args = {'stdin':'1', 'arg1':'festival', 'arg2':'--tts'}
        if lang:
            args['arg3'] = '--language'
            args['arg4'] = lang
        hook = weechat.hook_process_hashtable('festival',args,0,'my_process_cb','')
        weechat.hook_set(hook, "stdin", text)
        weechat.hook_set(hook, "stdin_close", "")
    elif engine == 'picospeaker':
        args = {'stdin':'1'}
        if lang:
            args['arg1'] = '-l'
            args['arg2'] = lang
        hook = weechat.hook_process_hashtable('picospeaker',args,0,'my_process_cb','')
        weechat.hook_set(hook, "stdin", text)
        weechat.hook_set(hook, "stdin_close", "")
Esempio n. 7
0
def ircrypt_gpg_init():
	'''Initialize GnuPG'''
	global ircrypt_gpg_homedir, ircrypt_gpg_id
	# This should usually be ~/.weechat/ircrypt
	ircrypt_gpg_homedir = '%s/ircrypt' % weechat.info_get("weechat_dir", "")
	try:
		os.mkdir(ircrypt_gpg_homedir, 0o700)
	except OSError:
		pass

	# Probe for GPG key
	(ret, out, err) = ircrypt.ircrypt_gnupg(b'', '--homedir', ircrypt_gpg_homedir,
			'--list-secret-keys', '--with-fingerprint', '--with-colon')

	# GnuPG returncode
	if ret:
		ircrypt.ircrypt_error(err.decode('utf-8'), weechat.current_buffer())
		return weechat.WEECHAT_RC_ERROR
	elif err:
		ircrypt.ircrypt_warn(err.decode('utf-8'), '')

	# There is a secret key
	if out:
		try:
			ircrypt_gpg_id = out.decode('utf-8').split('fpr')[-1].split('\n')[0].strip(':')
			ircrypt.ircrypt_info('Found private gpg key with fingerprint %s' %
					ircrypt_gpg_id, '')
			return weechat.WEECHAT_RC_OK
		except:
			ircrypt.ircrypt_error('Unable to get key id', '')

	# Try to generate a key
	ircrypt.ircrypt_warn('No private key for assymetric encryption was found in the '
			+ 'IRCrypt GPG keyring. IRCrypt will now try to automatically generate a '
			+ 'new key. This might take quite some time as this procedure depends on '
			+ 'the gathering of enough entropy for generating cryptographically '
			+ 'strong random numbers. You cannot use the key exchange (public key'
			+ 'authentication) until this process is done. However, it does not'
			+ 'affect the symmetric encryption which can already be used. You '
			+ 'will be notified once the process is done.')
	binary = weechat.config_string(weechat.config_get('ircrypt.general.binary'))
	hook = weechat.hook_process_hashtable(binary, {
		'stdin': '1',
		'arg1': '--batch',
		'arg2': '--no-tty',
		'arg3': '--quiet',
		'arg4': '--homedir',
		'arg5': ircrypt_gpg_homedir,
		'arg6': '--gen-key'},
		0, 'ircrypt_key_generated_cb', '')
	gen_command = 'Key-Type: RSA\n' \
			+ 'Key-Length: 2048\n' \
			+ 'Subkey-Type: RSA\n' \
			+ 'Subkey-Length: 2048\n' \
			+ 'Name-comment: ircrypt\n' \
			+ 'Expire-Date: 0\n' \
			+ '%commit'

	weechat.hook_set(hook, 'stdin', gen_command)
	weechat.hook_set(hook, 'stdin_close', '')
	return weechat.WEECHAT_RC_OK