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

Python weechat.hook_process_hashtable函数代码示例

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

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



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


示例16: wg_download_file

def wg_download_file(url, filename, timeout, callback, callback_data):
    """Download a file with an URL. Return hook_process created."""
    version = weechat.info_get("version_number", "") or 0
    if int(version) >= 0x00030700:
        return weechat.hook_process_hashtable("url:%s" % url,
                                              { "file_out": filename },
                                              timeout,
                                              callback, callback_data)
    else:
        script = [ "import sys",
                   "try:",
                   "    if sys.version_info >= (3,):",
                   "        import urllib.request",
                   "        response = urllib.request.urlopen('%s')" % url,
                   "    else:",
                   "        import urllib2",
                   "        response = urllib2.urlopen(urllib2.Request('%s'))" % url,
                   "    f = open('%s', 'wb')" % filename,
                   "    f.write(response.read())",
                   "    response.close()",
                   "    f.close()",
                   "except Exception as e:",
                   "    print('error:' + str(e))" ]
        return weechat.hook_process("python -c \"%s\"" % "\n".join(script),
                                    timeout,
                                    callback, callback_data)
开发者ID:SammyLin,项目名称:chef-osx,代码行数:26,代码来源:weeget.py


示例17: send_command

def send_command(command):
    API_TOKEN = weechat.config_get_plugin("api_token")
    if API_TOKEN != "":
        url = "https://irssinotifier.appspot.com/API/Message"
        postdata = urllib.urlencode({'apiToken':API_TOKEN,'command':encrypt(command)})
        #TODO irssinotifier.pl retries 2 times and I think we should also retry (unless we know that the error is permanent)
        hook1 = weechat.hook_process_hashtable("url:"+url, { "postfields":  postdata}, 10000, "", "")
开发者ID:BBBSnowball,项目名称:IrssiNotifier,代码行数:7,代码来源:irssinotifier.py


示例18: show_notification

def show_notification(chan, nick, message):
    API_TOKEN = weechat.config_get_plugin("api_token")
    if API_TOKEN != "":
        url = "https://irssinotifier.appspot.com/API/Message"
        postdata = urllib.urlencode({'apiToken':API_TOKEN,'nick':encrypt(nick),'channel':encrypt(chan),'message':encrypt(message),'version':13})
        version = weechat.info_get("version_number", "") or 0
        hook1 = weechat.hook_process_hashtable("url:"+url, { "postfields":  postdata}, 2000, "", "")
开发者ID:KokaKiwi,项目名称:weechat-scripts,代码行数:7,代码来源:irssinotifier.py


示例19: shell_exec

def shell_exec(buffer, command):
    """Execute a command."""
    global cmd_hook_process, cmd_command, cmd_start_time, cmd_buffer
    global cmd_stdout, cmd_stderr, cmd_send_to_buffer, cmd_timeout
    if cmd_hook_process:
        weechat.prnt(buffer,
                     '%sanother process is running! (use "/%s -kill" to kill it)'
                     % (SHELL_PREFIX, SHELL_CMD))
        return
    if cmd_send_to_buffer == 'new':
        weechat.prnt(buffer, '-->\t%s%s$ %s%s'
                     % (weechat.color('chat_buffer'), os.getcwd(), weechat.color('reset'), command))
        weechat.prnt(buffer, '')
    args = command.split(' ')
    if args[0] == 'cd':
        shell_chdir(buffer, ' '.join(args[1:]))
    elif args[0] == 'getenv':
        shell_getenv (buffer, ' '.join(args[1:]))
    elif args[0] == 'setenv':
        shell_setenv (buffer, ' '.join(args[1:]))
    elif args[0] == 'unsetenv':
        shell_unsetenv (buffer, ' '.join(args[1:]))
    else:
        shell_init()
        cmd_command = command
        cmd_start_time = datetime.datetime.now()
        cmd_buffer = buffer
        version = weechat.info_get("version_number", "") or 0
        if int(version) >= 0x00040000:
            cmd_hook_process = weechat.hook_process_hashtable('sh', { 'arg1': '-c', 'arg2': command },
                                                              cmd_timeout * 1000, 'shell_process_cb', command)
        else:
            cmd_hook_process = weechat.hook_process("sh -c '%s'" % command, cmd_timeout * 1000, 'shell_process_cb', command)
开发者ID:HongxuChen,项目名称:dotfiles,代码行数:33,代码来源:shell.py


示例20: show_notification

def show_notification(chan, nick, message):
    API_TOKEN = weechat.config_get_plugin("api_token")
    if API_TOKEN != "":
        url = "https://irssinotifier.appspot.com/API/Message"
        postdata = urllib.urlencode({'apiToken':API_TOKEN,'nick':encrypt(nick),'channel':encrypt(chan),'message':encrypt(message),'version':VERSION})
        version = weechat.info_get("version_number", "") or 0
        #TODO irssinotifier.pl retries 2 times and I think we should also retry (unless we know that the error is permanent)
        hook1 = weechat.hook_process_hashtable("url:"+url, { "postfields":  postdata}, 10000, "", "")
开发者ID:BBBSnowball,项目名称:IrssiNotifier,代码行数:8,代码来源:irssinotifier.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python weechat.hook_signal函数代码示例发布时间:2022-05-26
下一篇:
Python weechat.hook_process函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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