本文整理汇总了Python中weechat.buffer_get_string函数的典型用法代码示例。如果您正苦于以下问题:Python buffer_get_string函数的具体用法?Python buffer_get_string怎么用?Python buffer_get_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了buffer_get_string函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: priv_msg_cb
def priv_msg_cb(data, bufferp, uber_empty, tagsn, isdisplayed,
ishilight, prefix, message):
"""Sends highlighted message to be printed on notification"""
am_away = w.buffer_get_string(bufferp, 'localvar_away')
if not am_away:
w.prnt("", "[weebullet] Not away, skipping notification")
return w.WEECHAT_RC_OK
notif_body = u"<%s> %s" % (
prefix.decode('utf-8'),
message.decode('utf-8')
)
# Check that it's in a "/q" buffer and that I'm not the one writing the msg
is_pm = w.buffer_get_string(bufferp, "localvar_type") == "private"
is_notify_private = re.search(r'(^|,)notify_private(,|$)', tagsn) is not None
# PM (query)
if (is_pm and is_notify_private):
send_push(
title="Privmsg from %s" % prefix.decode('utf-8'),
body=notif_body
)
# Highlight (your nick is quoted)
elif (ishilight == "1"):
bufname = (w.buffer_get_string(bufferp, "short_name") or
w.buffer_get_string(bufferp, "name"))
send_push(
title="Highlight in %s" % bufname.decode('utf-8'),
body=notif_body
)
return w.WEECHAT_RC_OK
开发者ID:halkeye,项目名称:weebullet,代码行数:35,代码来源:weebullet.py
示例2: buffer_opened_cb
def buffer_opened_cb(data, signal, signal_data):
ptr_buffer = signal_data
plugin = weechat.buffer_get_string(ptr_buffer, 'localvar_plugin')
name = weechat.buffer_get_string(ptr_buffer, 'localvar_name')
filename = get_filename_with_path('%s.%s' % (plugin,name))
read_history(filename,ptr_buffer)
return weechat.WEECHAT_RC_OK
开发者ID:weechatter,项目名称:weechat-scripts,代码行数:7,代码来源:histman.py
示例3: unread_cb
def unread_cb(data, buffer, command):
global all_channels
channels = []
if command.find("set_unread_current_buffer") >= 0:
if w.buffer_get_string(buffer, "localvar_server") == "slack" and \
w.buffer_get_string(buffer, "localvar_type") in ["channel", "private"]:
channels.append(w.buffer_get_string(buffer, "localvar_channel"))
else:
channels = _channels()
for c in channels:
cs = c.lstrip("#")
if cs in all_channels:
try:
if c.startswith("#"):
if cs in private_groups:
r = slack.groups.mark(all_channels[cs], time.time())
else:
r = slack.channels.mark(all_channels[cs], time.time())
else:
r = slack.im.mark(all_channels[cs], time.time())
#w.prnt("", "%s: %s" % (c, r.body["ok"] and "ok" or "not ok"))
except:
w.prnt("", "Error while setting unread marker on %s" % c)
w.prnt("", "%d channels marked as read" % len(channels))
return w.WEECHAT_RC_OK
开发者ID:palbo,项目名称:dotfiles,代码行数:27,代码来源:slack.py
示例4: allquery_command_cb
def allquery_command_cb(data, buffer, args):
""" Callback for /allquery command """
args = args.strip()
if args == "":
weechat.command("", "/help %s" % SCRIPT_COMMAND)
return weechat.WEECHAT_RC_OK
argv = args.split(" ")
exclude_nick = None
if argv[0].startswith("-exclude="):
exclude_nick = make_list(argv[0])
command = " ".join(argv[1::])
else:
command = args
if not command.startswith("/"):
weechat.command("", "/help %s" % SCRIPT_COMMAND)
return weechat.WEECHAT_RC_OK
infolist = weechat.infolist_get("buffer", "", "")
while weechat.infolist_next(infolist):
if weechat.infolist_string(infolist, "plugin_name") == "irc":
ptr = weechat.infolist_pointer(infolist, "pointer")
server = weechat.buffer_get_string(ptr, "localvar_server")
query = weechat.buffer_get_string(ptr, "localvar_channel")
execute_command = re.sub(r'\b\$nick\b', query, command)
if weechat.buffer_get_string(ptr, "localvar_type") == "private":
if exclude_nick is not None:
if not query in exclude_nick:
weechat.command(ptr, execute_command)
else:
weechat.command(ptr, execute_command)
weechat.infolist_free(infolist)
return weechat.WEECHAT_RC_OK
开发者ID:fbesser,项目名称:weechat_scripts,代码行数:34,代码来源:allquery.py
示例5: notification_callback
def notification_callback(data, bufferp, uber_empty, tagsn, isdisplayed, ishilight, prefix, message):
is_away = weechat.buffer_get_string(bufferp, 'localvar_away')
is_focused = bufferp == weechat.current_buffer()
do_prowl = True # If set to False depending on state and settings, no Prowl notification will be sent
if (is_away):
if (is_focused and weechat.config_get_plugin('notify_focused_away') != 'on'):
do_prowl = False
elif (not is_focused and weechat.config_get_plugin('notify_unfocused_away') != 'on'):
do_prowl = False
else:
if (is_focused and weechat.config_get_plugin('notify_focused_active') != 'on'):
do_prowl = False
elif (not is_focused and weechat.config_get_plugin('notify_unfocused_active') != 'on'):
do_prowl = False
if (do_prowl):
if (weechat.buffer_get_string(bufferp, 'localvar_type') == 'private' and weechat.config_get_plugin('show_priv_msg') == 'on' and prefix != weechat.buffer_get_string(bufferp, 'localvar_nick')):
send_prowl_notification(prefix, message, True)
elif (ishilight == '1' and weechat.config_get_plugin('show_hilights') == 'on'):
buffer = (weechat.buffer_get_string(bufferp, 'short_name') or weechat.buffer_get_string(bufferp, 'name'))
send_prowl_notification(buffer, prefix + weechat.config_get_plugin('nick_separator') + message, False)
return weechat.WEECHAT_RC_OK
开发者ID:KokaKiwi,项目名称:weechat-scripts,代码行数:25,代码来源:weeprowl.py
示例6: prepare_notification
def prepare_notification(buffer, is_highlight, nick, message):
"""Prepares a notification from the given data."""
if is_highlight:
source = (weechat.buffer_get_string(buffer, 'short_name') or
weechat.buffer_get_string(buffer, 'name'))
message = nick + nick_separator() + message
else:
# A private message.
source = nick
max_length = int(weechat.config_get_plugin('max_length'))
if max_length > 0:
ellipsis = weechat.config_get_plugin('ellipsis')
message = shorten_message(message, max_length, ellipsis)
if weechat.config_get_plugin('escape_html') == 'on':
message = escape_html(message)
message = escape_slashes(message)
icon = weechat.config_get_plugin('icon')
timeout = weechat.config_get_plugin('timeout')
urgency = weechat.config_get_plugin('urgency')
return Notification(source, message, icon, timeout, urgency)
开发者ID:craigcabrey,项目名称:dotfiles,代码行数:25,代码来源:notify_send.py
示例7: twitch_buffer_switch
def twitch_buffer_switch(data, signal, signal_data):
server = weechat.buffer_get_string(signal_data, 'localvar_server')
type = weechat.buffer_get_string(signal_data, 'localvar_type')
if not (server in OPTIONS['servers'].split() and type == 'channel'):
return weechat.WEECHAT_RC_OK
twitch_main('', signal_data, 'bs')
return weechat.WEECHAT_RC_OK
开发者ID:MatthewCox,项目名称:dotfiles,代码行数:7,代码来源:twitch.py
示例8: show_item
def show_item(data, item, window):
bufpointer = weechat.window_get_pointer(window, "buffer")
if bufpointer == "":
return ""
if weechat.buffer_get_string(bufpointer, "name") != "weechat": # not weechat core buffer
if weechat.buffer_get_string(bufpointer, "localvar_type") == "": # buffer with free content?
return ""
lines_after, lines_count, percent, current_line = count_lines(window, bufpointer)
if lines_count == 0: # buffer empty?
return ""
tags = {"%C": str(current_line), "%A": str(lines_after), "%L": str(lines_count), "%P": str(percent) + "%"}
bufsize_item = substitute_colors(OPTIONS["format"])
# replace mandatory tags
for tag in list(tags.keys()):
# for tag in tags.keys():
bufsize_item = bufsize_item.replace(tag, tags[tag])
# replace optional tags
# %{…} only if lines after (e.g. %A > 0)
if lines_after > 0:
for regex_tag in regex_optional_tags.findall(bufsize_item):
bufsize_item = bufsize_item.replace(regex_tag, regex_tag.lstrip("%{").rstrip("}"))
else:
bufsize_item = regex_optional_tags.sub("", bufsize_item)
return bufsize_item
开发者ID:Ratler,项目名称:weechatter-weechat-scripts,代码行数:32,代码来源:bufsize.py
示例9: 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
开发者ID:balu-,项目名称:weechat-irssinotifier,代码行数:25,代码来源:irssinotifier.py
示例10: get_buffer_info
def get_buffer_info(buf):
server = weechat.buffer_get_string(buf, b'localvar_server').decode(
'utf-8', 'replace')
channel = weechat.buffer_get_string(buf, b'localvar_channel').decode(
'utf-8', 'replace')
return server, channel
开发者ID:mutantmonkey,项目名称:weesodium,代码行数:7,代码来源:weesodium.py
示例11: word_magic
def word_magic(data, buffer, command):
# get the input string
uinput = w.buffer_get_string(buffer, "input")
# if the buffer is blacklisted, do nothing
if w.buffer_get_string(buffer, "short_name") in w.config_get_plugin(
"blacklist_buffers").split(","):
return w.WEECHAT_RC_OK
if command == "/input return":
# in case the line's empty, do nothing
if uinput == "":
return w.WEECHAT_RC_OK
# bypass this using a backslash as the first character
elif uinput.startswith("\\"):
uinput = uinput.replace("\\", "", 1)
# we don't want to capitalize basic URLs
elif uinput[:4] == "http": # I'M TOO LAZY FOR REGEX MATCHING
return w.WEECHAT_RC_OK
# if we point to a user, don't capitalise this
elif isnick(buffer, uinput.split()[0][:-1]):
return w.WEECHAT_RC_OK
# if everything else is fine, replace the first char with its capital
else:
uinput = uinput.replace(uinput[0], uinput[0].upper(), 1)
# set the new string into the input
w.buffer_set(buffer, "input", uinput)
return w.WEECHAT_RC_OK
开发者ID:vlad-s,项目名称:weechat-plugins,代码行数:28,代码来源:auto_capital.py
示例12: check_buffer_type
def check_buffer_type(window, data, value):
bufpointer = weechat.window_get_pointer(window,"buffer")
if bufpointer == "":
return ""
value = value.split(' ', 1)
if len(value) <= 1:
return ""
# format is : buffer_type (channel,server,private,all) | signal (e.g: buffer_switch)
channel_type_and_signal = value[0]
if channel_type_and_signal.find('|') >= 0:
channel_type = channel_type_and_signal[0:channel_type_and_signal.find("|")]
signal_type = channel_type_and_signal[channel_type_and_signal.find("|")+1:]
unhook(data)
add_hook(signal_type, data)
else:
channel_type = value[0]
value = value[1]
if channel_type == 'all' or weechat.buffer_get_string(bufpointer,'localvar_type') == channel_type:
return value
if channel_type == '!all':
a = ["channel","server","private"]
if weechat.buffer_get_string(bufpointer,'localvar_type') in a:
return value
return ""
开发者ID:weechatter,项目名称:weechat-scripts,代码行数:28,代码来源:text_item.py
示例13: notify_show
def notify_show(data, bufferp, uber_empty, tagsn, isdisplayed,
ishighlight, prefix, message):
if weechat.config_get_plugin("enabled") == "off":
return weechat.WEECHAT_RC_OK
# get local nick for buffer
mynick = weechat.buffer_get_string(bufferp, "localvar_nick")
# strip channel op prefix
stripped_prefix = prefix.replace("@", "")
# check if we should not notify on this channel/nick priv_msg
channel = weechat.buffer_get_string(bufferp, "localvar_channel")
exclude_channels = weechat.config_get_plugin("exclude_channels").split(',')
if channel in exclude_channels:
return weechat.WEECHAT_RC_OK
always_notify_channels = weechat.config_get_plugin("always_notify_channels").split(',')
# only notify if the message was not sent by myself
if (weechat.buffer_get_string(bufferp, "localvar_type") == "private" and
stripped_prefix != mynick and
weechat.config_get_plugin("show_priv_msg") == "on"):
show_notification(prefix, prefix, message)
# notify on hilight or in always notifying channel and not sent by myself
elif (ishighlight == "1" and weechat.config_get_plugin("show_highlight") == "on") or \
(channel in always_notify_channels and stripped_prefix != mynick):
buf = (weechat.buffer_get_string(bufferp, "short_name") or
weechat.buffer_get_string(bufferp, "name"))
show_notification(buf, prefix, message)
return weechat.WEECHAT_RC_OK
开发者ID:kramimus,项目名称:weechat-pushover,代码行数:35,代码来源:pushover.py
示例14: get_notified
def get_notified(data, bufferp, uber_empty, tagsn, isdisplayed,
ishilight, prefix, message):
if (weechat.buffer_get_string(bufferp, "localvar_type") == "private" and
weechat.config_get_plugin('show_priv_msg') == "on"):
buffer = (weechat.buffer_get_string(bufferp, "short_name") or
weechat.buffer_get_string(bufferp, "name"))
if buffer == prefix:
n = pynotify.Notification("WeeChat", "%s said: %s" % (prefix,
message),weechat.config_get_plugin('show_icon'))
Popen("/usr/bin/python2.7 /usr/share/weetray/main.py", shell=True)
if not n.show():
print "Failed to send notification"
elif (ishilight == "1" and
weechat.config_get_plugin('show_highlight') == "on"):
buffer = (weechat.buffer_get_string(bufferp, "short_name") or
weechat.buffer_get_string(bufferp, "name"))
n = pynotify.Notification("WeeChat", "In %s, %s said: %s" % (buffer,
prefix, message),weechat.config_get_plugin('show_icon'))
Popen("/usr/bin/python2.7 /usr/share/weetray/main.py", shell=True)
if not n.show():
print "Failed to send notification"
return weechat.WEECHAT_RC_OK
开发者ID:eayin2,项目名称:weetray,代码行数:25,代码来源:lnotify.py
示例15: check_buffer_timer_cb
def check_buffer_timer_cb(data, remaining_calls):
global WEECHAT_VERSION,whitelist
# search for buffers in hotlist
ptr_infolist = weechat.infolist_get("hotlist", "", "")
while weechat.infolist_next(ptr_infolist):
ptr_buffer = weechat.infolist_pointer(ptr_infolist, "buffer_pointer")
localvar_name = weechat.buffer_get_string(ptr_buffer, 'localvar_name')
# buffer in whitelist? go to next buffer
buf_type = weechat.buffer_get_string(ptr_buffer,'localvar_type')
# buffer is a query buffer?
if OPTIONS['ignore_query'].lower() == 'on' and buf_type == 'private':
continue
# buffer in whitelist?
if localvar_name in whitelist:
continue
if ptr_buffer:
if get_time_from_line(ptr_buffer):
if OPTIONS['clear'].lower() == 'hotlist' or OPTIONS['clear'].lower() == 'all':
weechat.buffer_set(ptr_buffer, "hotlist", '-1')
if OPTIONS['clear'].lower() == 'unread' or OPTIONS['clear'].lower() == 'all':
weechat.command(ptr_buffer,"/input set_unread_current_buffer")
weechat.infolist_free(ptr_infolist)
return weechat.WEECHAT_RC_OK
开发者ID:DarkDefender,项目名称:scripts,代码行数:25,代码来源:automarkbuffer.py
示例16: at_completion
def at_completion(data, buffer, command):
if not config['enable']:
return weechat.WEECHAT_RC_OK
input = weechat.buffer_get_string(buffer, 'input')
if input[0] != '/':
buffer_name = weechat.buffer_get_string(buffer,'name')
plugin_name = weechat.buffer_get_string(buffer,'plugin')
# don't nick complete in core
if plugin_name == 'core': return weechat.WEECHAT_RC_OK
server_name = buffer_name.split('.')[0]
if (server_name not in config['servers']
or not check_buffers(buffer_name) ):
return weechat.WEECHAT_RC_OK
pos = weechat.buffer_get_integer(buffer, 'input_pos')
if pos > 0 and (pos == len(input) or input[pos] == ' '):
n = input.rfind(' ', 0, pos)
e = input.find(' ',n)
at = 0
word = input[n+1:pos]
if e != n :
word = word[:e]
if word[0] == '@':
word = word[1:]
at = 1
nicklist = weechat.infolist_get('nicklist', buffer, '')
if nicklist:
nick = walk_nicklist(nicklist,word)
if nick != "":
complete = '%[email protected]%s %s' %(input[:pos-len(word)-at],nick,input[pos:])
weechat.buffer_set(buffer, 'input', complete)
weechat.buffer_set(buffer, 'input_pos', str(pos - len(word) + len(nick)+2))
return weechat.WEECHAT_RC_OK_EAT
return weechat.WEECHAT_RC_OK
开发者ID:WarheadsSE,项目名称:weechat-atcompletion,代码行数:34,代码来源:at_completion.py
示例17: names_for_buffer
def names_for_buffer(buffer):
"""Returns a list of all names for the given buffer."""
# The 'buffer' parameter passed to our callback is actually the buffer's ID
# (e.g. '0x2719cf0'). We have to check its name (e.g. 'freenode.#weechat')
# and short name (e.g. '#weechat') because these are what users specify in
# their configs.
buffer_names = []
full_name = weechat.buffer_get_string(buffer, 'name')
if full_name:
buffer_names.append(full_name)
short_name = weechat.buffer_get_string(buffer, 'short_name')
if short_name:
buffer_names.append(short_name)
# Consider >channel and #channel to be equal buffer names. The reason
# is that the https://github.com/rawdigits/wee-slack plugin replaces
# '#' with '>' to indicate that someone in the buffer is typing. This
# fixes the behavior of several configuration options (e.g.
# 'tts_on_all_messages_in_buffers') when weechat_notify_send is used
# together with the wee_slack plugin.
#
# Note that this is only needed to be done for the short name. Indeed,
# the full name always stays unchanged.
if short_name.startswith('>'):
buffer_names.append('#' + short_name[1:])
return buffer_names
开发者ID:DarkDefender,项目名称:scripts,代码行数:28,代码来源:tts.py
示例18: handle_msg
def handle_msg(data, pbuffer, date, tags, displayed, highlight, prefix, message):
highlight = bool(highlight) and cfg["highlight"]
query = true[cfg["query"]]
notify_away = true[cfg["notify_away"]]
buffer_type = weechat.buffer_get_string(pbuffer, "localvar_type")
away = weechat.buffer_get_string(pbuffer, "localvar_away")
x_focus = False
window_name = ""
# Check to make sure we're in X and xdotool exists.
# This is kinda crude, but I'm no X master.
if (environ.get('DISPLAY') != None) and path.isfile("/bin/xdotool"):
window_name = subprocess.check_output(["xdotool", "getwindowfocus", "getwindowname"])
if "WeeChat" in window_name:
x_focus = True
if pbuffer == weechat.current_buffer() and x_focus:
return weechat.WEECHAT_RC_OK
if away and not notify_away:
return weechat.WEECHAT_RC_OK
buffer_name = weechat.buffer_get_string(pbuffer, "short_name")
if buffer_type == "private" and query:
notify_user(buffer_name, message)
elif buffer_type == "channel" and highlight:
notify_user("{} @ {}".format(prefix, buffer_name), message)
return weechat.WEECHAT_RC_OK
开发者ID:Shrews,项目名称:scripts,代码行数:32,代码来源:lnotify.py
示例19: notify
def notify(data, buffer, timestamp, tags, displayed, highlighted, prefix, message):
buffer_name = weechat.buffer_get_string(buffer, 'name')
buffer_type = weechat.buffer_get_string(buffer, 'localvar_type')
server = weechat.buffer_get_string(buffer, 'localvar_server')
message = None
if buffer_type not in ['private', 'channel']:
return weechat.WEECHAT_RC_OK
if buffer_type == 'channel' and highlighted == 0:
return weechat.WEECHAT_RC_OK
if buffer_type == 'private':
message = '{nick} sent you a private message on {server}'.format(nick=prefix, server=server)
elif buffer_type == 'channel':
channel = buffer_name.split('.', 1)[1]
message = '{nick} mentioned you in {channel}'.format(nick=prefix, channel=channel)
if message == None:
return weechat.WEECHAT_RC_OK
process_endpoint = 'url:https://api.pushover.net:443/1/messages.json'
post_data = urllib.urlencode({
'token': OPTIONS['apptoken'],
'user': OPTIONS['userkey'],
'sound': OPTIONS['sound'],
'message': message,
})
weechat.hook_process_hashtable(process_endpoint, { 'post': '1', 'postfields': post_data }, OPTIONS['timeout'], 'message_sent', '')
return weechat.WEECHAT_RC_OK
开发者ID:lewiseason,项目名称:weechat-scripts,代码行数:34,代码来源:notify_pushover.py
示例20: opall
def opall(data, buffer, args):
channel = weechat.buffer_get_string(buffer, 'localvar_channel')
server = weechat.buffer_get_string(buffer, 'localvar_server')
if not weechat.info_get('irc_is_channel', channel):
weechat.prnt(buffer, '%sopall: Not an IRC channel' % weechat.prefix('error'))
return weechat.WEECHAT_RC_OK
toOp = withoutOp(server, channel)
if len(toOp) == 0:
return weechat.WEECHAT_RC_OK
# how many people can we op at once
modes = int(weechat.info_get('irc_server_isupport_value', '%s,MODES' % server)) or 0
if modes == 0:
weechat.prnt(buffer, '%sopall: failed to determine MODES' % weechat.prefix('error'))
return weechat.WEECHAT_RC_ERROR
frm = 0
to = modes
while len(toOp) > frm:
weechat.command(buffer, '/OP %s' % ' '.join(toOp[frm:to]))
frm = to
to += modes
return weechat.WEECHAT_RC_OK
开发者ID:KokaKiwi,项目名称:weechat-scripts,代码行数:26,代码来源:opall.py
注:本文中的weechat.buffer_get_string函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论