本文整理汇总了Python中weechat.info_get函数的典型用法代码示例。如果您正苦于以下问题:Python info_get函数的具体用法?Python info_get怎么用?Python info_get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了info_get函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: 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
示例2: print_as_list
def print_as_list(target, matches, data, limit, total):
"""Prints the output as a comma-separated list of nicks."""
col = w.color(w.info_get("irc_nick_color_name", data["setter"]))
pf = fmt_prefix(data).replace("_target_", "")
s = "{}\tThe following {} {}"
if data["mode"] == "special":
w.prnt(target, s.format(pf, "nick matches" if total == 1 else "nicks match", fmt_banmask(data["mask"])))
else:
w.prnt(target, (s + ", {} by {}{}{}").format(
pf, "nick matches" if total == 1 else "nicks match",
fmt_banmask(data["mask"]), fmt_mode_char(data["mode"]), col,
data["setter"], w.color("reset")
))
nicks = []
remainder = len(matches) - limit
i = 0
for name in matches:
nicks.append("{}{}{}".format(w.color(w.info_get("irc_nick_color_name", name)), name, w.color("reset")))
i += 1
if i >= limit:
break
if w.config_string(w.config_get("weechat.look.prefix_same_nick")):
pf = (w.color(w.config_get_plugin("prefix_color")) +
w.config_string(w.config_get("weechat.look.prefix_same_nick")) +
w.color("reset"))
printstr = "{}\t{}".format(pf, ", ".join(nicks))
if remainder > 0:
printstr += ", and {} more..".format(remainder)
w.prnt(target, printstr)
示例3: responsive_cb
def responsive_cb(data, signal, signal_data):
term_height = int(weechat.info_get("term_height", ""))
term_width = int(weechat.info_get("term_width", ""))
try:
apply_layout = None
for layout, width, height in LAYOUT_LIST:
if term_height <= int(height) or term_width <= int(width):
apply_layout = layout
break
if apply_layout is None:
# Always apply the last layout if term width/height is larger than configured layouts
apply_layout = LAYOUT_LIST[-1][0]
if layout_exist(apply_layout) and not layout_current(apply_layout):
_print("Applying layout %s" % apply_layout)
weechat.command("", "/layout apply %s" % apply_layout)
toggle_nick_list(apply_layout)
weechat.bar_item_update("rlayout")
except ValueError:
_print("Height or width is not in number form, ignoring.")
return weechat.WEECHAT_RC_OK
示例4: wu_cond
def wu_cond(data, command, return_code, out, err):
if return_code == weechat.WEECHAT_HOOK_PROCESS_ERROR:
weechat.prnt("", "Error with command '%s'" % command)
return weechat.WEECHAT_RC_OK
if return_code > 0:
weechat.prnt("", "return_code = %d" % return_code)
if err != "":
weechat.prnt("", "stderr: %s" % err)
if out != "":
j = ast.literal_eval(out)
try:
jcheck = j['response']['error']['type']
if j['response']['error']['type'] == "invalidquery":
reaction = "Error. Try again."
rtnbuf = kserver + "," + kchannel
buffer = weechat.info_get("irc_buffer", rtnbuf)
weechat.command(buffer, "/msg " + kchannel + " " + reaction)
return weechat.WEECHAT_RC_OK
if j['response']['error']['type'] == "keynotfound":
weechat.prnt("", "Invalid API key.")
return weechat.WEECHAT_RC_OK
except KeyError:
pass
co = 'current_observation'
reaction = '[' + jname + '] ' + j[co]['weather'] + '. Temp is '
if units == "metric":
windspeed = j[co]['wind_kph']
temp = j[co]['temp_c']
like = j[co]['feelslike_c']
if str(temp) == str(like):
reaction += str(temp) + "*C"
else:
reaction += str(temp) + "*C but feels like " + str(like) + "*C"
if windspeed > 0:
reaction += '. '
reaction += str(j[co]['wind_dir']) + ' wind: ' + str(windspeed) + ' kph'
else:
windspeed = j[co]['wind_mph']
temp = j[co]['temp_f']
like = j[co]['feelslike_f']
if str(temp) == str(like):
reaction += str(temp) + "*F"
else:
reaction += str(temp) + "*F but feels like " + str(like) + "*F"
if windspeed > 0:
reaction += '. '
reaction += str(j[co]['wind_dir']) + ' wind: ' + str(windspeed) + ' mph'
humid = j[co]['relative_humidity']
if int(humid[:-1]) > 50:
reaction += '. Humidity: ' + j[co]['relative_humidity']
reaction += '.'
rtnbuf = kserver + "," + kchannel
buffer = weechat.info_get("irc_buffer", rtnbuf)
weechat.command(buffer, "/msg " + kchannel + " " + reaction)
return weechat.WEECHAT_RC_OK
示例5: join_cb
def join_cb(data, signal, signal_data):
nick = weechat.info_get("irc_nick_from_host", signal_data)
server = signal.split(",")[0]
channel = signal_data.split(":")[-1]
buffer = weechat.info_get("irc_buffer", "%s,%s" % (server, channel))
if buffer:
weechat.prnt(buffer, "Eheh, %s has joined this channel!" % nick)
return weechat.WEECHAT_RC_OK
示例6: on_join_scan_cb
def on_join_scan_cb(data, signal, signal_data):
network = signal.split(',')[0]
if network in OPTIONS['hooks.excluded_servers'].split(','):
return weechat.WEECHAT_RC_OK
joined_nick = weechat.info_get("irc_nick_from_host", signal_data)
join_match_data = re.match(':[^!]+!([^@][email protected](\S+)) JOIN :?([#&]\S*)', signal_data)
parsed_ident_host = join_match_data.group(1).lower()
parsed_host = join_match_data.group(2).lower()
if OPTIONS["compare_idents"] == "on":
hostkey = parsed_ident_host
else:
hostkey = parsed_host
chan_name = join_match_data.group(3)
network_chan_name = "%s.%s" % (network, chan_name)
chan_buffer = weechat.info_get("irc_buffer", "%s,%s" % (network, chan_name))
if not chan_buffer:
print "No IRC channel buffer found for %s" % network_chan_name
return weechat.WEECHAT_RC_OK
if OPTIONS["display_join_messages"] == "on":
message = "%s%s%s%s%s" % (
format_from_config(joined_nick, "colors.join_messages.nick"),
format_from_config("!", "colors.join_messages.message"),
format_from_config(parsed_ident_host, "colors.join_messages.identhost"),
format_from_config(" JOINed ", "colors.join_messages.message"),
format_from_config(network_chan_name, "colors.join_messages.channel"),
)
#Make sure message format is also applied if no formatting is given for nick
message = format_from_config(message, "colors.join_messages.message")
weechat.prnt(cs_get_buffer(), message)
clones = get_clones_for_buffer("%s,%s" % (network, chan_name), hostkey)
if clones:
key = get_validated_key_from_config("clone_onjoin_alert_key")
filtered_clones = filter(lambda clone: clone['nick'] != joined_nick, clones[hostkey])
match_strings = map(lambda m: format_from_config(m[key], "colors.onjoin_alert.matches"), filtered_clones)
join_string = format_from_config(' and ',"colors.onjoin_alert.message")
masks = join_string.join(match_strings)
message = "%s %s %s %s %s" % (
format_from_config(joined_nick, "colors.onjoin_alert.nick"),
format_from_config("is already on", "colors.onjoin_alert.message"),
format_from_config(network_chan_name, "colors.onjoin_alert.channel"),
format_from_config("as", "colors.onjoin_alert.message"),
masks
)
message = format_from_config(message, 'colors.onjoin_alert.message')
if OPTIONS["display_onjoin_alert_clone_buffer"] == "on":
weechat.prnt(cs_get_buffer(),message)
if OPTIONS["display_onjoin_alert_target_buffer"] == "on":
weechat.prnt(chan_buffer, message)
if OPTIONS["display_onjoin_alert_current_buffer"] == "on":
weechat.prnt(weechat.current_buffer(),message)
return weechat.WEECHAT_RC_OK
示例7: handle_query
def handle_query(data, signal, signal_data):
global buffer_data
# data: empty string
# signal: <server>,irc_in_PRIVMSG
# signal_data: whole message unparsed
# parse the message
parsed = weechat.info_get_hashtable("irc_message_parse",
{"message": signal_data})
# where should we answer?
server = signal.split(",")[0]
channel = parsed["channel"]
current_nick = weechat.info_get("irc_nick", server)
user = parsed["nick"]
message = parsed["text"]
if channel == current_nick:
# we got a message through a private query, refuse it
buffer_out = weechat.info_get("irc_buffer", server + "," + user)
# close private buffers, but not server buffers
# localvar_type can assume five values: private, channel, server, weechat and ""
if weechat.buffer_get_string(buffer_out,"localvar_type") == "private":
weechat.command(buffer_out, "How about speaking to me in public?")
weechat.buffer_close(buffer_out)
else:
# query came from public channel
if message.startswith(current_nick + ":"): # it's a command to our bot
query = message.split(":")[1].strip() # remove the part before the colon, and lead/trail whitespaces
s = query.split(" ", 1)
command = s[0].lower() # command is case-insensitive
args = s[1] if len(s) == 2 else ""
target = "{0},{1}".format(server, channel) # this is the key to the dict containing the lists
if command == "coin":
out_msg = _coin()
elif command == "help":
out_msg = _help(user)
elif command == "dice":
out_msg = _dice(args)
elif command == "server":
out_msg = _server()
elif command == "about":
out_msg = _about()
elif command == "rps":
out_msg = _rps(user, args)
elif command == "list":
out_msg = _list(target,user,args)
elif command == "coffee":
out_msg = _coffee()
elif command == "eightball":
out_msg = _8ball()
else:
out_msg = "Unrecognized command. Type '{0}: help' to get a list of commands".format(current_nick)
buffer_out = weechat.info_get("irc_buffer", server + "," + channel)
if weechat.buffer_get_string(buffer_out,"localvar_type") == "channel":
weechat.command(buffer_out, out_msg)
return weechat.WEECHAT_RC_OK # must always return this or WEECHAT_RC_ERROR
示例8: url_recv_cb
def url_recv_cb(data, buffer, time, tags, displayed, highlight, prefix, message):
if w.config_get_plugin('debug') == 'on':
w.prnt("","%s: Got url %s" % (SCRIPT_NAME, message))
#do not trigger on filtered lines and notices
if displayed == '0' or prefix == w.config_string(w.config_get('weechat.look.prefix_network')):
#leave alone
if w.config_get_plugin('debug') == 'on':
w.prnt("","%s: not displayed, or sent from network. Ignoring" % SCRIPT_NAME)
return w.WEECHAT_RC_OK
buf_name = w.buffer_get_string(buffer,"name")
if w.config_get_plugin('debug') == 'on':
w.prnt("","%s: from buffer %s" % (SCRIPT_NAME, buf_name))
#skip ignored buffers
ignore_buffers = w.config_get_plugin('ignore_buffers').split(',')
if buf_name in ignore_buffers:
if w.config_get_plugin('debug') == 'on':
w.prnt("","%s: %s is on ignore_buffer list" % (SCRIPT_NAME, buf_name))
return w.WEECHAT_RC_OK
FNULL=open(os.devnull,'w')
#can have multiple imgs per msg?
for url in urlRe.findall(message):
found = False
if w.config_get_plugin('debug') == 'on':
w.prnt("","%s: testing url %s" % (SCRIPT_NAME,url))
#is the url for an image?
if imgRe.match(url):
found = True
if w.config_get_plugin('debug') == 'on':
w.prnt("","%s: found image!" % SCRIPT_NAME)
elif imgServiceRe.match(url):
found = True
if w.config_get_plugin('debug') == 'on':
w.prnt("","%s: found image service!" % SCRIPT_NAME)
if "imgur" in url:
url = re.sub(r'.*imgur\.com/(.*)',
r'http://i\.imgur\.com/\1\.jpg',
url)
#elif "cl.ly" in url:
#keyword blacklisting?
#domains are tied to the service. guess the services could be blacklisted
if found:
#blacklist
subprocess.call(['%s/get_view_img.sh' % w.info_get("weechat_dir",""),
'%s/img_cache' % w.info_get("weechat_dir",""),
url],
stdout=FNULL,stderr=subprocess.STDOUT)
return w.WEECHAT_RC_OK
示例9: renderConversations
def renderConversations(unused, command, return_code, out, err):
global conversation_map
global conv
if return_code == weechat.WEECHAT_HOOK_PROCESS_ERROR:
weechat.prnt("", "Error with command '%s'" % command)
return weechat.WEECHAT_RC_OK
if return_code > 0:
weechat.prnt("", "return_code = %d" % return_code)
if out != '':
conv += out
if return_code == weechat.WEECHAT_HOOK_PROCESS_RUNNING:
weechat.prnt('', 'getting more data')
return weechat.WEECHAT_RC_OK
if err != "":
weechat.prnt("", "stderr: %s" % err)
return weechat.WEECHAT_RC_OK
try:
conversations = reversed(cPickle.loads(conv))
except EOFError:
weechat.prnt('', 'wtrecv returned garbage')
return weechat.WEECHAT_RC_OK
for conversation in conversations:
if not conversation.conv_id in conversation_map:
conversation_map[conversation.conv_id] = conversation
msgs = conversation.messages
else:
old = conversation_map[conversation.conv_id]
conversation_map[conversation.conv_id] = conversation
msgs = old.new_messages(conversation)
for msg in msgs:
if not conversation.number in number_map and msg['from'] != 'Me:':
number_map[conversation.number] = msg['from']
for msg in msgs:
if conversation.number in number_map:
buf = weechat.buffer_search('python', number_map[conversation.number][:-1])
if not buf:
buf = weechat.buffer_new(number_map[conversation.number][:-1],
"textOut", "", "buffer_close_cb", "")
else:
buf = weechat.buffer_search('python', 'Me')
if not buf:
buf = weechat.buffer_new('Me', "textOut", "", "buffer_close_cb", "")
if weechat.config_get_plugin('encrypt_sms') == 'True':
msg['text'] = decrypt(msg['text'], buf)
nick = msg['from'][:-1].strip()
tags = 'notify_private,nick_' + msg['from'][:-1].strip()
tags += ',log1,prefix_nick_' + weechat.info_get('irc_nick_color_name', nick)
nick = msg['from'][:-1].strip()
weechat.prnt_date_tags(buf, 0, tags, '\x03' + weechat.info_get('irc_nick_color', nick)
+ nick + '\t' + msg['text'])
conv = ''
callGV()
return weechat.WEECHAT_RC_OK
示例10: is_own
def is_own(buffer, prefix):
sender = prefix
if not weechat.info_get("irc_is_nick", sender) or weechat.info_get("irc_is_nick", sender):
sender = sender[1:]
if not weechat.info_get("irc_is_nick", sender):
return False
nick = get_nick(buffer)
if nick == sender:
return True
else:
return False
示例11: notify_quit_cb
def notify_quit_cb(data, signal, signal_data):
""" callback for when a user in WeeChat's notify list quits IRC """
server, nick = signal_data.split(",")
buf = w.info_get("irc_buffer", server + ",," + nick)
if not buf:
return w.WEECHAT_RC_OK
w.prnt(buf, "{}{}{}{} has disconnected".format(w.prefix("quit"),
w.info_get("nick_color", nick),
nick, w.color("red")))
return w.WEECHAT_RC_OK
示例12: __init__
def __init__(self, server, channel='', encoding='utf-8', **kwargs):
self.server = server
self.channel = channel
self.encoding = encoding
self.nickname = weechat.info_get("irc_nick", self.server)
if channel:
buffer_str = '{},{}'.format(server, channel)
else:
buffer_str = server
self.buffer = weechat.info_get('irc_buffer', buffer_str)
self._extra_data = {}
if kwargs:
self.extra_data(**kwargs)
示例13: auth_notice_check
def auth_notice_check(data, buffer, args):
server = buffer.split(',')[0]
if args.startswith(":[email protected]") and \
args.find("If this is your nickname, type /msg NickServ") != -1 or args.find("This nickname is registered") != -1 :
passwd = auth_get(weechat.info_get("irc_nick", server), server)
if passwd != None:
weechat.command(server, "/quote -server %s nickserv identify %s" % (server, passwd))
commands = auth_cmdget(server)
if commands != '':
for c in commands.split("|"):
weechat.command(server, c.strip().replace("%n", weechat.info_get('irc_nick', server)))
return weechat.WEECHAT_RC_OK
示例14: notify_join_cb
def notify_join_cb(data, signal, signal_data):
""" callback for when a user in WeeChat's notify list connects to IRC """
server, nick = signal_data.split(",")
buf = w.info_get("irc_buffer", server + ",," + nick)
if not buf:
return w.WEECHAT_RC_OK
w.prnt(buf, "{}{}{}{} is back on the server".format(w.prefix("join"),
w.info_get("nick_color", nick),
nick, w.color("green")))
return w.WEECHAT_RC_OK
示例15: create_whois_regex_from_isupport
def create_whois_regex_from_isupport(server):
"""Look into server ISUPPORT to create the ideal regex for removing channel modes from WHOIS output"""
isupport_prefix = w.info_get("irc_server_isupport_value", "{},PREFIX".format(server)).split(")")[1]
isupport_chantypes = w.info_get("irc_server_isupport_value", "{},CHANTYPES".format(server))
# Strip modes from WHOIS output.
whois_regex = re.compile(r"(?:[{}]{})?(([{}])[^ ]+)".format(
re.escape(isupport_prefix),
"{1," + str(len(isupport_prefix)) + "}",
re.escape(isupport_chantypes)
))
return whois_regex