def unhook_timer(): global hooks if hooks["timer"] != "": weechat.bar_item_remove(hooks["bar_item"]) weechat.unhook(hooks["timer"]) hooks["timer"] = "" hooks["bar_item"]
def hook_timer(): global hooks hooks["timer"] = weechat.hook_timer(int(OPTIONS["refresh"]) * 1000, 0, 0, 'item_update', '') hooks["bar_item"] = weechat.bar_item_new(SCRIPT_NAME, 'show_item','') if hooks["timer"] == 0: weechat.prnt('',"%s: can't enable %s, hook failed" % (weechat.prefix("error"), SCRIPT_NAME)) weechat.bar_item_remove(hooks["bar_item"]) hooks["bar_item"] = "" return 0 weechat.bar_item_update(SCRIPT_NAME) return 1
def shutdown(): """Script unload callback.""" debug('shutdown') weechat.config_write(CONFIG_FILE) for account in ACCOUNTS.itervalues(): account.end_all_private() free_all_config() weechat.bar_item_remove(OTR_STATUSBAR) return weechat.WEECHAT_RC_OK
def toggle_refresh(pointer, name, value): option_name = name[len('plugins.var.python.' + SCRIPT_NAME + '.'):] # get optionname # option was removed? remove bar_item from struct if not weechat.config_get_plugin(option_name): ptr_bar = weechat.bar_item_search(option_name) if ptr_bar: weechat.bar_item_remove(ptr_bar) return weechat.WEECHAT_RC_OK # check if option is new or changed if not weechat.bar_item_search(option_name): weechat.bar_item_new(option_name,'update_item',option_name) weechat.bar_item_update(option_name) return weechat.WEECHAT_RC_OK