本文整理汇总了Python中weechat.config_get_plugin函数的典型用法代码示例。如果您正苦于以下问题:Python config_get_plugin函数的具体用法?Python config_get_plugin怎么用?Python config_get_plugin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了config_get_plugin函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: notify_private_message_or_action
def notify_private_message_or_action(buffername, prefix, message, highlighted):
'''Notify on private message or action.'''
regex = re.compile(r'^CTCP_MESSAGE.+?ACTION (.+)$', re.UNICODE)
match = regex.match(message)
if match:
notify_private_action_message(buffername, prefix,
match.group(1), highlighted)
else:
if prefix == ' *':
regex = re.compile(r'^(\w+) (.+)$', re.UNICODE)
match = regex.match(message)
if match:
prefix = match.group(1)
message = match.group(2)
notify_private_action_message(buffername, prefix,
message, highlighted)
else:
if highlighted:
notify_highlighted_message(buffername, prefix, message)
elif (weechat.config_get_plugin("show_private_message") == "on"
or (weechat.config_get_plugin("show_private_message") == "away"
and STATE['is_away'])):
a_notify(
'Private',
'Private Message',
'{0}: {1}'.format(prefix, message))
示例2: notify_msg
def notify_msg(data, bufferp, time, tags, display, is_hilight, prefix, msg):
"""Sends highlighted message to be printed on notification"""
if ('notify_private' in tags and
weechat.config_get_plugin('show_priv_msg') == "on") \
or (int(is_hilight) and \
weechat.config_get_plugin('show_hilights') == "on"):
# grab the fully qualified buffer name so we can jump to it later
buffer = weechat.buffer_get_string(bufferp, "name")
# choose an appropriate brief name to display in the indicator applet
if 'notify_private' in tags:
brief = "private"
else:
# prefer short_name
brief = weechat.buffer_get_string(bufferp, "short_name")
if not brief:
# fall back to full name
brief = buffer
if weechat.config_get_plugin('debug') == "on":
print "buffer: " + buffer
print "brief: " + brief
print "prefix: " + prefix
print "msg: " + msg
# Create an object that will proxy for a particular remote object.
bus = dbus.SessionBus()
remote_object = bus.get_object(DBUS_CONNECTION, DBUS_OBJ_PATH)
remote_object.add_message(buffer, brief, prefix, msg)
return weechat.WEECHAT_RC_OK
示例3: print_matches
def print_matches(target, matches, data):
"""Print all matching masks to the target channel"""
verbose = w.config_get_plugin("verbose") in ["true", "yes"]
limit = int(w.config_get_plugin("limit"))
if limit < 1:
limit = 1
total = len(matches)
if total == 0:
if verbose or data["mode"] == "special":
w.prnt(target, "{}\tNo matches for {}".format(fmt_prefix(data).replace("_target_", ""), fmt_banmask(data["mask"])))
return
sorting = w.config_get_plugin("sorting")
if sorting == "alpha":
matches = sorted(matches)
elif sorting == "alpha_ignore_case":
matches = sorted(matches, key=str.lower)
if w.config_get_plugin("print_as_list") in ["true", "yes"]:
print_as_list(target, matches, data, limit, total)
else:
print_as_lines(target, matches, data, limit, total)
示例4: format_shared_channels
def format_shared_channels(channels, current_channels):
"""Take a list of channels and format it into a displayable string"""
count_shared = len(channels["shared"])
count_total = len(current_channels)
verbose = w.config_get_plugin("verbose_output") in ["true", "on"]
output_priority = w.config_get_plugin("output_priority")
if count_total == count_shared:
if verbose:
return "All channels are shared"
return None
if not count_shared:
if verbose:
return "No channels are shared"
return None
if output_priority == "not_shared" or (output_priority == "smart" and count_shared > count_total / 2):
output = ", ".join(sort_output(channels["not_shared"]))
append = ", not sharing"
else:
output = ", ".join(sort_output(channels["shared"]))
append = ""
return "Sharing {}/{} channels{}: {}".format(count_shared, count_total, append, output)
示例5: find_and_process_urls
def find_and_process_urls(string, use_color=True):
new_message = string
color = weechat.color(weechat.config_get_plugin("color"))
reset = weechat.color('reset')
for url in urlRe.findall(string):
max_url_length = int(weechat.config_get_plugin('urllength'))
if len(url) > max_url_length and not should_ignore_url(url):
short_url = get_shortened_url(url)
if use_color:
new_message = new_message.replace(
url, '%(url)s %(color)s[%(short_url)s]%(reset)s' % dict(
color=color,
short_url=short_url,
reset=reset,
url=url
)
)
else:
new_message = new_message.replace(url, short_url)
elif use_color:
# Highlight the URL, even if we aren't going to shorting it
new_message = new_message.replace(
url, '%(color)s %(url)s %(reset)s' % dict(
color=color,
reset=reset,
url=url
)
)
return new_message
示例6: screen_away_timer_cb
def screen_away_timer_cb(buffer, args):
'''Check if screen is attached, update awayness'''
global AWAY, SOCK
suffix = w.config_get_plugin('away_suffix')
attached = os.access(SOCK, os.X_OK) # X bit indicates attached
if attached and AWAY:
w.prnt('', '%s: Screen attached. Clearing away status' % SCRIPT_NAME)
for server, nick in get_servers():
w.command(server, "/away")
if suffix and nick.endswith(suffix):
nick = nick[:-len(suffix)]
w.command(server, "/nick %s" % nick)
AWAY = False
elif not attached and not AWAY:
w.prnt('', '%s: Screen detached. Setting away status' % SCRIPT_NAME)
for server, nick in get_servers():
if suffix:
w.command(server, "/nick %s%s" % (nick, suffix));
w.command(server, "/away %s" % w.config_get_plugin('message'));
AWAY = True
if w.config_get_plugin("command_on_detach"):
w.command("", w.config_get_plugin("command_on_detach"))
return w.WEECHAT_RC_OK
示例7: tts
def tts(text):
"""Pronounce the text"""
engine = weechat.config_get_plugin('tts_engine')
lang = weechat.config_get_plugin('language')
if engine == 'espeak':
args = {'arg1':text}
if lang:
args['arg2'] = '-v'
args['arg3'] = lang
hook = weechat.hook_process_hashtable('espeak',args,0,'my_process_cb','')
elif engine == 'festival':
args = {'stdin':'1', 'arg1':'festival', 'arg2':'--tts'}
if lang:
args['arg3'] = '--language'
args['arg4'] = lang
hook = weechat.hook_process_hashtable('festival',args,0,'my_process_cb','')
weechat.hook_set(hook, "stdin", text)
weechat.hook_set(hook, "stdin_close", "")
elif engine == 'picospeaker':
args = {'stdin':'1'}
if lang:
args['arg1'] = '-l'
args['arg2'] = lang
hook = weechat.hook_process_hashtable('picospeaker',args,0,'my_process_cb','')
weechat.hook_set(hook, "stdin", text)
weechat.hook_set(hook, "stdin_close", "")
示例8: customize_join_cb_signal
def customize_join_cb_signal(data, signal, signal_data):
weechat.prnt("","data: %s signal: %s signal_data: %s" % (data,signal,signal_data))
message = weechat.config_get_plugin('join_message')
if message == '':
return weechat.WEECHAT_RC_OK
parsed = get_hashtable(signal_data)
if parsed['nick'] == own_nick(signal.split(',', 1)[0]):
return weechat.WEECHAT_RC_OK
parsed['message'] = "" # dummy. no message for JOIN
parsed['kicked_nick'] = '' # dummy. no KICK here
message = create_output(message,parsed,'join')
buf_pointer = weechat.buffer_search('irc',"%s.%s" % (signal.split(',', 1)[0],parsed['channel']))
prefix = weechat.config_string(weechat.config_get('weechat.look.prefix_join'))
prefix_color = weechat.color(weechat.config_color(weechat.config_get('weechat.color.chat_prefix_join')))
message_tags = ''
if weechat.config_get_plugin('no_log').lower() == 'on':
message_tags = 'no_log'
weechat.prnt_date_tags(buf_pointer,0,message_tags,'%s%s\t%s' % (prefix_color,prefix,message))
return weechat.WEECHAT_RC_OK
示例9: spotify_print_cb
def spotify_print_cb(data, buffer, time, tags, displayed, highlight, prefix,
message):
notice = w.config_get_plugin('emit_notice')
buffer_name = w.buffer_get_string(buffer, "name")
server, channel = buffer_name.split('.')
buffers_to_check = w.config_get_plugin('buffers').split(',')
client_credentials_manager = SpotifyClientCredentials(
get_oauth('client_id'), get_oauth('client_secret'))
spotify = spotipy.Spotify(
client_credentials_manager=client_credentials_manager)
command = "msg"
if notice == "on":
command = "notice"
if buffer_name.lower() not in [
buffer.lower() for buffer in buffers_to_check
]:
return w.WEECHAT_RC_OK
for type, id in get_spotify_ids(message):
if type == 'album':
results = spotify.album(id)
elif type == 'track':
results = spotify.track(id)
elif type == 'artist':
results = spotify.artist(id)
reply = parse_response(results, type)
w.command('', "/%s -server %s %s %s" % (command, server, channel,
reply))
return w.WEECHAT_RC_OK
示例10: customize_part_cb
def customize_part_cb(data, modifier, modifier_data, string):
message = weechat.config_get_plugin('part_message')
if message == '':
return string
parsed = get_hashtable(string)
if parsed['nick'] == own_nick(modifier_data):
return string
parsed['kicked_nick'] = '' # dummy. no irc_KICK here
message = create_output(message,parsed,'part')
if OPTIONS['debug'] == 'on':
weechat.prnt("","debug mode: irc_part")
weechat.prnt("","string: %s" % string)
weechat.prnt("",parsed['channel'])
weechat.prnt("",parsed['message'])
buf_pointer = weechat.buffer_search('irc',"%s.%s" % (modifier_data,parsed['channel']))
prefix = weechat.config_string(weechat.config_get('weechat.look.prefix_quit'))
prefix_color = weechat.color(weechat.config_color(weechat.config_get('weechat.color.chat_prefix_quit')))
prefix = substitute_colors(prefix)
message_tags = ''
if weechat.config_get_plugin('no_log').lower() == 'on':
message_tags = 'no_log'
weechat.prnt_date_tags(buf_pointer,0,message_tags,'%s%s\t%s' % (prefix_color,prefix,message))
return string
示例11: customize_kick_cb
def customize_kick_cb(data, modifier, modifier_data, string):
message = weechat.config_get_plugin('kick_message')
if message == '':
return string
parsed = get_hashtable(string)
try:
parsed['kicked_nick'] = parsed['arguments'].split(' ', 1)[1]
parsed['kicked_nick'] = parsed['kicked_nick'].split(' :', 1)[0]
except:
parsed['kicked_nick'] = ''
message = create_output(message,parsed,'kick')
if OPTIONS['debug'] == 'on':
weechat.prnt("",string)
weechat.prnt("",parsed['channel'])
weechat.prnt("",parsed['message'])
buf_pointer = weechat.buffer_search('irc',"%s.%s" % (modifier_data,parsed['channel']))
prefix = weechat.config_string(weechat.config_get('weechat.look.prefix_quit'))
prefix_color = weechat.color(weechat.config_color(weechat.config_get('weechat.color.chat_prefix_quit')))
message_tags = ''
if weechat.config_get_plugin('no_log').lower() == 'on':
message_tags = 'no_log'
weechat.prnt_date_tags(buf_pointer,0,message_tags,'%s%s\t%s' % (prefix_color,prefix,message))
return string
示例12: decrypt
def decrypt(data, msgtype, servername, args):
hostmask, chanmsg = string.split(args, "PRIVMSG ", 1)
channelname, message = string.split(chanmsg, " :", 1)
if re.match(r'^\[\d{2}:\d{2}:\d{2}]\s', message):
timestamp = message[:11]
message = message[11:]
else:
timestamp = ''
if channelname[0] == "#":
username=channelname
else:
username, rest = string.split(hostmask, "!", 1)
username = username[1:]
if os.path.exists(weechat_dir + "/cryptkey." + username):
p = subprocess.Popen(["openssl", "enc", "-d", "-a", "-" + weechat.config_get_plugin("cipher"), "-pass" ,"file:" + weechat_dir + "/cryptkey." + username], bufsize=4096, stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True)
p.stdin.write("U2FsdGVkX1" + message.replace("|","\n"))
p.stdin.close()
decrypted = p.stdout.read()
p.stdout.close()
if decrypted == "":
return args
decrypted = ''.join(c for c in decrypted if ord(c) > 31 or ord(c) == 9 or ord(c) == 2 or ord(c) == 3 or ord(c) == 15)
return hostmask + "PRIVMSG " + channelname + " :" + chr(3) + "04" + weechat.config_get_plugin("message_indicator") + chr(15) + timestamp + decrypted
else:
return args
示例13: notify_show
def notify_show(data, bufferp, uber_empty, tagsn, isdisplayed,
ishilight, prefix, message):
#are we away?
away = weechat.buffer_get_string(bufferp,"localvar_away")
if (away == "" and weechat.config_get_plugin("only_away") == "on"):
return weechat.WEECHAT_RC_OK
#get local nick for buffer
mynick = weechat.buffer_get_string(bufferp,"localvar_nick")
# get name of buffer
name = weechat.buffer_get_string(bufferp,"name")
# ignore buffers on ignorelist
if not name in weechat.config_get_plugin("ignore").split(","):
# only notify if the message was not sent by myself
if (weechat.buffer_get_string(bufferp, "localvar_type") == "private") and (prefix!=mynick):
show_notification(prefix, prefix, message)
elif ishilight == "1":
buffer = (weechat.buffer_get_string(bufferp, "short_name") or name)
show_notification(buffer, prefix, message)
return weechat.WEECHAT_RC_OK
示例14: keydict_update
def keydict_update(*args):
'''Populate a python dictionary with relevant key=>buffer mappings.'''
global keydict
keylist = w.infolist_get('key', '', '')
if w.config_get_plugin('use_keybindings') == 'on':
while w.infolist_next(keylist):
key = w.infolist_string(keylist, 'key')
# we dont want jump sequences
if 'j' in key:
continue
key = key.replace('meta-', '')
key = key.replace('ctrl-', '^')
if w.config_get_plugin('skip_number_binds') == 'on':
# skip entries where buffer number = key, typically entries below 11
if key.isdigit():
continue
command = w.infolist_string(keylist, 'command')
# we only care about commands that leads to buffers
if command.startswith('/buffer'):
command = command.replace('/buffer ', '')
buffer = command.lstrip('*')
keydict[buffer] = key
w.infolist_free(keylist)
return w.WEECHAT_RC_OK
示例15: vdm_display
def vdm_display(vdm):
""" Display VDMs in buffer. """
global vdm_buffer
weechat.buffer_set(vdm_buffer, "unread", "1")
if weechat.config_get_plugin("number_as_prefix") == "on":
separator = "\t"
else:
separator = " > "
colors = weechat.config_get_plugin("colors").split(";");
vdm2 = vdm[:]
if weechat.config_get_plugin("reverse") == "on":
vdm2.reverse()
for index, item in enumerate(vdm2):
item_id = item["id"]
item_text = item["text"]
if sys.version_info < (3,):
# python 2.x: convert unicode to str (in python 3.x, id and text are already strings)
item_id = item_id.encode("UTF-8")
item_text = item_text.encode("UTF-8")
weechat.prnt_date_tags(vdm_buffer,
0, "notify_message",
"%s%s%s%s%s" %
(weechat.color(weechat.config_get_plugin("color_number")),
item_id,
separator,
weechat.color(colors[0]),
item_text))
colors.append(colors.pop(0))
if index == len(vdm) - 1:
weechat.prnt(vdm_buffer, "------")
elif weechat.config_get_plugin("blank_line") == "on":
weechat.prnt(vdm_buffer, "")