本文整理汇总了Python中weechat.hook_command函数的典型用法代码示例。如果您正苦于以下问题:Python hook_command函数的具体用法?Python hook_command怎么用?Python hook_command使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了hook_command函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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", "")
开发者ID:Arlefreak,项目名称:dotfiles,代码行数:29,代码来源:weetweet.py
示例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", "")
开发者ID:keith,项目名称:edit-weechat,代码行数:7,代码来源:edit.py
示例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", "")
开发者ID:flowbish,项目名称:weechat-fullwidth,代码行数:33,代码来源:fullwidth.py
示例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", "")
开发者ID:keith,项目名称:giphy-weechat,代码行数:7,代码来源:giphy.py
示例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', '')
开发者ID:gilbertw1,项目名称:scripts,代码行数:30,代码来源:go.py
示例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', '')
开发者ID:Zarthus,项目名称:scripts,代码行数:29,代码来源:unhighlight.py
示例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", "")
开发者ID:keith,项目名称:emote-weechat,代码行数:7,代码来源:emote.py
示例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
开发者ID:flowbish,项目名称:weechat-emojis,代码行数:58,代码来源:emojis.py
示例9: init_script
def init_script():
weechat.hook_command(
"weecat",
"open a new buffer reading a given file",
"",
"",
"",
"weecat_command_cb", ""
)
开发者ID:jesskay,项目名称:weecat,代码行数:9,代码来源:weecat.py
示例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", "")
开发者ID:keith,项目名称:urlview-weechat,代码行数:10,代码来源:urlview.py
示例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", "")
开发者ID:keith,项目名称:imgur-weechat,代码行数:10,代码来源:imgur.py
示例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', '')
开发者ID:gryf,项目名称:weechat-replacer,代码行数:13,代码来源:replacer.py
示例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
开发者ID:OliverUv,项目名称:weechat-emojis,代码行数:48,代码来源:emojis.py
示例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
开发者ID:frumiousbandersnatch,项目名称:weechat-scripts,代码行数:16,代码来源:bee.py
示例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', '')
开发者ID:MatthewCox,项目名称:dotfiles,代码行数:45,代码来源:theme.py
示例16: AddCommand
def AddCommand():
TRIV['commands']['main']['hook'] = weechat.hook_command(TRIV['commands']['main']['command'],
TRIV['commands']['main']['description'],
TRIV['commands']['main']['args'],
TRIV['commands']['main']['args_description'],
TRIV['commands']['main']['completion'],
TRIV['commands']['main']['callback'],
TRIV['commands']['main']['callback_data'])
return weechat.WEECHAT_RC_OK
开发者ID:manuelalcocer,项目名称:trivial,代码行数:9,代码来源:trivial.py
示例17: init
def init(self):
if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""):
global SAVEPATH
SAVEPATH = os.path.join(weechat.info_get('weechat_dir',''),'darktower','adfilter')
if not os.path.exists(SAVEPATH): os.makedirs(SAVEPATH)
self.saveFile = os.path.join(SAVEPATH,'adfilter.DT')
self.exceptFile = os.path.join(SAVEPATH,'AFexceptions.DT')
weechat.hook_command("adfilter", "Dark Tower AdFilter Commands",
"[COMMANDS]",
"[COMMANDS DETAIL]",
"[COMPLETION]",
"AdFilter", "command_cb:")
weechat.hook_modifier("irc_in_PRIVMSG", "AdFilter","privmsg_event:")
self.loadAds()
self.loadExceptions()
开发者ID:ruuk,项目名称:dark.tower.fserve,代码行数:18,代码来源:adfilter.py
示例18: loadCommand
def loadCommand(self,cmd):
cmd.wc = self
pointer = weechat.hook_command(cmd.name,
cmd.title,
cmd.usage,
cmd.help,
cmd.autocomplete,
cmd._callback(), "")
self.msg("Loaded Command: %s" % cmd.displayName())
开发者ID:djbouche,项目名称:superwee,代码行数:9,代码来源:superwee.py
示例19: init_script
def init_script():
global default_settings
for option, default_value in default_settings.items():
if not weechat.config_is_set_plugin(option):
weechat.config_set_plugin(option, default_value)
weechat.hook_command(
"weemustfeed",
"open/switch to weemustfeed buffer",
"",
"",
"",
"weemustfeed_command_cb", ""
)
weechat.hook_config(
"plugins.var.python.weemustfeed.interval",
"weemustfeed_reset_timer_cb", ""
)
开发者ID:DarkDefender,项目名称:scripts,代码行数:20,代码来源:weemustfeed.py
示例20: ircrypt_init
def ircrypt_init():
# Initialize configuration
ircrypt_config_init()
ircrypt_config_read()
# Look for GnuPG binary
if weechat.config_string(weechat.config_get('ircrypt.general.binary')):
# Initialize public key authentification
ircrypt_gpg_init()
# Register Hooks
weechat.hook_modifier('irc_in_notice', 'ircrypt_notice_hook', '')
weechat.hook_command('ircrypt-keyex', 'Commands of the Addon IRCrypt-keyex',
'[list] '
'| remove-public-key [-server <server>] <nick> '
'| start [-server <server>] <nick> ',
SCRIPT_HELP_TEXT,
'list '
'|| remove-public-key %(nicks)|-server %(irc_servers) %- '
'|| start %(nicks)|-server %(irc_servers) %- ',
'ircrypt_command', '')
else:
ircrypt.ircrypt_error('GnuPG not found', weechat.current_buffer())
开发者ID:petvoigt,项目名称:ircrypt-weechat,代码行数:21,代码来源:ircrypt-keyex.py
注:本文中的weechat.hook_command函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论