本文整理汇总了Python中weechat.config_set_plugin函数的典型用法代码示例。如果您正苦于以下问题:Python config_set_plugin函数的具体用法?Python config_set_plugin怎么用?Python config_set_plugin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了config_set_plugin函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: 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', '')
示例2: print_tweet_data
def print_tweet_data(buffer,tweets,data):
for message in tweets:
nick = message[1]
text = message[3]
reply_id = ""
if script_options['tweet_nicks']:
parse_for_nicks(text,buffer)
add_to_nicklist(buffer,nick,tweet_nicks_group[buffer])
if script_options['print_id']:
t_id = weechat.color('reset') + ' ' + dict_tweet(message[2])
else:
t_id = ''
if len(message) == 5:
#This is a reply to a tweet
arrow_col = weechat.color('chat_prefix_suffix')
reset_col = weechat.color('reset')
reply_id = arrow_col + "<" + reset_col + dict_tweet(message[4]) + arrow_col + "> " + reset_col
temp_text = text
text = reply_id
reply_id = temp_text
weechat.prnt_date_tags(buffer, message[0], "notify_message",
"%s%s\t%s%s" % (nick, t_id, text,reply_id))
if data == "id":
try:
if script_options['last_id'] < tweets[-1][2]:
script_options['last_id'] = tweets[-1][2]
# Save last id
weechat.config_set_plugin("last_id",script_options["last_id"])
except:
pass
示例3: at_control
def at_control(data,buffer,args):
argv = args.split(' ')
js = ', '
if argv[0] in ['enable','disable','toggle']:
if argv[0] == 'enable' : config['enable'] = True
if argv[0] == 'disable': config['enable'] = False
if argv[0] == 'toggle' : config['enable'] = not config['enable']
weechat.config_set_plugin('enable','on' if config['enable'] else 'off')
if argv[0] == 'status':
weechat.prnt('','atcomplete: %s' % 'on' if config['enable'] else 'off')
weechat.prnt('',' servers: %s' % js.join(config['servers']))
weechat.prnt('',' buffers: %s' % js.join(config['buffers']))
if argv[0] in ['server','buffer']:
sets = argv[0]+'s'
if argv[1] == 'list':
weechat.prnt('','atcomplete %s: %s' % (sets,js.join(config[sets])))
if (argv[1] == 'add' and len(argv) == 3):
if argv[2] not in config[sets]:
config[sets].append(argv[2])
at_config('',STRIP_VAR+sets,js.join(config[sets]))
if (argv[1] == 'del' and len(argv) == 3):
if argv[2] in config[sets]:
config[sets].remove(argv[2])
at_config('',STRIP_VAR+sets,js.join(config[sets]))
return weechat.WEECHAT_RC_OK
示例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)
示例5: load_config
def load_config(data=None, option=None, value=None):
"""
Load configuration options and (re)register hook_timer to clear old
messages based on the current value of check_every. If check_every is 0
then messages are never cleared.
"""
# On initial load set any unset options to the defaults.
if not option:
for option, default in settings.iteritems():
if not weechat.config_is_set_plugin(option):
weechat.config_set_plugin(option, default)
if not option or option.endswith('check_every'):
# If hook_timer for clearing old messages is set already, clear it.
old_hook = globals().get('CLEAR_HOOK', None)
if old_hook is not None:
weechat.unhook(old_hook)
# Register hook_timer to clear old messages.
check_every = get_option_int('check_every') * 1000
if check_every:
globals()['CLEAR_HOOK'] = weechat.hook_timer(
check_every, 0, 0, 'clear_messages_cb', '')
return weechat.WEECHAT_RC_OK
示例6: load_settings
def load_settings():
for (option, default_value) in configs.items():
if w.config_get_plugin(option) == '':
if configs[option] == '_required':
w.prnt('', 'missing plugins.var.python.weepushover.{}'.format(option))
else:
w.config_set_plugin(option, configs[option])
示例7: command_cb
def command_cb(data, buffer, args):
debug('adding "%s"' % args)
items = weechat.config_get_plugin('items')
new_items = '%s %s' % (items, args)
debug('new_items: %s' % new_items)
weechat.config_set_plugin('items', new_items)
return weechat.WEECHAT_RC_OK
示例8: del_from_exemptions
def del_from_exemptions(entry):
"""Remove an entry from the list of defined exemptions.
:param entry: The entry to delete, which can be specified by the position in the list or by the name itself.
:returns: the new list of entries. The return value is only used for unit testing.
"""
entries = list_exemptions()
try:
# by index
try:
index = int(entry) - 1
if index < 0:
raise IndexError
entry = entries.pop(index)
except IndexError:
weechat.prnt("", "[{}] del: Index out of range".format(SCRIPT_COMMAND))
return entries
except ValueError:
try:
# by name
entries.remove(entry)
weechat.config_set_plugin("exemptions", DELIMITER.join(entries))
except ValueError:
weechat.prnt("", "[{}] del: Could not find {}".format(SCRIPT_COMMAND, entry))
return entries
weechat.config_set_plugin("exemptions", DELIMITER.join(entries))
weechat.prnt("", "[{}] del: Removed {} from exemptions.".format(SCRIPT_COMMAND, entry))
return entries
示例9: get_validated_key_from_config
def get_validated_key_from_config(setting):
key = weechat.config_get_plugin(setting)
if key != 'mask' and key != 'nick':
weechat.prnt("", "Key %s not found. Valid settings are 'nick' and 'mask'. Reverted the setting to 'mask'" % key)
weechat.config_set_plugin("clone_report_key", "mask")
key = "mask"
return key
示例10: init_options
def init_options():
for option,value in OPTIONS.items():
if not weechat.config_get_plugin(option):
weechat.config_set_plugin(option, value[0])
else:
OPTIONS[option] = weechat.config_get_plugin(option)
weechat.config_set_desc_plugin(option, '%s (default: "%s")' % (value[1], value[0]))
示例11: 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", "")
示例12: 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.
notifications = [
'Public',
'Private',
'Action',
'Notice',
'Invite',
'Highlight',
'Server',
'Channel',
'DCC',
'WeeChat'
]
# 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', '')
示例13: urlview
def urlview(data, buf, args):
infolist = weechat.infolist_get("buffer_lines", buf, "")
lines = []
while weechat.infolist_next(infolist) == 1:
lines.append(
weechat.string_remove_color(
weechat.infolist_string(infolist, "message"),
""
)
)
weechat.infolist_free(infolist)
if not lines:
weechat.prnt(buf, "No URLs found")
return weechat.WEECHAT_RC_OK
if not weechat.config_is_set_plugin("command"):
weechat.config_set_plugin("command", "urlview")
command = weechat.config_get_plugin("command")
text = "\n".join(reversed(lines))
response = os.system("echo %s | %s" % (pipes.quote(text), command))
if response != 0:
weechat.prnt(buf, "No URLs found")
weechat.command(buf, "/window refresh")
return weechat.WEECHAT_RC_OK
示例14: main
def main():
'''Sets up WeeChat Growl notifications.'''
# Initialize options.
for option, value in SETTINGS.items():
if not weechat.config_is_set_plugin(option):
weechat.config_set_plugin(option, value)
# Initialize Growl.
name = "WeeChat"
hostname = weechat.config_get_plugin('hostname')
password = weechat.config_get_plugin('password')
icon_path = os.path.join(weechat.info_get("weechat_dir", ""),
weechat.config_get_plugin('icon'))
try:
icon = open(icon_path, "rb").read()
except IOError:
weechat.prnt('',
'Weechat-Growl: {0} could not be opened. '.format(icon_path) +
'Please make sure it exists.')
icon = None
notifications = [
'Public',
'Private',
'Action',
'Notice',
'Invite',
'Highlight',
'Server',
'Channel',
'DCC',
'WeeChat'
]
if len(hostname) == 0:
hostname = ''
if len(password) == 0:
password = ''
growl = GrowlNotifier(
applicationName=name,
hostname=hostname,
password=password,
notifications=notifications,
applicationIcon=icon)
try:
growl.register()
except Exception as error:
weechat.prnt('', 'growl: {0}'.format(error))
STATE['growl'] = growl
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', '')
示例15: init_options
def init_options():
for option,value in list(OPTIONS.items()):
if not weechat.config_is_set_plugin(option):
weechat.config_set_plugin(option, value[0])
OPTIONS[option] = value[0]
else:
OPTIONS[option] = weechat.config_get_plugin(option)
weechat.config_set_desc_plugin(option, "%s (default: '%s')" % (value[1], value[0]))