def hilightCheckBuffer( signal, pointer ): global bufferpointer if pointer == bufferpointer: weechat.prnt("", "Alright, who closed the buffer?!?!") weechat.buffer_new( weechat.config_get_plugin('buffer_out'), "", "" ) bufferpointer = weechat.buffer_search( "python", weechat.config_get_plugin('buffer_out')) return weechat.WEECHAT_RC_OK
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
def gvOut(data, buf, input_data): if input_data[:4] == 'text' and buf == weechat.buffer_search('python', 'weeText'): buffer = weechat.buffer_new("+1"+input_data[5:], "textOut", "", "buffer_close_cb", "") if input_data[:5] == 'multi' and buf == weechat.buffer_search('python', 'weeText'): num_list = input_data[6:].split(',') nums = '' for num in num_list: nums += '+' + num[-4:] nums = nums[1:] buffer = weechat.buffer_new('m:' + nums, "multiText", input_data[6:], "buffer_close_cb", "") return weechat.WEECHAT_RC_OK
def __init__(self, server, name, id, type="channel", auto=True): """ Init chat """ self.server = server # TODO(arnaud) maybe add an option to remove the # in front of channels self.name = f"#{name}" if type == 'channel' else f"{name}" self.id = f"{id}" self.buffer = weechat.buffer_search("python", self.id) self.type = type # can be channel or private if not self.buffer: self.buffer = weechat.buffer_new(self.name, "webex_buffer_input_cb", "", "webex_buffer_close_cb", "") if self.buffer: weechat.buffer_set(self.buffer, "title", self.name) weechat.buffer_set(self.buffer, "short_name", self.name) weechat.buffer_set(self.buffer, "input_multiline", "1") weechat.buffer_set( self.buffer, "localvar_set_type", self.type ) # I use this in external plugin (notification/autosort) weechat.buffer_set(self.buffer, "localvar_set_roomid", self.id) # I use this to debug weechat.hook_signal_send("logger_backlog", weechat.WEECHAT_HOOK_SIGNAL_POINTER, self.buffer) if auto: weechat.buffer_set(self.buffer, "display", "auto") # Store real ID if possible if self.type == "channel": self.real_id = get_real_room_id(self.id) else: self.real_id = None
def playlistinfo(self, sortkey='pos'): """Shows playlist information sorted by key """ new_buf = wc.buffer_search("", "mpc: playlist") if len(new_buf) == 0: new_buf = wc.buffer_new('mpc: playlist', "", "", "", "") pl = self._mpdc.playlistinfo() try: # Numerical sort spl = sorted(pl, cmp=lambda x,y: cmp(int(x), int(y)), key=itemgetter(sortkey)) except ValueError: # Alpha sort lcmp = lambda x,y: cmp(x.lower(), y.lower()) spl = sorted(pl, cmp=lambda x,y: cmp(x.lower(), y.lower()), key=itemgetter(sortkey)) t = Template(wc.config_get_plugin("playinfo")) for line in spl: wc.prnt(new_buf, t.safe_substitute(line)) return pl
def weetris_init(): """Initialize weetris.""" keys = { 'meta2-A': 'up', 'meta2-B': 'down', 'meta-Ob': 'bottom', 'meta-OB': 'bottom', 'meta2-1;5B': 'bottom', 'meta2-D': 'left', 'meta2-C': 'right', 'meta-n': 'new_game', 'meta-p': 'pause', } weetris['buffer'] = weechat.buffer_search('python', 'weetris') if not weetris['buffer']: weetris['buffer'] = weechat.buffer_new('weetris', 'buffer_input_cb', '', 'buffer_close_cb', '') if weetris['buffer']: weechat.buffer_set(weetris['buffer'], 'type', 'free') weechat.buffer_set(weetris['buffer'], 'title', BUFFER_TITLE) for key, action in keys.items(): weechat.buffer_set(weetris['buffer'], 'key_bind_%s' % key, '/weetris %s' % action) new_game() weechat.buffer_set(weetris['buffer'], 'display', '1')
def join_cb(server, channel, hostmask, signal_data): if channel in ignoreJoins: return WEECHAT_RC_OK warnDB.purge() for mask in warnDB: match = pattern_match(mask, hostmask) if match: obj = warnDB[mask] if not obj.isValidChannel(channel): continue value = get_config_valid_string('warning_buffer') buffer = '' if value == 'channel': buffer = weechat.buffer_search('irc', '%s.%s' % (server, channel)) elif value == 'current': buffer = weechat.current_buffer() elif value == 'warn_buffer': buffer = weechat.buffer_search('python', SCRIPT_NAME) if not buffer: buffer = weechat.buffer_new(SCRIPT_NAME, '', '', '', '') prnt_date_tags( buffer, 0, 'notify_highlight', "%s\t%s joined %s%s %s[%s%s%s] %s%s \"%s\"" % (script_nick, format_hostmask(hostmask), COLOR_CHAT_CHANNEL, channel, COLOR_CHAT_DELIMITERS, COLOR_CHAT_BUFFER, obj.id, COLOR_CHAT_DELIMITERS, mask, COLOR_RESET, obj.comment)) break return WEECHAT_RC_OK
def create_buffer(self): channel_buffer = w.buffer_search("", "%s.%s" % (self.server.domain, self.name)) if channel_buffer: self.channel_buffer = channel_buffer else: self.channel_buffer = w.buffer_new("%s.%s" % (self.server.domain, self.name), "buffer_input_cb", self.name, "", "") w.buffer_set(self.channel_buffer, "short_name", 'loading..')
def lb_create_buffer(): global lb_buffer, lb_curline if not lb_buffer: lb_buffer = weechat.buffer_new("listbuffer", "lb_input_cb", \ "", "lb_close_cb", "") weechat.buffer_set(lb_buffer, "title", lb_line_format({ 'channel': 'Channel name', 'users': 'Users', 'modes': 'Modes', 'topic': 'Topic', 'nomodes': None, })) # Sets notify to 0 as this buffer does not need to be in hotlist. weechat.buffer_set(lb_buffer, "notify", "0") weechat.buffer_set(lb_buffer, "nicklist", "0") weechat.buffer_set(lb_buffer, "type", "free") weechat.buffer_set(lb_buffer, "key_bind_ctrl-L", "/listbuffer **refresh") weechat.buffer_set(lb_buffer, "key_bind_meta2-A", "/listbuffer **up") weechat.buffer_set(lb_buffer, "key_bind_meta2-B", "/listbuffer **down") weechat.buffer_set(lb_buffer, "key_bind_meta2-1~", "/listbuffer **scroll_top") weechat.buffer_set(lb_buffer, "key_bind_meta2-4~", "/listbuffer **scroll_bottom") weechat.buffer_set(lb_buffer, "key_bind_meta-ctrl-J", "/listbuffer **enter") weechat.buffer_set(lb_buffer, "key_bind_meta-ctrl-M", "/listbuffer **enter") weechat.buffer_set(lb_buffer, "key_bind_meta->", "/listbuffer **sort_next") weechat.buffer_set(lb_buffer, "key_bind_meta-<", "/listbuffer **sort_previous") weechat.buffer_set(lb_buffer, "key_bind_meta-/", "/listbuffer **sort_invert") lb_curline = 0 if weechat.config_get_plugin("autofocus") == "on": if not weechat.window_search_with_buffer(lb_buffer): weechat.command("", "/buffer " + weechat.buffer_get_string(lb_buffer,"name"))
def __init__(self, options): self.status_name = options['server_name'] self.nick_name = options['nickname'] global debug if options['debug'] == "true": debug = True else: debug = False self.private_chans = {} self.private_chans_ptr = {} self.status = weechat.buffer_new(self.status_name, "status_input_cb", "", "status_close_cb", "") weechat.buffer_set(self.status, "localvar_set_type", "server") weechat.buffer_set(self.status, "localvar_set_server", "keybase") self.init_chats() #self.get_history() self.reader = weechat.hook_process_hashtable("keybase chat api-listen", {"buffer_flush": "1"}, 0, "start_reading", "") weechat.hook_command( "download", "Download an attachment", "<msg_id> <outputh_path>", "<msg_id>: ID of the message\n<output_path>: Path to store file", "", "download_message", "") weechat.hook_command("open", "Open (with default application) an attachment", "<msg_id>", "<msg_id>: ID of the message\n", "", "open_attachment", "") ## Hooking to classic weechat command weechat.hook_command_run("/msg", "send_new_message", "") weechat.hook_command_run("/reply", "reply_to_message", "") weechat.hook_signal("buffer_switch", "buffer_switched", "") weechat.hook_signal("window_scrolled", "window_scrolled", "") weechat.hook_command("test", "", "", "", "", "test12", "")
def weecat_command_cb(data, buffer, args): global weecat_buffers, cmds_by_buffer, listen_hooks try: this_file = open(args) except IOError as e: weechat.prnt("", weechat.prefix("error") + "weecat: " + e.strerror) return weechat.WEECHAT_RC_ERROR filename = this_file.name if not args in listen_hooks: new_buffer = weechat.buffer_new( "wc: " + filename, "weecat_input_cb", "", "weecat_close_cb", "" ) weechat.buffer_set(new_buffer, "title", "weecat: " + filename) weechat.hook_signal_send("logger_backlog", weechat.WEECHAT_HOOK_SIGNAL_POINTER, new_buffer) listen_hooks[filename] = weechat.hook_fd(this_file.fileno(), 1, 0, 0, "weecat_update_cb", new_buffer) weechat.buffer_set(new_buffer, "display", "1") # switch to it weecat_buffers.add(new_buffer) files_by_buffer[new_buffer] = this_file return weechat.WEECHAT_RC_OK
def minesweeper_init(): """Init minesweeper: create buffer, adjust zoom, new game.""" global minesweeper if minesweeper['buffer']: return minesweeper['buffer'] = weechat.buffer_search('python', 'minesweeper') if not minesweeper['buffer']: minesweeper['buffer'] = weechat.buffer_new('minesweeper', 'minesweeper_input_buffer', '', 'minesweeper_close_buffer', '') if minesweeper['buffer']: weechat.buffer_set(minesweeper['buffer'], 'type', 'free') weechat.buffer_set(minesweeper['buffer'], 'title', 'Minesweeper! | alt-space or mouse-b1: explore, alt-f or mouse-b2: flag, alt-n: new game, ' 'alt-+/-: adjust board zoom | ' 'Command line: (n)ew, +/-: change size, (q)uit') weechat.buffer_set(minesweeper['buffer'], 'key_bind_meta2-A', '/minesweeper up') weechat.buffer_set(minesweeper['buffer'], 'key_bind_meta2-B', '/minesweeper down') weechat.buffer_set(minesweeper['buffer'], 'key_bind_meta2-D', '/minesweeper left') weechat.buffer_set(minesweeper['buffer'], 'key_bind_meta2-C', '/minesweeper right') weechat.buffer_set(minesweeper['buffer'], 'key_bind_meta-f', '/minesweeper flag') weechat.buffer_set(minesweeper['buffer'], 'key_bind_meta- ', '/minesweeper explore') weechat.buffer_set(minesweeper['buffer'], 'key_bind_meta-n', '/minesweeper new') weechat.buffer_set(minesweeper['buffer'], 'key_bind_meta-+', '/minesweeper zoom') weechat.buffer_set(minesweeper['buffer'], 'key_bind_meta--', '/minesweeper dezoom') weechat.buffer_set(minesweeper['buffer'], 'key_bind_meta-c', '/minesweeper cheat') if minesweeper['buffer']: minesweeper_adjust_zoom() minesweeper_new_game()
def floodit_init(): """Init floodit: create buffer, adjust zoom, new game.""" global floodit, floodit_settings if floodit['buffer']: return floodit['buffer'] = weechat.buffer_search('python', 'floodit') if not floodit['buffer']: floodit['buffer'] = weechat.buffer_new('floodit', 'floodit_input_buffer', '', 'floodit_close_buffer', '') if floodit['buffer']: weechat.buffer_set(floodit['buffer'], 'type', 'free') weechat.buffer_set( floodit['buffer'], 'title', 'Flood it! | alt-f or mouse: flood, alt-n: new game, alt-+/-: adjust board zoom | ' 'Command line: (n)ew, (s)ingle, (v)ersus, (d)emo (+delay), +/-: change size, (q)uit' ) weechat.buffer_set(floodit['buffer'], 'key_bind_meta2-D', '/floodit left') weechat.buffer_set(floodit['buffer'], 'key_bind_meta2-C', '/floodit right') weechat.buffer_set(floodit['buffer'], 'key_bind_meta-f', '/floodit flood') weechat.buffer_set(floodit['buffer'], 'key_bind_meta-n', '/floodit new') weechat.buffer_set(floodit['buffer'], 'key_bind_meta-+', '/floodit zoom') weechat.buffer_set(floodit['buffer'], 'key_bind_meta--', '/floodit dezoom') weechat.buffer_set(floodit['buffer'], 'key_bind_meta-C', '/floodit computer') if floodit['buffer']: floodit_adjust_zoom() floodit_new_game()
def test_display(): """Test display functions.""" check(weechat.prefix('action') != '') check(weechat.prefix('error') != '') check(weechat.prefix('join') != '') check(weechat.prefix('network') != '') check(weechat.prefix('quit') != '') check(weechat.prefix('unknown') == '') check(weechat.color('green') != '') check(weechat.color('unknown') == '') weechat.prnt('', '## test print core buffer') weechat.prnt_date_tags('', 946681200, 'tag1,tag2', '## test print_date_tags core buffer') buffer = weechat.buffer_new('test_formatted', 'buffer_input_cb', '', 'buffer_close_cb', '') check(buffer != '') check(weechat.buffer_get_integer(buffer, 'type') == 0) weechat.prnt(buffer, '## test print formatted buffer') weechat.prnt_date_tags(buffer, 946681200, 'tag1,tag2', '## test print_date_tags formatted buffer') weechat.buffer_close(buffer) buffer = weechat.buffer_new_props('test_free', {'type': 'free'}, 'buffer_input_cb', '', 'buffer_close_cb', '') check(weechat.buffer_get_integer(buffer, 'type') == 1) check(buffer != '') weechat.prnt_y(buffer, 0, '## test print_y free buffer') weechat.prnt_y_date_tags(buffer, 0, 946681200, 'tag1,tag2', '## test print_y_date_tags free buffer') weechat.buffer_close(buffer)
def samegame_init(): """Init samegame: create buffer, adjust zoom, new game.""" global samegame, samegame_settings if samegame["buffer"]: return samegame["buffer"] = weechat.buffer_search("python", "samegame") if not samegame["buffer"]: samegame["buffer"] = weechat.buffer_new("samegame", "samegame_input_buffer", "", "samegame_close_buffer", "") if samegame["buffer"]: weechat.buffer_set(samegame["buffer"], "type", "free") weechat.buffer_set( samegame["buffer"], "title", "Samegame | mouse: play, alt-n: new game, alt-+/-: adjust board zoom, alt-u: undo | " "Command line: (n)ew, +/-: change size, (q)uit, 3-6: number of colors", ) weechat.buffer_set(samegame["buffer"], "key_bind_meta-n", "/samegame new") weechat.buffer_set(samegame["buffer"], "key_bind_meta-+", "/samegame zoom") weechat.buffer_set(samegame["buffer"], "key_bind_meta--", "/samegame dezoom") weechat.buffer_set(samegame["buffer"], "key_bind_meta-u", "/samegame undo") try: samegame["numcolors"] = int(samegame_settings["numcolors"]) except: pass if samegame["numcolors"] < 3: samegame["numcolors"] = 3 if samegame["numcolors"] > 6: samegame["numcolors"] = 6 if samegame["buffer"]: samegame_adjust_zoom() samegame_new_game()
def rooms_create_buffer(bitlbee_server): global rooms_buffer, rooms_curline if not rooms_buffer: rooms_buffer = weechat.buffer_new("hipchat_rooms", "rooms_input_cb", "", "rooms_close_cb", "") rooms_set_buffer_title() # Sets notify to 0 as this buffer does not need to be in hotlist. weechat.buffer_set(rooms_buffer, "notify", "0") weechat.buffer_set(rooms_buffer, "nicklist", "0") weechat.buffer_set(rooms_buffer, "type", "free") weechat.buffer_set(rooms_buffer, "key_bind_ctrl-L", "/hipchat rooms **refresh") weechat.buffer_set(rooms_buffer, "key_bind_meta2-A", "/hipchat rooms **up") weechat.buffer_set(rooms_buffer, "key_bind_meta2-B", "/hipchat rooms **down") weechat.buffer_set(rooms_buffer, "key_bind_meta2-1~", "/hipchat rooms **scroll_top") weechat.buffer_set(rooms_buffer, "key_bind_meta2-4~", "/hipchat rooms **scroll_bottom") weechat.buffer_set(rooms_buffer, "key_bind_meta-ctrl-J", "/hipchat rooms **enter") weechat.buffer_set(rooms_buffer, "key_bind_meta-ctrl-M", "/hipchat rooms **enter") weechat.buffer_set(rooms_buffer, "key_bind_meta->", "/hipchat rooms **sort_next") weechat.buffer_set(rooms_buffer, "key_bind_meta-<", "/hipchat rooms **sort_previous") weechat.buffer_set(rooms_buffer, "key_bind_meta-/", "/hipchat rooms **sort_invert") weechat.buffer_set(rooms_buffer, "localvar_set_bitlbee_server", bitlbee_server) rooms_curline = 0 if weechat.config_get_plugin("autofocus") == "on": if not weechat.window_search_with_buffer(rooms_buffer): weechat.command("", "/buffer " + weechat.buffer_get_string(rooms_buffer, "name"))
def lb_create_buffer(): global lb_buffer, lb_curline if not lb_buffer: lb_buffer = weechat.buffer_new("listbuffer", "lb_input_cb", \ "", "lb_close_cb", "") lb_set_buffer_title() # Sets notify to 0 as this buffer does not need to be in hotlist. weechat.buffer_set(lb_buffer, "notify", "0") weechat.buffer_set(lb_buffer, "nicklist", "0") weechat.buffer_set(lb_buffer, "type", "free") weechat.buffer_set(lb_buffer, "key_bind_ctrl-L", "/listbuffer **refresh") weechat.buffer_set(lb_buffer, "key_bind_meta2-A", "/listbuffer **up") weechat.buffer_set(lb_buffer, "key_bind_meta2-B", "/listbuffer **down") weechat.buffer_set(lb_buffer, "key_bind_meta2-1~", "/listbuffer **scroll_top") weechat.buffer_set(lb_buffer, "key_bind_meta2-4~", "/listbuffer **scroll_bottom") weechat.buffer_set(lb_buffer, "key_bind_meta-ctrl-J", "/listbuffer **enter") weechat.buffer_set(lb_buffer, "key_bind_meta-ctrl-M", "/listbuffer **enter") weechat.buffer_set(lb_buffer, "key_bind_meta->", "/listbuffer **sort_next") weechat.buffer_set(lb_buffer, "key_bind_meta-<", "/listbuffer **sort_previous") weechat.buffer_set(lb_buffer, "key_bind_meta-/", "/listbuffer **sort_invert") lb_curline = 0 if weechat.config_get_plugin("autofocus") == "on": if not weechat.window_search_with_buffer(lb_buffer): weechat.command( "", "/buffer " + weechat.buffer_get_string(lb_buffer, "name"))
def setup_timeline(timelined, followed=False, search=False): """Sets up the main timeline window.""" global hooks global user global tlid global buffers if not search: name = "timeline" title = "%s's timeline" % user.screen_name prefix = "__TIMELINE" search = False buf_cb = "tweet_cb" else: name = search title = "Twitter search for %s" % search prefix = md5(search).hexdigest() buf_cb = "tweet_cb" buf = wc.buffer_new(name, buf_cb, "", "stop_timelined", prefix) # Some naming wc.buffer_set(buf, "title", title) # We want mentions to highlight. wc.buffer_set(buf, "highlight_words", user.screen_name) if followed: # We want a nicklist to hold everyone we follow. wc.buffer_set(buf, "nicklist", "1") add_to_nicklist(buf, user.screen_name) for screen_name in followed: add_to_nicklist(buf, screen_name) storage_dir = wc.config_get_plugin("storage_dir") command = timelined + " " + storage_dir if search: command += " '%s'" % search timelinestream_hook = wc.hook_process( command, 0, "timelined_cb", prefix) strkey = prefix + "STREAM" hooks[strkey] = timelinestream_hook # Check if there are new timeline entries every second. timelinedisplay_hook = wc.hook_timer(1 * 1000, 60, 0, "display_cb", prefix) diskey = prefix + "DISPLAY" hooks[diskey] = timelinedisplay_hook if search: wc.buffer_set(buf, "display", "1") buffers[prefix] = buf hooks['signal'] = wc.hook_signal("input_text_changed", "timeline_prompt_cb", "") if prefix is "__TIMELINE": tlid[prefix] = "timelined" else: tlid[prefix] = prefix
def setup_timeline(timelined, followed=False, search=False): """Sets up the main timeline window.""" global hooks global user global tlid global buffers if not search: name = "timeline" short_name = "twitter" title = "%s's timeline" % user.screen_name prefix = "__TIMELINE" search = False buf_cb = "tweet_cb" else: name = search short_name = search title = "Twitter search for %s" % search prefix = md5(search).hexdigest() buf_cb = "tweet_cb" buf = wc.buffer_new(name, buf_cb, "", "stop_timelined", prefix) # Some naming wc.buffer_set(buf, "title", title) wc.buffer_set(buf, "short_name", short_name) # We want mentions to highlight. wc.buffer_set(buf, "highlight_words", user.screen_name) if followed: # We want a nicklist to hold everyone we follow. wc.buffer_set(buf, "nicklist", "1") add_to_nicklist(buf, user.screen_name) for screen_name in followed: add_to_nicklist(buf, screen_name) storage_dir = wc.config_get_plugin("storage_dir") command = timelined + " " + storage_dir if search: command += " '%s'" % search timelinestream_hook = wc.hook_process(command, 0, "timelined_cb", prefix) strkey = prefix + "STREAM" hooks[strkey] = timelinestream_hook # Check if there are new timeline entries every second. timelinedisplay_hook = wc.hook_timer(1 * 1000, 60, 0, "display_cb", prefix) diskey = prefix + "DISPLAY" hooks[diskey] = timelinedisplay_hook if search: wc.buffer_set(buf, "display", "1") buffers[prefix] = buf hooks['signal'] = wc.hook_signal("input_text_changed", "timeline_prompt_cb", "") if prefix is "__TIMELINE": tlid[prefix] = "timelined" else: tlid[prefix] = prefix
def create_buffer(cls): name = "{}.{}".format(SCRIPT_BUFFER, cls.buffer_index) cls.buffer_index += 1 buffer = weechat.buffer_new(name, "term_buffer_input_cb", "", "term_buffer_close_cb", "") weechat.buffer_set(buffer, "type", "free") return buffer
def help_cb(data, buffer, args): global help_buf if help_buf is None: help_buf = weechat.buffer_new("vimode", '', '', "help_closed_cb", '') buf_num = weechat.buffer_get_integer(help_buf, "number") weechat.command('', "/buffer %s" % buf_num) weechat.prnt(help_buf, help_text) return weechat.WEECHAT_RC_OK
def create_buffer(): global BUFFER if not BUFFER: BUFFER = weechat.buffer_new(SCRIPT_NAME, 'buffer_input_cb', 'Main working window for ' + SCRIPT_NAME, 'buffer_close_cb', '') log_debug('Buffer created')
def create_slack_debug_buffer(): global slack_debug, debug_string if slack_debug != None: w.buffer_set(slack_debug, "display", "1") else: debug_string = None slack_debug = w.buffer_new("slack-debug", "", "", "closed_slack_debug_buffer_cb", "") w.buffer_set(slack_debug, "notify", "0")
def get_main_buffer(): buffer = (weechat.buffer_search('', 'server.%s' % BUFFER_NAME) or weechat.buffer_new('server.%s' % BUFFER_NAME, 'buffer_input_cb', '', 'buffer_close_cb', '')) weechat.buffer_set(buffer, 'title', 'GroupMe server buffer') weechat.buffer_set(buffer, 'localvar_set_no_log', '1') return buffer
def __init__(self, server, login = None, fd = None) : self.server = server self.login = login self.fd = fd self.buffer = weechat.buffer_new('Netsoul.temp', 'weeNS_buffer_input_cb', '', 'weeNS_buffer_close_cb', '') weechat.buffer_set(self.buffer, "display", "auto") self.updateBuffer(login) self.server.chats.append(self)
def init(): global gribble_buffer gribble_buffer = weechat.buffer_new(NAME, "", "", "", "") weechat.prnt(gribble_buffer, "Options:") for opt, val in options.iteritems(): if not weechat.config_is_set_plugin(opt): weechat.config_set_plugin(opt, val) else: options[opt] = weechat.config_get_plugin(opt) weechat.prnt(gribble_buffer, " %s: %s" % (opt, options[opt]))
def setup_viola_weechat_buffers(): """Initialize the viola control panel and debug buffers.""" global VIOLA_DEBUG_BUFFER global VIOLA_CONTROL_BUFFER if not VIOLA_CONTROL_BUFFER: VIOLA_CONTROL_BUFFER = weechat.buffer_new(otrlib.colorize("Viola Control Panel", "yellow"), "", "", "debug_buffer_close_cb", "") weechat.buffer_set(VIOLA_CONTROL_BUFFER, 'title', 'Viola Control Messages') weechat.buffer_set(VIOLA_CONTROL_BUFFER, 'localvar_set_no_log', '1') if not VIOLA_DEBUG_BUFFER: VIOLA_DEBUG_BUFFER = weechat.buffer_new("Viola Debug", "", "", "debug_buffer_close_cb", "") weechat.buffer_set(VIOLA_DEBUG_BUFFER, 'title', 'Viola Debug') weechat.buffer_set(VIOLA_DEBUG_BUFFER, 'localvar_set_no_log', '1')
def create_buffer(self): channel_buffer = w.buffer_search( "", "%s.%s" % (self.server.domain, self.name)) if channel_buffer: self.channel_buffer = channel_buffer else: self.channel_buffer = w.buffer_new( "%s.%s" % (self.server.domain, self.name), "buffer_input_cb", self.name, "", "") w.buffer_set(self.channel_buffer, "short_name", 'loading..')
def setup_flute_weechat_buffers(): """Initialize the flute control panel and debug buffers.""" global FLUTE_DEBUG_BUFFER global FLUTE_CONTROL_BUFFER if not FLUTE_CONTROL_BUFFER: FLUTE_CONTROL_BUFFER = weechat.buffer_new(otrlib.colorize("Flute Control Panel", "yellow"), "", "", "debug_buffer_close_cb", "") weechat.buffer_set(FLUTE_CONTROL_BUFFER, 'title', 'Flute Control Messages') weechat.buffer_set(FLUTE_CONTROL_BUFFER, 'localvar_set_no_log', '1') if not FLUTE_DEBUG_BUFFER: FLUTE_DEBUG_BUFFER = weechat.buffer_new("Flute Debug", "", "", "debug_buffer_close_cb", "") weechat.buffer_set(FLUTE_DEBUG_BUFFER, 'title', 'Flute Debug') weechat.buffer_set(FLUTE_DEBUG_BUFFER, 'localvar_set_no_log', '1')
def open_buffer(bufname): if not buffers[bufname]: buffers[bufname] = weechat.buffer_new(BUFFERNAMES[bufname], "", "", "buffer_close_cb", bufname) weechat.buffer_set(buffers[bufname], "title", "{} buffer for {}".format(bufname, NETWORK)) if NOLOG: weechat.buffer_set(buffers[bufname], "localvar_set_no_log", "1") if RELAYHIDE: weechat.buffer_set(buffers[bufname], "localvar_set_relay", "hard-hide")
def create_buffer(self): channel_buffer = w.buffer_search("", "%s.%s" % (self.server.domain, self.name)) if channel_buffer: self.channel_buffer = channel_buffer else: self.channel_buffer = w.buffer_new("%s.%s" % (self.server.domain, self.name), "buffer_input_cb", self.name, "", "") if self.type == "im": w.buffer_set(self.channel_buffer, "localvar_set_type", 'private') else: w.buffer_set(self.channel_buffer, "localvar_set_type", 'channel') w.buffer_set(self.channel_buffer, "short_name", 'loading..')
def setup_flute_weechat_buffers(): """Initialize the flute control panel and debug buffers.""" global FLUTE_DEBUG_BUFFER global FLUTE_CONTROL_BUFFER if not FLUTE_CONTROL_BUFFER: FLUTE_CONTROL_BUFFER = weechat.buffer_new( otrlib.colorize("Flute Control Panel", "yellow"), "", "", "debug_buffer_close_cb", "") weechat.buffer_set(FLUTE_CONTROL_BUFFER, 'title', 'Flute Control Messages') weechat.buffer_set(FLUTE_CONTROL_BUFFER, 'localvar_set_no_log', '1') if not FLUTE_DEBUG_BUFFER: FLUTE_DEBUG_BUFFER = weechat.buffer_new("Flute Debug", "", "", "debug_buffer_close_cb", "") weechat.buffer_set(FLUTE_DEBUG_BUFFER, 'title', 'Flute Debug') weechat.buffer_set(FLUTE_DEBUG_BUFFER, 'localvar_set_no_log', '1')
def debug(s, args=(), prefix='', name_suffix='debug', level=1): """Debug msg""" l = weechat.config_get_plugin('debug') if not (l and int(l) >= level): return buffer_name = '%s_%s' %(SCRIPT_NAME, name_suffix) buffer = weechat.buffer_search('python', buffer_name) if not buffer: buffer = weechat.buffer_new(buffer_name, '', '', '', '') weechat.buffer_set(buffer, 'nicklist', '0') weechat.buffer_set(buffer, 'localvar_set_no_log', '1') weechat.prnt(buffer, '%s\t%s' %(prefix, s %args))
def logger_buffer_open(): # Search for an existing buffer logBuffer = weechat.buffer_search(NAME, BUFFERNAME) # Make a new buffer if one doesn't exist already if (logBuffer == ""): # Create new buffer for URLs logBuffer = weechat.buffer_new(BUFFERNAME, "buffer_input_cb", "", "buffer_close_cb", "") # Set the title weechat.buffer_set(logBuffer, "title", "URL Logger") return weechat.WEECHAT_RC_OK
def vdm_buffer_create(): """ Create VDM buffer. """ global vdm_buffer vdm_buffer = weechat.buffer_search("python", "vdm") if vdm_buffer == "": vdm_buffer = weechat.buffer_new("vdm", "vdm_buffer_input", "", "vdm_buffer_close", "") if vdm_buffer != "": vdm_buffer_set_title() weechat.buffer_set(vdm_buffer, "localvar_set_no_log", "1") weechat.buffer_set(vdm_buffer, "time_for_each_line", "0")
def debug(s, prefix=''): """Debug msg""" if not weechat.config_get_plugin('debug'): return buffer_name = 'DEBUG_' + SCRIPT_NAME buffer = weechat.buffer_search('python', buffer_name) if not buffer: buffer = weechat.buffer_new(buffer_name, '', '', '', '') weechat.buffer_set(buffer, 'nicklist', '0') weechat.buffer_set(buffer, 'time_for_each_line', '0') weechat.buffer_set(buffer, 'localvar_set_no_log', '1') weechat.prnt(buffer, '%s\t%s' %(prefix, s))
def cs_get_buffer(): global cs_buffer if not cs_buffer: # Sets notify to 0 as this buffer does not need to be in hotlist. cs_buffer = weechat.buffer_new("clone_scanner", "", \ "", SCRIPT_CLOSE_CB, "") weechat.buffer_set(cs_buffer, "title", "Clone Scanner") weechat.buffer_set(cs_buffer, "notify", "0") weechat.buffer_set(cs_buffer, "nicklist", "0") return cs_buffer
def himan_buffer_create(): global himan_buffer himan_buffer = w.buffer_new('himan', 'himan_input_cb', '', 'himan_buffer_close', '') w.buffer_set(himan_buffer, 'title', '-[Hi, man! v' + SCRIPT_VERSION + ']- ' + SCRIPT_DESC) w.buffer_set(himan_buffer, 'nicklist', '0') # configurable option to set buffer notify on or off w.buffer_set(himan_buffer, 'notify', '0') if cg('notify') == 'on': w.buffer_set(himan_buffer, 'notify', '1')
def playlist(self, *args): def ifn( b, s, d): wc.prnt(b, Template(s).safe_substitute(d)) def cfn(): wc.prnt(None, "mpc closing playlist buffer") new_buf = wc.buffer_new('mpc: playlist', "ifn", "", "cfn", "") wc.buffer_set(new_buf, "localvar_set_no_log", "1") pl = self._mpdc.playlist() for line in pl: wc.prnt(new_buf, line) wc.buffer_set(new_buf, "display", "1") return pl
def __init__(self, server, name, identifier, members=[]): self.server = server self.name = name self.identifier = identifier self.members = set(members) self.pointer = w.buffer_new(name, "buffer_input_cb", "", "buffer_close_cb", "") self.last_id = None rooms.append(self) async_http_get_request(_domain, server.token, "rooms/{}/messages?reverse=false".format(identifier)) rooms_by_id[identifier] = name rooms.update_hashtable() dbg("Creating room {}".format(self))
def get_buffer(nick, overwrite_name=False): """Get the buffer for a nick or create it if it doesn't exist""" buffer = buffers.get(nick.lower()) name = get_name(nick) if buffer is None: buffer = weechat.buffer_new( "TWITCH-WHISPER." + name, "handle_whisper_buffer_input", name, "handle_whisper_buffer_close", name ) weechat.buffer_set(buffer, "short_name", name) buffers[nick.lower()] = buffer elif overwrite_name: weechat.buffer_set(buffer, "short_name", nick) return buffer
def buffer_create(): """Returns our buffer pointer, creates and cleans the buffer if needed.""" buffer = weechat.buffer_search('python', SCRIPT_NAME) if not buffer: buffer = weechat.buffer_new(SCRIPT_NAME, 'buffer_input', '', 'buffer_close', '') weechat.buffer_set(buffer, 'time_for_each_line', '0') weechat.buffer_set(buffer, 'nicklist', '0') weechat.buffer_set(buffer, 'title', 'egrep output buffer') weechat.buffer_set(buffer, 'localvar_set_no_log', '1') else: if get_config_boolean('clear_buffer'): weechat.buffer_clear(buffer) return buffer
def infolist_buffer_new(): global infolist_buffer infolist_buffer = weechat.buffer_search("python", "infolist") if infolist_buffer == "": infolist_buffer = weechat.buffer_new("infolist", "infolist_buffer_input_cb", "", "infolist_buffer_close_cb", "") if infolist_buffer != "": infolist_buffer_set_title(infolist_buffer) weechat.buffer_set(infolist_buffer, "localvar_set_no_log", "1") weechat.buffer_set(infolist_buffer, "time_for_each_line", "0") weechat.buffer_set(infolist_buffer, "display", "1")
def shell_new_buffer(): """Create shell buffer.""" global cmd_shell_buffer cmd_shell_buffer = weechat.buffer_search('python', 'shell') if not cmd_shell_buffer: cmd_shell_buffer = weechat.buffer_new('shell', 'shell_input_buffer', '', 'shell_close_buffer', '') if cmd_shell_buffer: shell_set_title() weechat.buffer_set(cmd_shell_buffer, 'localvar_set_no_log', '1') weechat.buffer_set(cmd_shell_buffer, 'time_for_each_line', '0') weechat.buffer_set(cmd_shell_buffer, 'input_get_unknown_commands', '1') weechat.buffer_set(cmd_shell_buffer, 'display', '1') return cmd_shell_buffer
def __init__(self, options): self.status_name = options['server_name'] self.nick_name = options['nickname'] self.is_away = False global debug if options['debug'] == "true": debug = True else: debug = False self.private_chans = {} self.private_chans_ptr = {} self.status = weechat.buffer_new(self.status_name, "status_input_cb", "", "status_close_cb", "") weechat.buffer_set(self.status, "localvar_set_type", "server") weechat.buffer_set(self.status, "localvar_set_server", "keybase") self.init_chats() #self.get_history() self.reader = weechat.hook_process_hashtable("keybase chat api-listen", {"buffer_flush": "1"}, 0, "start_reading", "") weechat.hook_command( "download", "Download an attachment", "<msg_id> <outputh_path>", "<msg_id>: ID of the message\n<output_path>: Path to store file", "", "download_message", "") weechat.hook_command("open", "Open (with default application) an attachment", "<msg_id>", "<msg_id>: ID of the message\n", "", "open_attachment", "") weechat.hook_command("attach", "Upload file to conversation", "<filename>", "<filename>: File to upload\n", "", "attach_file", "") weechat.hook_command( "re", "Reply to message", "<msg_id> <reply_message>", "<msg_id>: ID of the message to which reply\n<reply_message>: reply", "", "reply_message_buffer", "") weechat.hook_command("delete", "Delete message", "<msg_id>", "<msg_id>: ID of the message to which reply", "", "delete_message_buffer", "") weechat.hook_command( ":", "React to message", "<reaction> <msg_id>", "<reaction>: Keybase Reaction alias\n<msg_id>: ID of the message to which reply", "", "react_to_message", "") weechat.hook_command("reload", "", "", "", "", "reload_conversation", "") ## Hooking to classic weechat command # weechat.hook_command_run("/msg","send_new_message","") weechat.hook_command_run("/away", "away_command_cb", "") weechat.hook_signal("buffer_switch", "buffer_switched", "") weechat.hook_signal("window_scrolled", "window_scrolled", "")
def buffer_get(): """Finds or creates a buffer to use for script output. Returns a buffer pointer. """ buffer = weechat.buffer_search('python', SCRIPT_NAME) if not buffer: buffer = weechat.buffer_new(SCRIPT_NAME, 'buffer_input', '', '', '') weechat.buffer_set(buffer, 'time_for_each_line', '0') weechat.buffer_set(buffer, 'nicklist', '0') weechat.buffer_set(buffer, 'title', 'Google Calendar') weechat.buffer_set(buffer, 'localvar_set_no_log', '1') return buffer