本文整理汇总了Python中weechat.hook_command函数的典型用法代码示例。如果您正苦于以下问题:Python hook_command函数的具体用法?Python hook_command怎么用?Python hook_command使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了hook_command函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: hook_commands_and_completions
def hook_commands_and_completions():
compl_list = []
com_list = []
desc_list = []
for command in sorted(command_dict):
compl_list.append(command)
com_list.append(command + weechat.color("*red") + " or " +
weechat.color('reset') + command_dict[command] + "\n")
desc_list.append(weechat.color("chat_nick_other") + command + ": \n" + desc_dict[command])
weechat.hook_command("twitter", "Command to interact with the twitter api/plugin",
" | ".join(com_list),
"You can type all of these command in the twitter buffer if you add a ':' before the command, IE:\n"
":limits\n\n"
"If you don't type a command in the twitter buffer you will tweet that instead,\n"
"text after 140 chars will turn red to let you know were twitter will cut off your tweet.\n\n"
+ weechat.color("*red") + "NOTE:\n"
"There are limits on how many twitter api calls you can do, some calls are _quite_ restricted.\n"
"So if you get HTML errors from the twitter lib you probably exceeded the limit\n"
"you can check out your limits with the rate_limits/limits command.\n"
"_Most_ commands in this plugin only uses one call. If you want to check old tweets\n"
"in your home timeline it's better to request many tweets in one go.\n"
"That way you don't have to request new tweets as often to go further back in the timeline.\n"
"And thus you are less likely to hit the limit of requests you can do in the 15 min time window.\n"
"\nYou can write newlines in your tweet with html newline ' ' (you can autocomplete it)\n"
"\nThe 'number' next to the nicks in the chat window is the <id> of the tweet it's used\n"
"in the some of the twitter plugin commands.\n\n"
"Command desc:\n"+ "\n".join(desc_list),
" || ".join(compl_list),
"my_command_cb", "")
示例2: main
def main():
if not weechat.register("edit", "Keith Smiley", "1.0.0", "MIT",
"Open your $EDITOR to compose a message", "", ""):
return weechat.WEECHAT_RC_ERROR
weechat.hook_command("edit", "Open your $EDITOR to compose a message", "",
"", "", "edit", "")
示例3: main
def main():
""" Entry point, initializes everything """
# Setup the translation table, mapping latin characters to their Unicode
# fullwidth equivalents.
global FW_TABLE
FW_TABLE = dict(zip(range(0x21, 0x7F),
range(0xFF01, 0xFF5F)))
# Handle space specially.
FW_TABLE[0x20] = 0x3000
weechat.register(
SCRIPT_NAME,
SCRIPT_AUTHOR,
SCRIPT_VERSION,
SCRIPT_LICENSE,
SCRIPT_DESCRIPTION,
"", # Shutdown callback function
"", # Charset (blank for utf-8)
)
# Command callbacks
weechat.hook_command( # command name
"fw",
# description
"Translates latin characters to their fullwidth equivalents.",
# arguments
"text",
# description of arguments
" text: text to be full-width'd",
# completions
"",
"fw_cb", "")
示例4: main
def main():
if not weechat.register("giphy", "Keith Smiley", "1.0.0", "MIT",
"Insert a random giphy URL", "", ""):
return weechat.WEECHAT_RC_ERROR
weechat.hook_command("giphy", "Insert a random giphy URL", "",
"", "", "giphy", "")
示例5: go_main
def go_main():
"""Entry point."""
if not weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION,
SCRIPT_LICENSE, SCRIPT_DESC,
'go_unload_script', ''):
return
weechat.hook_command(
SCRIPT_COMMAND,
'Quick jump to buffers', '[term(s)]',
'term(s): directly jump to buffer matching the provided term(s) single'
'or space dilimited list (without argument, list is displayed)\n\n'
'You can bind command to a key, for example:\n'
' /key bind meta-g /go\n\n'
'You can use completion key (commonly Tab and shift-Tab) to select '
'next/previous buffer in list.',
'%(buffers_names)',
'go_cmd', '')
# set default settings
version = weechat.info_get('version_number', '') or 0
for option, value in SETTINGS.items():
if not weechat.config_is_set_plugin(option):
weechat.config_set_plugin(option, value[0])
if int(version) >= 0x00030500:
weechat.config_set_desc_plugin(
option, '%s (default: "%s")' % (value[1], value[0]))
weechat.hook_info('go_running',
'Return "1" if go is running, otherwise "0"',
'',
'go_info_running', '')
示例6: main
def main():
hook = weechat.hook_modifier('weechat_print', 'unhighlight_cb', '')
description = """
{script_name} lets you set up a regex for things to never highlight.
To use this, set the localvar 'unhighlight_regex' on a buffer. Lines in
that buffer which match will never be highlighted, even if they have
your nick or match highlight_words or highlight_regex.
You will need the script 'buffer_autoset.py' installed to make local
variables persistent; see the examples below.
Examples:
Temporarily block highlights in the current buffer for lines matching 'banana':
/buffer set localvar_set_unhighlight_regex banana
Unhighlight SASL authentication messages for double logins:
/buffer weechat
/buffer set localvar_set_unhighlight_regex SaslServ
/autosetbuffer add core.weechat localvar_set_unhighlight_regex SaslServ
List buffers with autoset unhighlights:
/{script_name} list
Show this help:
/{script_name}
Display local variables for current buffer:
/buffer localvar
""".format(script_name = SCRIPT_NAME)
weechat.hook_command(SCRIPT_NAME, SCRIPT_DESC, 'list', description, 'list %-', 'command_cb', '')
示例7: main
def main():
if not weechat.register("emote", "Keith Smiley", "1.0.0", "MIT",
"Paste awesome unicode!", "", ""):
return weechat.WEECHAT_RC_ERROR
weechat.hook_command("emote", "Paste awesome unicode!", "", "",
"|".join(mappings.keys()), "emote", "")
示例8: main
def main():
""" Entry point, initializes everything """
weechat.register(
SCRIPT_NAME,
SCRIPT_AUTHOR,
SCRIPT_VERSION,
SCRIPT_LICENSE,
SCRIPT_DESCRIPTION,
"", # Shutdown callback function
"", # Charset (blank for utf-8)
)
# Default values for settings
default_settings = {
'dbfile': os.path.join(
weechat.info_get("weechat_dir", ""), "emojis-db.dat")
}
# Apply default configuration values if anything is unset
for option, default in default_settings.items():
if not weechat.config_is_set_plugin(option):
weechat.config_set_plugin(option, default)
# Hook callbacks
weechat.hook_config("plugins.var.python." + SCRIPT_NAME + ".*",
"configuration_cb", "")
weechat.hook_command_run("/input return", "transform_cb", "")
weechat.hook_command_run("/input complete*", "complete_cb", "")
#weechat.hook_modifier("input_text_display", "collapse_cb", "")
# Command callbacks
weechat.hook_command( # command name
SCRIPT_NAME,
# description
" display :common_name: with its emoji equivalent",
# arguments
"reload"
" || add <name> <emoji>"
" || show <emoji>",
# description of arguments
" name: emoji name, sans colons\n"
"emoji: text that replaces :name:\n",
# completions
"reload || add || show %(emoji_name)", "emojis_cb", "")
weechat.hook_completion("emoji_name", "Emoji name", "emoji_name_completion_cb", "")
dbfile = weechat.config_get_plugin("dbfile")
weechat.prnt("", "%s: Loading emojis from %s" % (SCRIPT_NAME, dbfile))
try:
load_emojis(dbfile)
except IOError as e:
weechat.prnt("",
"%s%s: Database file %s is missing or inaccessible." \
% (weechat.prefix("error"), SCRIPT_NAME, dbfile))
raise e # TODO: handle this better instead of brutally aborting
示例9: init_script
def init_script():
weechat.hook_command(
"weecat",
"open a new buffer reading a given file",
"",
"",
"",
"weecat_command_cb", ""
)
示例10: main
def main():
if distutils.spawn.find_executable("urlview") is None:
return weechat.WEECHAT_RC_ERROR
if not weechat.register("urlview", "Keith Smiley", "1.0.2", "MIT",
"Use urlview on the current buffer", "", ""):
return weechat.WEECHAT_RC_ERROR
weechat.hook_command("urlview", "Pass the current buffer to urlview", "",
"", "", "urlview", "")
示例11: main
def main():
if not weechat.register("imgur", "Keith Smiley", "1.0.0", "MIT",
"Upload an image to imgur", "", ""):
return weechat.WEECHAT_RC_ERROR
if not weechat.config_get_plugin(CLIENT_ID):
weechat.config_set_plugin(CLIENT_ID, "Set imgur client ID")
weechat.hook_command("imgur", "Pass the current buffer to urlview", "",
"", "filename", "imgur", "")
示例12: main
def main():
"""Main entry"""
weechat.register(NAME, AUTHOR, VERSION, LICENSE, DESC, '', '')
weechat.hook_completion('replacer_plugin', 'Try to match last word with '
'those in replacement map keys, and replace it '
'with value.', 'replace_cb', '')
weechat.hook_completion('completion_cb', 'Complete replacement map keys',
'completion_cb', '')
weechat.hook_command(COMMAND, DESC, "[add <word> <text>|del <word>]",
__doc__ % {"command": COMMAND},
'add|del %(completion_cb)', 'replace_cmd', '')
示例13: main
def main():
""" Entry point, initializes everything """
weechat.register(
SCRIPT_NAME,
SCRIPT_AUTHOR,
SCRIPT_VERSION,
SCRIPT_LICENSE,
SCRIPT_DESCRIPTION,
"", # Shutdown callback function
"", # Charset (blank for utf-8)
)
# Default values for settings
default_settings = {
'dbfile': os.path.join(
weechat.info_get("weechat_dir", ""), "emojis-db.dat")
}
# Apply default configuration values if anything is unset
for option, default in default_settings.items():
if not weechat.config_is_set_plugin(option):
weechat.config_set_plugin(option, default)
# Hook callbacks
weechat.hook_config(
"plugins.var.python." + SCRIPT_NAME + ".*",
"configuration_cb", "")
weechat.hook_command_run("/input return", "transform_cb", "")
weechat.hook_command_run("/input complete*", "complete_cb", "")
# Command callbacks
weechat.hook_command(
"reloademojis", "reload emojis from file",
"", "", "", "reload_emojis_cb", "")
dbfile = weechat.config_get_plugin("dbfile")
weechat.prnt("", "%s: Loading emojis from %s" % (SCRIPT_NAME, dbfile))
try:
load_emojis(dbfile)
except IOError as e:
weechat.prnt(
"",
"%s%s: Database file %s is missing or inaccessible."
% (weechat.prefix("error"), SCRIPT_NAME, dbfile))
raise e # TODO: handle this better instead of brutally aborting
示例14: main
def main():
if not init(): return
weechat.hook_command(SCRIPT_COMMAND,
SCRIPT_DESC,
"[cmd1 | cmd2]",
" cmd1: comand1\n"
" cmd2: command2\n",
"cmd1 example",
"bee_cmd", "")
weechat.bar_item_new(bar_item, "bee_item_cb", "");
weechat.bar_new(bar_name, "on", "0", "root", "", "top", "horizontal",
"vertical", "0", "0", "default", "default", "default", "0",
bar_item);
return
示例15: main_weechat
def main_weechat():
"""Main function, called only in WeeChat."""
if not weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION,
SCRIPT_LICENSE, SCRIPT_DESC, '', ''):
return
theme_config_init()
theme_config_read()
theme_init()
weechat.hook_command(
SCRIPT_COMMAND,
'WeeChat theme manager',
'list [<text>] || info|show [<theme>] || install <theme>'
' || installfile <file> || update || undo || backup || save <file>'
' || restore || export [-white] <file>',
' list: list themes (search text if given)\n'
' info: show info about theme (without argument: for current '
'theme)\n'
' show: show all options in theme (without argument: for '
'current theme)\n'
' install: install a theme from repository\n'
'installfile: load theme from a file\n'
' update: download and unpack themes in themes directory\n'
' undo: undo last theme install\n'
' backup: backup current theme (by default in '
'~/.weechat/themes/_backup.theme); this is done the first time script '
'is loaded\n'
' save: save current theme in a file\n'
' restore: restore theme backuped by script\n'
' export: save current theme as HTML in a file (with "-white": '
'use white background in HTML)\n\n'
'Examples:\n'
' /' + SCRIPT_COMMAND + ' save /tmp/flashcode.theme => save current '
'theme',
'list'
' || info %(filename)'
' || show %(filename)'
' || install %(themes)'
' || installfile %(filename)'
' || update'
' || undo'
' || save %(filename)'
' || backup'
' || restore'
' || export -white|%(filename) %(filename)',
'theme_cmd', '')