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

Python weechat.hook_timer函数代码示例

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

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



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

示例1: add_invite

def add_invite(server, channel):
    servbuf = _server_buffer(server)
    if servbuf not in queue:
        queue[servbuf] = [channel]
        weechat.hook_timer(1000, 0, 1, "timer_cb", servbuf)
    else:
        queue[servbuf].append(channel)
开发者ID:PaulSalden,项目名称:weechat-scripts,代码行数:7,代码来源:qinvite.py


示例2: main

def main():
    if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""):
        version = int(weechat.info_get("version_number", "")) or 0

        # unset unused setting from older versions of script
        if weechat.config_is_set_plugin("display_unit"):
            weechat.prnt("", "Option plugins.var.python.bandwidth.display_unit no longer used, removing.")
            weechat.config_unset_plugin("display_unit")

        # set default settings
        for option in SCRIPT_SETTINGS.iterkeys():
            if not weechat.config_is_set_plugin(option):
                weechat.config_set_plugin(option, SCRIPT_SETTINGS[option][0])
            if version >= 0x00030500:
                weechat.config_set_desc_plugin(option, SCRIPT_SETTINGS[option][1])

        # ensure sane refresh_rate setting
        if int(weechat.config_get_plugin("refresh_rate")) < 1:
            weechat.prnt(
                "",
                "{}Invalid value for option plugins.var.python.bandwidth.refresh_rate, setting to default of {}".format(
                    weechat.prefix("error"), SCRIPT_SETTINGS["refresh_rate"][0]
                ),
            )
            weechat.config_set_plugin("refresh_rate", SCRIPT_SETTINGS["refresh_rate"][0])

        # create the bandwidth monitor bar item
        weechat.bar_item_new("bandwidth", "bandwidth_item_cb", "")
        # update it every plugins.var.python.bandwidth.refresh_rate seconds
        weechat.hook_timer(int(weechat.config_get_plugin("refresh_rate")) * 1000, 0, 0, "bandwidth_timer_cb", "")
开发者ID:Shrews,项目名称:scripts,代码行数:30,代码来源:bandwidth.py


示例3: a_notify

def a_notify(bname, nclass, title, description, priority=pynotify.URGENCY_LOW):
    '''Creates or updates the notification'''
    is_away = STATE['is_away']
    icon = STATE['icon']
    time_out = int(weechat.config_get_plugin("timeout"))
    cur_time = time.time()
    threshold = 1.0
    refresh = 0.01

    try:
        BUFFERS[bname].append(
                description,
                merge=weechat.config_get_plugin("merge") == "on",
                )
    except KeyError:
        BUFFERS[bname] = BufferState(
                title,
                threshold,
                refresh,
                icon=icon,
                priority=priority,
                timeout=time_out,
                )
        BUFFERS[bname].append(
                description,
                merge=weechat.config_get_plugin("merge") == "on",
                )
        weechat.hook_timer(500, 0, 1, "cb_buffer_start", bname)
开发者ID:kilogram,项目名称:weechat-anotify,代码行数:28,代码来源:anotify.py


示例4: main

def main():
    '''Sets up WeeChat notifications.'''
    # Initialize options.
    for option, value in SETTINGS.items():
        if not weechat.config_is_set_plugin(option):
            weechat.config_set_plugin(option, value)
    # Initialize.
    name = "WeeChat"
    icon = "/usr/share/pixmaps/weechat.xpm"
    notifications = [
        'Public',
        'Private',
        'Action',
        'Notice',
        'Invite',
        'Highlight',
        'Server',
        'Channel',
        'DCC',
        'WeeChat'
    ]
    STATE['icon'] = icon
    # Register hooks.
    weechat.hook_signal(
        'irc_server_connected',
        'cb_irc_server_connected',
        '')
    weechat.hook_signal(
        'irc_server_disconnected',
        'cb_irc_server_disconnected',
        '')
    weechat.hook_signal('upgrade_ended', 'cb_upgrade_ended', '')
    weechat.hook_print('', '', '', 1, 'cb_process_message', '')
    weechat.hook_timer(1000, 1, 65535, "cb_buffer_tick", "")
    pynotify.init(name)
开发者ID:kilogram,项目名称:weechat-anotify,代码行数:35,代码来源:anotify.py


示例5: conf_update_cb

def conf_update_cb(data, option, value):
    #Commit data if not part of ignore list.
    if weechat.config_get_plugin("commit_each_change") == "true"  and not option in weechat.config_get_plugin("auto_commit_ignore").split(","):
        #Call use pause else /save will be called before the config is actually saved to disc
        #This is kinda hack but better input would be appricated.
        weechat.hook_timer(500, 0, 1, "commit_cb", "")
    return weechat.WEECHAT_RC_OK
开发者ID:norrs,项目名称:weechat-plugins,代码行数:7,代码来源:confversion.py


示例6: cb_update_line_numbers

def cb_update_line_numbers(data, signal, signal_data):
    """Call `cb_timer_update_line_numbers()` when switching buffers.
    A timer is required because the bar item is refreshed before the new buffer
    is actually displayed, so ``win_chat_height`` would refer to the old
    buffer. Using a timer refreshes the item after the new buffer is displayed.
    """
    weechat.hook_timer(10, 0, 1, "cb_timer_update_line_numbers", "")
    return weechat.WEECHAT_RC_OK
开发者ID:tarruda,项目名称:dot-files,代码行数:8,代码来源:vimode.py


示例7: send_typing

def send_typing(nick, level):
    if not channel_has_nick(bitlbee_server_name, bitlbee_channel, nick):
        return
    cookie = sending_typing.get(nick, 1) + 1
    if not sending_typing.get(nick, None):
        send_typing_ctcp(nick, level)
    sending_typing[nick] = cookie
    w.hook_timer(4000, 0, 1, "typing_disable_timer", "%s:%i" % (nick, cookie))
开发者ID:emersonrp,项目名称:homedir,代码行数:8,代码来源:bitlbee_typing_notice.py


示例8: on_signal

def on_signal(*args, **kwargs):
	global timer
	''' Called whenever the buffer list changes. '''
	if timer is not None:
		weechat.unhook(timer)
		timer = None
	weechat.hook_timer(config.signal_delay, 0, 1, "on_timeout", "")
	return weechat.WEECHAT_RC_OK
开发者ID:ASKobayashi,项目名称:dotFiles,代码行数:8,代码来源:autosort.py


示例9: Winner

 def Winner(self, winner):
     self.trivial['state'] = 0
     if self.trivial['main_timer']:
         weechat.unhook(self.trivial['main_timer'])
     self.Show_Awards(winner)
     self.Register_Question(winner)
     self.Show_Session_Awards(winner)
     self.Show_Ranking()
     interval = int(self.opts['time_wait'])
     weechat.hook_timer(interval * 1000, 0, 1, 'Wait_Next_Round_cb', self.TrivId)
开发者ID:manuelalcocer,项目名称:trivial,代码行数:10,代码来源:trivial.py


示例10: modifier_cb

def modifier_cb(data,modifier,modifier_data,string):
    global bufp,linetosay
    if len(string)<2 or (string[0]=="/" and string[1]!="/"): return string
    bufp=modifier_data

    linetosay=intlmakeEline(string)
    if linetosay==None: return string

    weechat.hook_timer(10,0,1,"timer_cb","")
    return string
开发者ID:lieuwex,项目名称:dotfiles,代码行数:10,代码来源:intel_replace.py


示例11: cb_buffer_tick

def cb_buffer_tick(arg, remaining_calls):
    for buf in list(BUFFERS.keys()):
        if not BUFFERS[buf].tick():
            # weechat.prnt('', 'anotify: removing notifier {0}'.format(BUFFERS[buf]._window))
            BUFFERS.pop(buf)

    if remaining_calls == 0:
        weechat.hook_timer(1000, 1, 65535, "cb_buffer_tick", arg)

    return weechat.WEECHAT_RC_OK
开发者ID:kilogram,项目名称:weechat-anotify,代码行数:10,代码来源:anotify.py


示例12: serverConnected

def serverConnected(data, buffer, args):
    global start_time_sec
    start_time_sec = readTimer()
    global connectedState
    connectedState = 1
    # POSIX of the start of the session
    global session_start_time
    session_start_time = time.time()
    weechat.hook_timer(1000,1,0,'updateTimer','')
    return weechat.WEECHAT_RC_OK
开发者ID:mikestiers,项目名称:irctimer,代码行数:10,代码来源:irctimer.py


示例13: pressed_keys_check

def pressed_keys_check(data, remaining_calls):
    """Check the pressed keys and changes modes or detects bound keys
    accordingly.

    """
    global pressed_keys, mode, vi_buffer, esc_pressed
    # If the last pressed key was Escape, this one will be detected as an arg
    # as Escape acts like a modifier (pressing Esc, then pressing i is detected
    # as pressing meta-i). We'll emulate it being pressed again, so that the
    # user's input is actually processed normally.
    if esc_pressed is True:
        esc_pressed = False
        weechat.hook_timer(50, 0, 1, "handle_esc", pressed_keys[-1])
    if mode == "INSERT":
        # Ctrl + Space, or Escape
        if pressed_keys == "@" or pressed_keys == "[":
            set_mode("NORMAL")
            if pressed_keys == "[":
                esc_pressed = True
    elif mode == "NORMAL":
        # We strip all numbers and check if the the combo is recognized below,
        # then extract the numbers, if any, and pass them as the repeat factor.
        buffer_stripped = re.sub(num, '', vi_buffer)
        if vi_buffer in ['i', 'a', 'A']:
            set_mode("INSERT")
            if vi_buffer == 'a':
                weechat.command('', "/input move_next_char")
            elif vi_buffer == 'A':
                weechat.command('', "/input move_end_of_line")
        # Pressing '0' should not be detected as a repeat count.
        elif vi_buffer == '0':
            weechat.command('', vi_keys['0'])
        # Quick way to detect repeats (e.g. d5w). This isn't perfect, as things
        # like "5d2w1" are detected as "dw" repeated 521 times, but it should
        # be alright as long as the user doesn't try to break it on purpose.
        # Maximum number of repeats performed is 10000.
        elif buffer_stripped in vi_keys:
            repeat = ''.join(re.findall(num, vi_buffer))
            if len(repeat) > 0:
                repeat = min([int(repeat), 10000])
            else:
                repeat = 0
            if isinstance(vi_keys[buffer_stripped], str):
                for _ in range(1 if repeat == 0 else repeat):
                    weechat.command('', vi_keys[re.sub(num, '', vi_buffer)])
            else:
                buf = weechat.current_buffer()
                input_line = weechat.buffer_get_string(buf, 'input')
                cur = weechat.buffer_get_integer(buf, "input_pos")
                vi_keys[buffer_stripped](buf, input_line, cur, repeat)
        else:
            return weechat.WEECHAT_RC_OK
    clear_vi_buffers()
    return weechat.WEECHAT_RC_OK
开发者ID:jnbek,项目名称:_weechat,代码行数:54,代码来源:vimode.py


示例14: send_typing

def send_typing(nick, level):
    if level == 0 and nick in sending_typing:
        send_typing_ctcp(nick, 0)
        del sending_typing[nick]
    elif level > 0 :
        if nick not in sending_typing:
            send_typing_ctcp(nick, level)
        cookie = sending_typing.get(nick, 0) + 1
        sending_typing[nick] = cookie
        w.hook_timer( int(1000 * float(w.config_get_plugin('timeout'))), 0, 1,
                      "typing_disable_timer", "%s:%i" % (nick, cookie))
开发者ID:Arlefreak,项目名称:dotfiles,代码行数:11,代码来源:bitlbee_typing_notice.py


示例15: modifier_cb

def modifier_cb(data,modifier,modifier_data,string):
	global nrip
	bufplugin,bufname=modifier_data.split(";")[0:2]
	fullname=bufplugin+"."+bufname
	if fullname.lower()!=BUFFERNAME.lower():
		return string
	# weechat.prnt("",dashprefix+"[rip] SR=<"+str(SEARCHREGEX)+"> string=<"+string+">")
	if re.search(SEARCHREGEX,string,re.IGNORECASE):
		nrip+=1
		weechat.hook_timer(10,0,1,"timer_cb","")
	return string
开发者ID:lieuwex,项目名称:dotfiles,代码行数:11,代码来源:rip.py


示例16: bas_signal_buffer_opened_cb

def bas_signal_buffer_opened_cb(data, signal, signal_data):
    global bas_options
    buffer = signal_data
    timer = weechat.config_integer(bas_options["look_timer"])
    if timer == 0:
        bas_apply_options_for_buffer(buffer)
    else:
        weechat.hook_timer(timer, 0, 1,
                           "bas_timer_buffer_opened_cb",
                           weechat.buffer_get_string(buffer, "full_name"))
    return weechat.WEECHAT_RC_OK
开发者ID:AndyHoang,项目名称:dotfiles,代码行数:11,代码来源:buffer_autoset.py


示例17: cb_key_pressed

def cb_key_pressed(data, signal, signal_data):
    """Detect potential Esc presses.
    Alt and Esc are detected as the same key in most terminals. The difference
    is that Alt signal is sent just before the other pressed key's signal.
    We therefore use a timeout (50ms) to detect whether Alt or Esc was pressed.
    """
    global last_signal_time
    last_signal_time = time.time()
    if signal_data == "\x01[":
        # In 50ms, check if any other keys were pressed. If not, it's Esc!
        weechat.hook_timer(50, 0, 1, "cb_check_esc", "{:f}".format(last_signal_time))
    return weechat.WEECHAT_RC_OK
开发者ID:tarruda,项目名称:dot-files,代码行数:12,代码来源:vimode.py


示例18: wee_ns_reconnect_loop

def wee_ns_reconnect_loop(*args):
    weechat.prnt(server.buffer, 'Trying to reconnect...')
    server.connect()
    try:
        reconnect_time = int(server.get_option('reconnect_time'))
    except ValueError:
        reconnect_time = int(server.get_default('reconnect_time'))
    if not server.is_connected and reconnect_time > 0:
        weechat.prnt(server.buffer,
                     'Failed, next attempt in %s seconds'
                     % (server.get_option('reconnect_time'),))
        weechat.hook_timer(reconnect_time * 1000, 0, 1,
                           'wee_ns_reconnect_loop', '')
    return weechat.WEECHAT_RC_OK
开发者ID:DarkDefender,项目名称:scripts,代码行数:14,代码来源:weenetsoul.py


示例19: is_printing

def is_printing(current, saved):
    """Is the character a visible, printing character that would normally
    show in the input box?

    Previously saved characters are taken into consideration as well for some
    key combinations, such as the arrows, which are detected as three separate
    events (^A[, [ and A/B/C/D).
    The keys buffers will be cleared if the character isn't visible.

    """
    if current.startswith("") or saved.startswith(""):
        weechat.hook_timer(50, 0, 1, "clear_vi_buffers", '')
        return False
    return True
开发者ID:jnbek,项目名称:_weechat,代码行数:14,代码来源:vimode.py


示例20: cowchat

def cowchat(data, command, return_code, out, err):
    if return_code != 0:
        weechat.prnt(weechat.current_buffer(), "Cowchat error: {0}".format(return_code))
        for line in err.split("\n")[:-1]:
            weechat.prnt(weechat.current_buffer(), line)
        return weechat.WEECHAT_RC_ERROR
    lines = out.split("\n")
    cowchat_line("{}\n{}".format(data, out), len(lines) - 1)
    weechat.hook_timer(2000, 0, len(lines) - 1, "cowchat_line", "{}\n{}".format(data, out))
#    for line in out.split("\n"):
#        if len(line) > 1 and line[0] == '/':
#            line = '/' + line
#        weechat.hook_signal_send("irc_input_send", weechat.WEECHAT_HOOK_SIGNAL_STRING,
#                                 "{};2;;{}".format(data, line))
    return weechat.WEECHAT_RC_OK
开发者ID:telnoratti,项目名称:weechatrc,代码行数:15,代码来源:cowchat.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python weechat.info_get函数代码示例发布时间:2022-05-26
下一篇:
Python weechat.hook_signal函数代码示例发布时间: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