本文整理汇总了Python中weechat.current_buffer函数的典型用法代码示例。如果您正苦于以下问题:Python current_buffer函数的具体用法?Python current_buffer怎么用?Python current_buffer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了current_buffer函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: update_title
def update_title(data, signal, signal_data):
''' The callback that adds title. '''
if w.config_get_plugin('short_name') == 'on':
title = w.buffer_get_string(w.current_buffer(), 'short_name')
else:
title = w.buffer_get_string(w.current_buffer(), 'name')
hotlist = w.infolist_get('hotlist', '', '')
hot_text = ''
while w.infolist_next(hotlist):
priority = w.infolist_integer(hotlist, 'priority')
if priority >= int(w.config_get_plugin('title_priority')):
number = w.infolist_integer(hotlist, 'buffer_number')
thebuffer = w.infolist_pointer(hotlist, 'buffer_pointer')
name = w.buffer_get_string(thebuffer, 'short_name')
hot_text += ' %s' % number
if hot_text:
title += ' [A:%s]' % hot_text
w.infolist_free(hotlist)
w.window_set_title(title)
return w.WEECHAT_RC_OK
开发者ID:aimeeble,项目名称:dotfiles,代码行数:25,代码来源:title.py
示例2: command_main
def command_main(data, buffer, args):
args = args.split()
curr_buffer = weechat.current_buffer()
curr_buffer_number = weechat.buffer_get_integer(curr_buffer, "number")
if len(args) != 1 and len(args) != 2:
weechat.prnt("", "You need to specify 1 or 2 buffers")
return weechat.WEECHAT_RC_ERROR
if len(args) == 2:
weechat.command("", "/buffer %s" % args[0])
first_buffer = weechat.current_buffer()
first_buffer_number = weechat.buffer_get_integer(first_buffer, "number")
weechat.command("", "/buffer %s" % args[1])
second_buffer = weechat.current_buffer()
second_buffer_number = weechat.buffer_get_integer(second_buffer, "number")
else:
first_buffer = weechat.current_buffer()
first_buffer_number = weechat.buffer_get_integer(first_buffer, "number")
weechat.command("", "/buffer %s" % args[0])
second_buffer = weechat.current_buffer()
second_buffer_number = weechat.buffer_get_integer(second_buffer, "number")
weechat.buffer_set(first_buffer, "number", str(second_buffer_number))
weechat.buffer_set(second_buffer, "number", str(first_buffer_number))
weechat.command("", "/buffer %s" % str(curr_buffer_number))
return weechat.WEECHAT_RC_OK
开发者ID:FiXato,项目名称:weechat_scripts,代码行数:31,代码来源:buffer_swap.py
示例3: ircrypt_public_key_send
def ircrypt_public_key_send(server, nick):
'''This function sends away own public key'''
global ircrypt_gpg_homedir, ircrypt_gpg_id, ircrypt_key_ex_memory
# Export own public key and b64encode the public key. Print error if
# necessary.
if not ircrypt_gpg_id:
ircrypt.ircrypt_error('Error in IRCrypt key exchange', weechat.current_buffer())
weechat.command('','/mute -all notice -server %s %s '
'>UCRY-INTERNAL-ERROR' % (server, info['nick']))
return ''
(ret, out, err) = ircrypt.ircrypt_gnupg(b'', '--homedir', ircrypt_gpg_homedir,
'--export', ircrypt_gpg_id)
if ret:
ircrypt.ircrypt_error(err.decode('utf-8'), weechat.current_buffer())
weechat.command('','/mute -all notice -server %s %s '
'>UCRY-INTERNAL-ERROR' % (server, info['nick']))
try:
del ircrypt_key_ex_memory[target]
except KeyError:
pass
return ''
elif err:
ircrypt.ircrypt_warn(err.decode('utf-8'))
pub_key = base64.b64encode(out)
# Partition the public key and send it away
for i in range(1 + (len(pub_key) // MAX_PART_LEN))[::-1]:
msg = '>PUB-EX-%i %s' % (i, pub_key[i*MAX_PART_LEN:(i+1)*MAX_PART_LEN])
weechat.command('','/mute -all notice -server %s %s %s' % (server, nick, msg))
return ''
开发者ID:petvoigt,项目名称:ircrypt-weechat,代码行数:35,代码来源:ircrypt-keyex.py
示例4: translate_process_cb
def translate_process_cb(data, command, rc, stdout, stderr):
"""Callback reading HTML data from website."""
global translate
if stdout != '':
translate['stdout'] += stdout
if int(rc) >= 0:
translated = translate['stdout'].split('"')[1]
translate['input_before'][0] = weechat.buffer_get_string(weechat.current_buffer(), 'input')
translate['input_before'][1] = weechat.buffer_get_integer(weechat.current_buffer(), 'input_pos')
if translate['options']['word']:
# translate last word of input
str_input = translate['input_before'][0]
if str_input:
pos = str_input.rfind(' ')
if pos < 0:
str_input = translated
else:
str_input = '%s %s' % (str_input[0:pos], translated)
else:
str_input = translated
translate['input_after'][0] = str_input
else:
if translate['options']['before_marker']:
translated = '%s%s' % (translate['options']['before_marker'], translated)
translate['input_after'][0] = translated
# set input with translation
translate['input_after'][1] = len(translate['input_after'][0])
weechat.buffer_set(weechat.current_buffer(), 'input', translate['input_after'][0])
weechat.buffer_set(weechat.current_buffer(), 'input_pos', '%d' % translate['input_after'][1])
translate['hook_process'] = ''
elif int(rc) == WEECHAT_HOOK_PROCESS_ERROR:
translate['hook_process'] = ''
return weechat.WEECHAT_RC_OK
开发者ID:norrs,项目名称:weechat-plugins,代码行数:33,代码来源:translate.py
示例5: get_nicklist
def get_nicklist(server, channel):
global options
regex_flags = 0
if options['ignore_case']:
regex_flags = re.IGNORECASE
ignore_list = w.config_get_plugin('ignore_list')
if ignore_list == '':
ignore_match = lambda x: False
else:
ignore_match = re.compile('(%s)$' % ignore_list.replace(',', '|'), regex_flags).match
server = w.buffer_get_string(w.current_buffer(), 'localvar_server')
my_nick = w.info_get('irc_nick', server)
nicklist = {}
infolist_nicklist = w.infolist_get('nicklist', w.current_buffer(), '')
while w.infolist_next(infolist_nicklist):
nick = w.infolist_string(infolist_nicklist, 'name')
prefix = w.infolist_string(infolist_nicklist, 'prefix')
nick_type = w.infolist_string(infolist_nicklist, 'type')
if nick_type != 'nick' or (options['ignore_self'] and nick == my_nick) or ignore_match(nick):
pass
else:
if not nicklist.has_key(prefix):
nicklist[prefix]=[]
nicklist[prefix].append(nick)
w.infolist_free(infolist_nicklist)
return nicklist
开发者ID:DarkDefender,项目名称:scripts,代码行数:28,代码来源:hl_nicks.py
示例6: pastero_cmd_cb
def pastero_cmd_cb(data, buffer, args):
global Ext
command = 'curl -sSF [email protected] ' + url
if args.count('.') > 0:
Ext = args.split('.')
Ext.reverse()
else:
Ext = ' ' # Ugly hack so Ext[0] doesn't complain in case is empty :>
if args != '':
sargs = args.split()
if sargs[0] == '--clip':
f_input(get_clip_cmd().strip())
elif sargs[0] == '--cmd':
if len(sargs) == 1:
w.prnt(w.current_buffer(),
'%s\tPlease specify a command to run.' % PREFIX)
else:
sargs = ' '.join(sargs[1:])
command = ' '.join((sargs, '|', command))
w.hook_process_hashtable('sh',
{'arg1':'-c',
'arg2':command},
5 * 1000, 'printer_cb', '')
else:
f_input(open(sargs[0], 'r').read())
else:
w.prnt(w.current_buffer(),
'%s\tPlease, specify a file to upload.' % PREFIX)
return WEECHAT_RC_OK
开发者ID:batalooppak,项目名称:pastero,代码行数:34,代码来源:pastero.py
示例7: whois
def whois (username):
'''Shows profile information about a given user'''
if len(username) == 0:
return weechat.WEECHAT_RC_ERROR
response = statusnet_handler.handle_request(statusnet_handler.build_request('users', 'show', username))
if response == None:
pass
elif response == False:
weechat.prnt(weechat.current_buffer(), ('%sCan\'t retrieve information about %s' % (weechat.prefix('error'), username)))
else:
whois = json.load(response)
whois['summary'] = ' '.join([u'\u00B5', str(whois['statuses_count']),
u'\u2764', str(whois['favourites_count']),
'subscribers', str(whois['followers_count']),
'subscriptions', str(whois['friends_count'])])
for property in ['name', 'description', 'url', 'location', 'profile_image_url', 'summary']:
if property in whois and whois[property] != None:
weechat.prnt(weechat.current_buffer(), ('%s[%s] %s' % (weechat.prefix('network'),
nick_color(username),
whois[property].encode('utf-8'))))
return weechat.WEECHAT_RC_OK
开发者ID:s5unty,项目名称:dotfiles,代码行数:26,代码来源:tweetim.py
示例8: prism_cmd_cb
def prism_cmd_cb(data, buffer, args):
global color_index
input = args.decode("UTF-8")
input_method = "command"
if not input:
input = w.buffer_get_string(buffer, "input")
input = input.decode("UTF-8")
input_method = "keybinding"
# select a tokenizer and increment mode
regex = regex_chars
inc = 1
mepfx = 0
bs = 0
m = re.match('-[rwmbe]* ', input)
if m and input_method == "command":
opts = m.group(0)
input = input[len(opts):]
if 'w' in opts:
regex = regex_words
if 'r' in opts:
inc = 0
if 'm' in opts:
mepfx = 1
if 'b' in opts:
input = input[::-1]
if 'e' in opts:
bs = 1
output = u""
tokens = re.findall(regex, input)
for token in tokens:
# prefix each token with a color code
color_code = unicode(colors[color_index % color_count]).rjust(2, "0")
if bs == 1:
output += u'\x03' + color_code + ',' + find_another_color(color_code) + token
else:
output += u"\x03" + color_code + token
# select the next color or another color at
# random depending on the options specified
if inc == 0:
color_index += random.randint(1, color_count - 1)
else:
color_index += inc
# output starting with a / will be executed as a
# command unless we escape it with a preceding /
if len(output) > 0 and output[0] == "/":
output = "/" + output
if mepfx == 1:
output = "/me " + output
if input_method == "keybinding":
w.buffer_set(w.current_buffer(), "input", output.encode("UTF-8"))
else:
w.command(w.current_buffer(), output.encode("UTF-8"))
return w.WEECHAT_RC_OK
开发者ID:ThatPerson,项目名称:dotfiles,代码行数:59,代码来源:prism.py
示例9: np
def np(self):
"""Pushes result of np template substitution to current buffer.
"""
ds = self.currentsong()
if len(ds) == 0:
wc.prnt(wc.current_buffer(), "MPC: ERROR: mpd is stopped")
return
wc.command(wc.current_buffer(),
Template(wc.config_get_plugin("format")).safe_substitute(ds))
开发者ID:sitaktif,项目名称:weechat-scripts,代码行数:9,代码来源:mpc.py
示例10: execbot_command_del
def execbot_command_del(server,nicknames):
'''Remove nicknames.'''
for x in nicknames:
try:
del execbot_allows['%s.%s'%(server,x.lower())]
weechat.prnt(weechat.current_buffer(),'Deleted permission of %s' % '%s.%s'%(server,x.lower()))
except KeyError:
weechat.prnt(weechat.current_buffer(),'No existing %s.%s'%(server,x.lower()))
return weechat.WEECHAT_RC_OK
开发者ID:oakkitten,项目名称:scripts,代码行数:9,代码来源:execbot.py
示例11: weather_cb
def weather_cb(server, buffer, argList):
""" Callback for the Google weather bar item. """
global last_run, last_city, current_city
global gweather_output, gweather_hook_process
if argList.partition(" ")[0] == "default":
weechat.config_set_plugin("city", argList.partition(" ")[2])
current_city = weechat.config_get_plugin("city")
weechat.prnt(weechat.current_buffer(), "Saving new location as: %s" % current_city)
if argList == "" and weechat.config_get_plugin("city") == "":
weechat.prnt(weechat.current_buffer(), "Error: no default city, provide one with command")
return weechat.WEECHAT_RC_ERROR
if len(argList) > 0:
if weechat.config_get_plugin("city") == "":
weechat.config_set_plugin("city", argList)
current_city = argList
else:
current_city = weechat.config_get_plugin("city")
location_id, hl = map(quote, (current_city, weechat.config_get_plugin("language")))
url = GOOGLE_WEATHER_URL % (location_id, hl)
# Use cached copy if it is updated recently enough
if current_city == last_city and (time() - last_run) < (int(weechat.config_get_plugin("interval")) * 60):
weechat.command(weechat.current_buffer(), gweather_output)
return weechat.WEECHAT_RC_OK
last_city = current_city
command = "urllib2.urlopen('%s')" % (url)
if gweather_hook_process != "":
weechat.unhook(gweather_hook_process)
gweather_hook_process = ""
# Fire up the weather informationg fetching
python2_bin = weechat.info_get("python2_bin", "") or "python"
gweather_hook_process = weechat.hook_process(
python2_bin
+ ' -c "import urllib2;\
handler = '
+ command
+ ";\
print handler.info().dict['content-type'];\
print handler.read();\
handler.close();\"",
int(weechat.config_get_plugin("timeout")) * 1000,
"weather_data_cb",
"",
)
# The old cached string is returned here. gweather_data_cb() will
# request a new update after the data is fetched and parsed.
return weechat.WEECHAT_RC_OK
开发者ID:Shrews,项目名称:scripts,代码行数:56,代码来源:weather.py
示例12: wake_room
def wake_room(data, buffer, args):
server = weechat.buffer_get_string(weechat.current_buffer(), 'localvar_server')
channel = weechat.buffer_get_string(weechat.current_buffer(), 'localvar_channel')
infolist = weechat.infolist_get('irc_nick', '', server + ',' + channel)
nicklist = ''
while weechat.infolist_next(infolist):
nicklist += weechat.infolist_string(infolist, 'name') + ' '
weechat.command(weechat.current_buffer(), nicklist)
weechat.infolist_free(infolist)
return weechat.WEECHAT_RC_OK
开发者ID:BullShark,项目名称:WakeUp,代码行数:10,代码来源:wr.py
示例13: ircrypt_receive_key_ex_ping
def ircrypt_receive_key_ex_ping(server, args, info):
'''This function handles incomming >KEY-EX-PING notices'''
global ircrypt_gpg_id, ircrypt_key_ex_memory
# Check for ircrypt plugin
if not ircrypt_check_ircrypt:
weechat.command('','/mute -all notice -server %s %s '
'>UCRY-INTERNAL-ERROR' % (server, info['nick']))
return ''
# Check if own gpg key exists
if not ircrypt_gpg_id:
ircrypt.ircrypt_error('Error in IRCrypt key exchange', weechat.current_buffer())
weechat.command('','/mute -all notice -server %s %s '
'>UCRY-INTERNAL-ERROR' % (server, info['nick']))
return ''
# Get fingerprint from message
try:
fingerprint = args.split('>KEY-EX-PING')[-1].split(' (')[0].lstrip(' ')
except:
ircrypt.ircrypt_error('Error in IRCrypt key exchange', weechat.current_buffer())
weechat.command('','/mute -all notice -server %s %s '
'>UCRY-INTERNAL-ERROR' % (server, info['nick']))
return ''
# Wrong fingerprint: Error
if fingerprint and fingerprint != ircrypt_gpg_id:
ircrypt.ircrypt_error('%s tries key exchange with wrong fingerprint' \
% info['nick'], weechat.current_buffer())
weechat.command('','/mute -all notice -server %s %s '
'>UCRY-PING-WITH-INVALID-FINGERPRINT' % (server, info['nick']))
return ''
# Send back a >KEY-EX-PONG with optional fingerprint and create an instance
# of the class KeyExchange
target = '%s/%s' % (server, info['nick'])
gpg_id = ircrypt_asym_id.get(target.lower())
if gpg_id:
weechat.command('','/mute -all notice -server %s %s >KEY-EX-PONG %s' \
% (server, info['nick'], gpg_id))
if fingerprint:
ircrypt_key_ex_memory[target] = KeyExchange(False, False)
else:
ircrypt_key_ex_memory[target] = KeyExchange(False, True)
else:
weechat.command('','/mute -all notice -server %s %s >KEY-EX-PONG' \
% (server, info['nick']))
if fingerprint:
ircrypt_key_ex_memory[target] = KeyExchange(True, False)
else:
ircrypt_key_ex_memory[target] = KeyExchange(True, True)
return ''
开发者ID:petvoigt,项目名称:ircrypt-weechat,代码行数:54,代码来源:ircrypt-keyex.py
示例14: process_complete
def process_complete(data, command, rc, stdout, stderr):
global process_output
process_output += stdout.strip()
if len(process_output) > 40:
weechat.prnt(weechat.current_buffer(), weechat.prefix("error") + 'whatismyip: [%s]' % "Service Unavailable")
return weechat.WEECHAT_RC_OK
if int(rc) == 0:
weechat.prnt(weechat.current_buffer(), '[%s]' % process_output)
return weechat.WEECHAT_RC_OK
开发者ID:DarkDefender,项目名称:scripts,代码行数:11,代码来源:whatismyip.py
示例15: find_nick
def find_nick(data, buffer, args):
''' print out the last nick '''
user_input = args
if not user_input:
user_input = weechat.buffer_get_string(weechat.current_buffer(), "input")
weechat.prnt(weechat.current_buffer(), "got content for user_input")
# reset outstring
outstring = ''
# Capture the nicks used
# for the sake of testing, we will use "BOING"
# Need a function that will string the nicks and assign them to the outstring
# Encode the outstring as UTF
outstring = outstring.encode('UTF-8')
开发者ID:situmam,项目名称:last_nick,代码行数:13,代码来源:last_nick.py
示例16: flip_cmd_cb
def flip_cmd_cb(data, buffer, args):
''' Command /flip '''
translate_input = args
if not translate_input:
translate_input = w.buffer_get_string(w.current_buffer(), "input")
outstring = ''
for char in translate_input:
if char in replacements:
char = replacements[char]
outstring += char
outstring = outstring.encode('UTF-8')
w.buffer_set(w.current_buffer(), 'input', outstring)
return w.WEECHAT_RC_OK
开发者ID:DarkDefender,项目名称:scripts,代码行数:13,代码来源:upside_down.py
示例17: weather_cb
def weather_cb(server, buffer, argList):
''' Callback for the Google weather bar item. '''
global last_run, last_city, current_city
global gweather_output, gweather_hook_process
if(argList.partition(" ")[0] == "default"):
weechat.config_set_plugin('city', argList.partition(" ")[2])
current_city = weechat.config_get_plugin('city')
weechat.prnt(weechat.current_buffer(), "Saving new location as: %s" % current_city)
if(argList == '' and weechat.config_get_plugin('city') == ''):
weechat.prnt(weechat.current_buffer(), "Error: no default city, provide one with command")
return weechat.WEECHAT_RC_ERROR
if(len(argList)>0):
if(weechat.config_get_plugin('city') == ''):
weechat.config_set_plugin('city', argList)
current_city = argList
else:
current_city = weechat.config_get_plugin('city')
location_id, hl = map(quote, (current_city, \
weechat.config_get_plugin('language')))
url = GOOGLE_WEATHER_URL % (location_id, hl)
# Use cached copy if it is updated recently enough
if current_city == last_city and \
(time() - last_run) < (int(weechat.config_get_plugin('interval')) * 60):
weechat.command(weechat.current_buffer(), gweather_output)
return weechat.WEECHAT_RC_OK
last_city = current_city
command = 'urllib2.urlopen(\'%s\')' % (url)
if gweather_hook_process != "":
weechat.unhook(gweather_hook_process)
gweather_hook_process = ''
# Fire up the weather informationg fetching
gweather_hook_process = weechat.hook_process(\
"python -c \"import urllib2;\
handler = " + command + ";\
print handler.info().dict['content-type'];\
print handler.read();\
handler.close();\"",
int(weechat.config_get_plugin('timeout')) * 1000, "weather_data_cb", "")
# The old cached string is returned here. gweather_data_cb() will
# request a new update after the data is fetched and parsed.
return weechat.WEECHAT_RC_OK
开发者ID:kinabalu,项目名称:weechat-plugins,代码行数:51,代码来源:forecast.py
示例18: subscribe
def subscribe (username):
if len(username) == 0:
return weechat.WEECHAT_RC_ERROR
response = statusnet_handler.handle_request(statusnet_handler.build_request('friendships', 'create', username))
if response == None:
pass
elif response == False:
weechat.prnt(weechat.current_buffer(), ('%sYou\'re already suscribed to %s' % (weechat.prefix('error'), username)))
else:
weechat.prnt(weechat.current_buffer(), ('%sSuscribed to %s updates' % (weechat.prefix('join'), username)))
return weechat.WEECHAT_RC_OK
开发者ID:bradfier,项目名称:configs,代码行数:14,代码来源:identica.py
示例19: unsubscribe
def unsubscribe (username):
if len(username) == 0:
return weechat.WEECHAT_RC_ERROR
response = statusnet_handler.handle_request(statusnet_handler.build_request('friendships', 'destroy', username))
if response == None:
pass
elif response == False:
weechat.prnt(weechat.current_buffer(), ('%sYou aren\'t suscribed to %s' % (weechat.prefix('error'), username)))
else:
weechat.prnt(weechat.current_buffer(), ('%sUnsuscribed from %s\'s updates' % (weechat.prefix('quit'), username)))
return weechat.WEECHAT_RC_OK
开发者ID:bradfier,项目名称:configs,代码行数:14,代码来源:identica.py
示例20: unblock
def unblock (username):
'''Unblocks users'''
if len(username) == 0:
return weechat.WEECHAT_RC_ERROR
response = statusnet_handler.handle_request(statusnet_handler.build_request('blocks', 'destroy', username))
if response == None:
pass
elif response == False:
weechat.prnt(weechat.current_buffer(), ('%sCan\'t unblock %s' % (weechat.prefix('error'), username)))
else:
weechat.prnt(weechat.current_buffer(), ('%sUnblocked %s' % (weechat.prefix('network'), username)))
return weechat.WEECHAT_RC_OK
开发者ID:s5unty,项目名称:dotfiles,代码行数:15,代码来源:tweetim.py
注:本文中的weechat.current_buffer函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论