当前位置: 首页>>代码示例>>Python>>正文


Python weechat.hook_process_hashtable函数代码示例

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


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

示例1: notify

def notify(data, buffer, timestamp, tags, displayed, highlighted, prefix, message):
    buffer_name = weechat.buffer_get_string(buffer, 'name')
    buffer_type = weechat.buffer_get_string(buffer, 'localvar_type')
    server      = weechat.buffer_get_string(buffer, 'localvar_server')

    message     = None

    if buffer_type not in ['private', 'channel']:
        return weechat.WEECHAT_RC_OK

    if buffer_type == 'channel' and highlighted == 0:
        return weechat.WEECHAT_RC_OK

    if buffer_type == 'private':
        message = '{nick} sent you a private message on {server}'.format(nick=prefix, server=server)

    elif buffer_type == 'channel':
        channel = buffer_name.split('.', 1)[1]
        message = '{nick} mentioned you in {channel}'.format(nick=prefix, channel=channel)

    if message == None:
        return weechat.WEECHAT_RC_OK

    process_endpoint = 'url:https://api.pushover.net:443/1/messages.json'
    post_data = urllib.urlencode({
        'token':   OPTIONS['apptoken'],
        'user':    OPTIONS['userkey'],
        'sound':   OPTIONS['sound'],
        'message': message,
    })

    weechat.hook_process_hashtable(process_endpoint, { 'post': '1', 'postfields': post_data }, OPTIONS['timeout'], 'message_sent', '')

    return weechat.WEECHAT_RC_OK
开发者ID:lewiseason,项目名称:weechat-scripts,代码行数:34,代码来源:notify_pushover.py

示例2: tts

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", "")
开发者ID:DarkDefender,项目名称:scripts,代码行数:26,代码来源:tts.py

示例3: post_prowl

def post_prowl(label, title, message):
    opt_dict = urllib.urlencode(
        {"apikey": API_KEY, "priority": PRIORITY, "application": label, "event": title, "description": message}
    )
    weechat.hook_process_hashtable(
        "url:https://api.prowlapp.com/publicapi/add?", {"postfields": opt_dict}, 30 * 1000, "prowl_response", ""
    )
开发者ID:kidchunks,项目名称:weechat-prowl-notify,代码行数:7,代码来源:prowl_notify.py

示例4: pastero_cmd_cb

def pastero_cmd_cb(data, buffer, args):
    global Ext
    command = 'curl -sSF [email protected] ' + url

    if args.count('.') > 0:
        Ext = args.split('.')
        Ext.reverse()
    else:
        Ext = ' ' # Ugly hack so Ext[0] doesn't complain in case is empty :>

    if args != '':
        sargs = args.split()

        if sargs[0] == '--clip':
            f_input(get_clip_cmd().strip())

        elif sargs[0] == '--cmd':
            if len(sargs) == 1:
                w.prnt(w.current_buffer(),
                       '%s\tPlease specify a command to run.' % PREFIX)
            else:
                sargs = ' '.join(sargs[1:])
                command = ' '.join((sargs, '|', command))
                w.hook_process_hashtable('sh',
                                         {'arg1':'-c',
                                          'arg2':command},
                                         5 * 1000, 'printer_cb', '')
        else:
            f_input(open(sargs[0], 'r').read())
    else:
        w.prnt(w.current_buffer(),
                     '%s\tPlease, specify a file to upload.' % PREFIX)

    return WEECHAT_RC_OK
开发者ID:batalooppak,项目名称:pastero,代码行数:34,代码来源:pastero.py

示例5: post_prowl

def post_prowl(label, title, message):
    opt_dict = urllib.urlencode({
        'apikey': API_KEY,
        'application': label,
        'event': title,
        'description': message
    });
    weechat.hook_process_hashtable("url:https://api.prowlapp.com/publicapi/add?", { "postfields": opt_dict }, 30 * 1000, "prowl_response", "")
开发者ID:KokaKiwi,项目名称:weechat-scripts,代码行数:8,代码来源:prowl_notify.py

示例6: setup_from_url

def setup_from_url():
	"""Download replacements and store them in weechat home directory."""

	log("downloading XML...")
	weechat.hook_process_hashtable("url:https://www.w3.org/Math/characters/unicode.xml",
		{
			"file_out": xml_path
		},
		30000, "download_cb", "")
开发者ID:DarkDefender,项目名称:scripts,代码行数:9,代码来源:latex_unicode.py

示例7: img_dl_cb

def img_dl_cb(data, command, rc, out, err):
    weechat.hook_process_hashtable('img2txt', {
        'arg1': data,
        'arg2': '-f',
        'arg3': 'ansi',
        'arg4': '-y',
        'arg5': '12'
    }, 5000, 'img_cb', '')
    return weechat.WEECHAT_RC_OK
开发者ID:recht,项目名称:weechat-plugins,代码行数:9,代码来源:hipchat.py

示例8: call

def call(command, options):
	options = "\n".join(options).encode("utf-8")

	w.hook_process_hashtable("sh"
		,{"arg1": "-c","arg2": 'echo "{0}" | {1}'.format(options, command)}
		,10 * 1000
		,"launch_process_cb"
		,""
	)
开发者ID:DarkDefender,项目名称:scripts,代码行数:9,代码来源:buffer_dmenu.py

示例9: postProwl

def postProwl(label, title, message):
    if api_key != "":
        opt_dict = "apikey=" + api_key + "&application=" + label + "&event=" + title + "&description=" + message
        weechat.hook_process_hashtable("url:https://api.prowlapp.com/publicapi/add?",
            { "postfields": opt_dict },
            30 * 1000, "", "")
    else:
        weechat.prnt("", "API Key is missing!")
        return weechat.WEECHAT_RC_OK
开发者ID:frumiousbandersnatch,项目名称:weechat-scripts,代码行数:9,代码来源:prowl_notify.py

示例10: async_http_get_request

def async_http_get_request(domain, token, request):
    url = 'url:http://{token}:[email protected]{domain}/{request}'.format(
        domain=domain,
        request=request,
        token=token,
    )
    context = pickle.dumps({"request": request, "token": token})
    params = {'useragent': 'weechat-letschat 0.0'}
    w.hook_process_hashtable(url, params, 20000, "url_processor_cb", context)
开发者ID:calve,项目名称:weechat-letschat,代码行数:9,代码来源:weechat-letschat.py

示例11: send_push

def send_push(title, body):
    apikey = w.config_get_plugin("api_key")
    apiurl = "https://%[email protected]/v2/pushes" % (apikey)
    timeout = 20000 # FIXME - actually use config
    if len(title) is not 0 or len(body) is not 0:
        deviceiden = w.config_get_plugin("device_iden")
        if deviceiden == "all":
            payload = urllib.urlencode({'type': 'note', 'title': title, 'body': body.encode('utf-8')})
        else:
            payload = urllib.urlencode({'type': 'note', 'title': title, 'body': body.encode('utf-8'), 'device_iden':deviceiden})
        w.hook_process_hashtable("url:" + apiurl, { "postfields": payload, "header":"1" }, timeout, "process_pushbullet_cb", "")
开发者ID:butlerx,项目名称:dotfiles,代码行数:11,代码来源:weebullet.py

示例12: twitch_main

def twitch_main(data, buffer, args):
    if not args == 'bs':
        weechat.buffer_set(buffer, 'localvar_set_tstatus', '')
    username = weechat.buffer_get_string(buffer, 'short_name').replace('#', '')
    server = weechat.buffer_get_string(buffer, 'localvar_server')
    type = weechat.buffer_get_string(buffer, 'localvar_type')
    if not (server in OPTIONS['servers'].split() and type == 'channel'):
        return weechat.WEECHAT_RC_OK
    url = 'https://api.twitch.tv/kraken/streams/' + username
    weechat.hook_process_hashtable(
        "url:" + url+params, curlopt, 7 * 1000, "stream_api", buffer)
    return weechat.WEECHAT_RC_OK
开发者ID:MatthewCox,项目名称:dotfiles,代码行数:12,代码来源:twitch.py

示例13: async_http_post_request

def async_http_post_request(domain, token, request, post_data=None):
    url = 'http://{token}:[email protected]{domain}/{request}'.format(
        domain=domain,
        request=request,
        token=token,
    )
    context = pickle.dumps({"request": request, "token": token, "post_data": post_data})
    params = {'useragent': 'weechat-letschat 0.0'}
    command = 'curl -X POST {url} -H "Content-Type: application/json" --data \'{post_data}\''.format(
        url=url,
        post_data=json.dumps(post_data)
    )
    w.hook_process_hashtable(command, params, 20000, "url_processor_cb", context)
开发者ID:calve,项目名称:weechat-letschat,代码行数:13,代码来源:weechat-letschat.py

示例14: callGV

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)
开发者ID:rxcomm,项目名称:weeText,代码行数:13,代码来源:weetext.py

示例15: send_push

def send_push(title, message):
    postfields = {
        'token': w.config_get_plugin('token'),
        'user': w.config_get_plugin('user'),
        'title': title,
        'message': message,
        'url': 'https://glowing-bear.org',
    }

    w.hook_process_hashtable(
        'url:https://api.pushover.net/1/messages.json',
        {'postfields': urllib.urlencode(postfields)},
        20*1000,
        'http_request_callback',
        '',
    )
开发者ID:qguv,项目名称:config,代码行数:16,代码来源:weepushover.py


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