Beispiel #1
0
def scroll_cb(data_ptr, remaining_calls):
    display_fin.pop(0)
    cadena = ''
    for character in display_fin:
        cadena += character
    weechat.buffer_set(weechat.current_buffer(), 'title', cadena)
    return weechat.WEECHAT_RC_OK
def input_delete_cb(data, signal, signal_data):
    buffer = signal
    delete_localvar_replace_mode(buffer)
    weechat.buffer_set(buffer, 'localvar_del_spell_correction_suggest_item', '')
    weechat.buffer_set(buffer, 'localvar_del_spell_correction_suggest_input_line', '')
    weechat.bar_item_update('spell_correction')
    return weechat.WEECHAT_RC_OK
Beispiel #3
0
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
Beispiel #4
0
    def run(self):
        self.pid, fd = self.fork()

        self.hook_fd = weechat.hook_fd(fd, 1, 0, 0, "term_fd_cb", self.buffer)
        self.f = os.fdopen(fd, "w+b", 0)

        weechat.buffer_set(self.buffer, "display", "1") # switch to buffer
Beispiel #5
0
def switch_current_buffer():
    """Save current buffer and ensure that it's visible, then if the
    buffer is elegible to be hidden, we add it to the list of the buffers
    to be hidden after a delay
    """
    global CURRENT_BUFFER
    global CURRENT_BUFFER_TIMER_HOOK

    previous_buffer = CURRENT_BUFFER
    CURRENT_BUFFER = weechat.current_buffer()

    if previous_buffer == CURRENT_BUFFER:
        return

    if weechat.buffer_get_integer(CURRENT_BUFFER, "hidden") == 1:
        weechat.buffer_set(CURRENT_BUFFER, "hidden", "0")

    if weechat.config_get_plugin("keep_open") != "off":
        if CURRENT_BUFFER_TIMER_HOOK is not None:
            weechat.unhook(CURRENT_BUFFER_TIMER_HOOK)
            CURRENT_BUFFER_TIMER_HOOK = None
            maybe_hide_buffer(previous_buffer)
        else:
            keep_alive_buffer(previous_buffer)

        CURRENT_BUFFER_TIMER_HOOK = weechat.hook_timer(MINIMUM_BUFFER_LIFE, 0, 1,
            "on_current_buffer_is_still_active_timeout", "")
    else:
        maybe_hide_buffer(previous_buffer)
Beispiel #6
0
def vdm_parse(string):
    """ Parse XML output from HTTP output string. """
    global vdm_buffer, vdm_switch_to_buffer
    vdm = []
    try:
        dom = xml.dom.minidom.parseString(string)
    except:
        weechat.prnt(
            vdm_buffer, "%sError reading data from website (maybe it's down? "
            "please try again later)" % weechat.prefix("error"))
        if vdm_switch_to_buffer:
            weechat.buffer_set(vdm_buffer, "display", "1")
    else:
        for node in dom.getElementsByTagName("item"):
            texte = node.getElementsByTagName("text")
            if texte:
                vdm.append({
                    "id":
                    node.getAttribute("id"),
                    "text":
                    texte[0].firstChild.data.replace("\n", " ").replace(
                        """, "\"")
                })
        dom.unlink()
    return vdm
Beispiel #7
0
def unread_buffer_cb(data, buffer, args):

    arguments = args.lower().split(' ')
    if not len(arguments) == 2:
        return weechat.WEECHAT_RC_OK

    if arguments[0] == 'low':
        priority = "0"
    elif arguments[0] == 'message':
        priority = "1"
    elif arguments[0] == 'private':
        priority = "2"
    elif arguments[0] == 'highlight':
        priority = "3"
    elif arguments[0] == 'remove':
        priority = "-1"
    else:
        return weechat.WEECHAT_RC_OK
    # search for either buffer_name or buffer_number
    ptr_buffer = buffer_infolist(arguments[1])

    weechat.buffer_set(ptr_buffer, "hotlist", "-1")
    weechat.buffer_set(ptr_buffer, "hotlist", priority)

    return weechat.WEECHAT_RC_OK
def on_print_callback(data, buffer, date, tags, displayed, highlight, prefix,
                      message):
    """Hook the messages printed to weechat and uses the given buffer, tags, highlight status, and message to highlight the next few messages sent by the highlighted nick."""
    if int(highlight):
        m = re.search(",(?P<nickname>nick_\S+?),", tags)
        if not m:
            return weechat.WEECHAT_RC_OK

        nicktag = m.group('nickname')
        if nicktag and newHighlight(buffer, nicktag):
            # Add nick tag to highlight_tags
            current_highlight_tags = weechat.buffer_get_string(
                buffer, "highlight_tags")
            if not current_highlight_tags:
                new_tags = nicktag
            else:
                new_tags = "{},{}".format(current_highlight_tags, nicktag)
            weechat.buffer_set(buffer, "highlight_tags", new_tags)
            decrementRemainingMessages(buffer, nicktag)
        elif shouldRefresh(message):
            refreshRemainingMessages(buffer, nicktag)
        elif highlightTimedOut(buffer, nicktag):
            highlight_tags = weechat.buffer_get_string(buffer,
                                                       "highlight_tags")
            new_tags = re.sub(nicktag, '', highlight_tags)
            # This may or may not be super bad if tags are allowed to have commas
            new_tags = re.sub(",,", ",", new_tags)
            weechat.buffer_set(buffer, "highlight_tags", new_tags)
            resetRemainingMessages(buffer, nicktag)
        else:
            decrementRemainingMessages(buffer, nicktag)

    return weechat.WEECHAT_RC_OK
Beispiel #9
0
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, "")
Beispiel #10
0
def command_run_input(data, buffer, command):
    """ Function called when a command "/input xxxx" is run """
    if command == "/input return":  # As in enter was pressed.

        # Get input contents
        input_s = w.buffer_get_string(buffer, "input")

        # Skip modification of settings
        if input_s.startswith("/set "):
            return w.WEECHAT_RC_OK

        # Iterate transformation pairs
        for replace_item in w.config_get_plugin("replacement_pairs").split(","):
            if replace_item:
                orig, replaced = replace_item.split("=")
                input_s = input_s.replace(orig, replaced)
        # Iterate words
        for replace_item in w.config_get_plugin("replacement_words").split(","):
            if replace_item:
                orig, replaced = replace_item.split("=")
                # Search for whitespace+word+whitespace and replace the word
                input_s = re.sub("(\s+|^)%s(\s+|$)" % orig, "\\1%s\\2" % replaced, input_s)

        # Spit it out
        w.buffer_set(buffer, "input", input_s)
    return w.WEECHAT_RC_OK
Beispiel #11
0
 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..')
Beispiel #12
0
def command_run_input(data, buffer, command):
    """ Function called when a command "/input xxxx" is run """
    if command == "/input return":  # As in enter was pressed.

        # Get input contents
        input_s = w.buffer_get_string(buffer, 'input')

        # Skip modification of settings
        if input_s.startswith('/set '):
            return w.WEECHAT_RC_OK

        # Iterate transformation pairs
        for replace_item in w.config_get_plugin('replacement_pairs').split(
                ','):
            if replace_item:
                orig, replaced = replace_item.split('=')
                input_s = input_s.replace(orig, replaced)
        # Iterate words
        for replace_item in w.config_get_plugin('replacement_words').split(
                ','):
            if replace_item:
                orig, replaced = replace_item.split('=')
                # Search for whitespace+word+whitespace and replace the word
                input_s = re.sub('(\s+|^)%s(\s+|$)' % orig,
                                 '\\1%s\\2' % replaced, input_s)

        # Spit it out
        w.buffer_set(buffer, 'input', input_s)
    return w.WEECHAT_RC_OK
Beispiel #13
0
def unhide_buffer_cb(data, signal, signal_data):
    """Unhide a buffer on new activity.

    This callback unhides a buffer in which a new message has been received.
    If configuration option ``unhide_low`` is enabled,
    buffers with only low priority messages (like JOIN, PART, etc.) will be unhidden as well.

    :param data: Pointer
    :param signal: Signal sent by Weechat
    :param signal_data: Data sent with signal
    :returns: Callback return value expected by Weechat.
    """
    hotlist = hotlist_dict()
    line_data = weechat.hdata_pointer(weechat.hdata_get('line'), signal_data, 'data')
    buffer = weechat.hdata_pointer(weechat.hdata_get('line_data'), line_data, 'buffer')

    if not buffer in hotlist.keys():
        # just some background noise
        return WEECHAT_RC_OK

    if (weechat.config_get_plugin("unhide_low") == "on"
            and hotlist[buffer]["count_low"] > 0
            or hotlist[buffer]["count_message"] > 0
            or hotlist[buffer]["count_private"] > 0
            or hotlist[buffer]["count_highlight"] > 0):
        remove_keep_alive(buffer)
        weechat.buffer_set(buffer, "hidden", "0")

    return WEECHAT_RC_OK
Beispiel #14
0
def bas_config_option_cb(data, option, value):
    if not weechat.config_boolean(bas_options["look_instant"]):
        return weechat.WEECHAT_RC_OK

    if not weechat.config_get(option):  # option was deleted
        return weechat.WEECHAT_RC_OK

    option = option[len("%s.buffer." % CONFIG_FILE_NAME):]

    pos = option.rfind(".")
    if pos > 0:
        buffer_mask = option[0:pos]
        property = option[pos+1:]
        if buffer_mask and property:
            buffers = weechat.infolist_get("buffer", "", buffer_mask)

            if not buffers:
                return weechat.WEECHAT_RC_OK

            while weechat.infolist_next(buffers):
                buffer = weechat.infolist_pointer(buffers, "pointer")
                weechat.buffer_set(buffer, property, value)

            weechat.infolist_free(buffers)

    return weechat.WEECHAT_RC_OK
Beispiel #15
0
def game_api(data, command, rc, stdout, stderr):
    try:
        jsonDict = json.loads(stdout.strip())
    except Exception as e:
        weechat.prnt(
            data, '%stwitch.py: error communicating with twitch api' %
            weechat.prefix('error'))
        if OPTIONS['debug']:
            weechat.prnt(
                data,
                '%stwitch.py: return code: %s' % (weechat.prefix('error'), rc))
            weechat.prnt(
                data,
                '%stwitch.py: stdout: %s' % (weechat.prefix('error'), stdout))
            weechat.prnt(
                data,
                '%stwitch.py: stderr: %s' % (weechat.prefix('error'), stderr))
            weechat.prnt(
                data,
                '%stwitch.py: exception: %s' % (weechat.prefix('error'), e))
        return weechat.WEECHAT_RC_OK

    if 'data' in jsonDict.keys():
        if not jsonDict['data']:
            return weechat.WEECHAT_RC_OK
        if len(jsonDict['data']) == 1:
            jsonDict['data'] = jsonDict['data'][0]
        old_title = weechat.buffer_get_string(data, "title")
        id = jsonDict['data']['id']
        name = makeutf8(jsonDict['data']['name'])
        new_title = old_title.replace('<{}>'.format(id), '<{}>'.format(name))
        weechat.buffer_set(data, "title", new_title)
        gameid_cache[id] = name
    return weechat.WEECHAT_RC_OK
Beispiel #16
0
def input_set(data, remaining_calls):
    """Set the input line's content."""
    buf = weechat.current_buffer()
    weechat.buffer_set(buf, "input", data)
    # move the cursor back to its position prior to setting the content
    weechat.command('', "/input move_next_char")
    return weechat.WEECHAT_RC_OK
Beispiel #17
0
def go_end(buf):
    """End go on buffer."""
    global saved_input, saved_input_pos, old_input
    go_unhook_all()
    weechat.buffer_set(buf, 'input', saved_input)
    weechat.buffer_set(buf, 'input_pos', str(saved_input_pos))
    old_input = None
Beispiel #18
0
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, "")
def input_text_changed_cb(data, signal, signal_data):
    global multiline_input

    if multiline_input == "1":
        return weechat.WEECHAT_RC_OK

    buffer = signal_data
    if not buffer:
        return weechat.WEECHAT_RC_OK

    tab_complete, position, aspell_suggest_item = get_position_and_suggest_item(buffer)
    if not position or not aspell_suggest_item:
        return weechat.WEECHAT_RC_OK

    # 1 = cursor etc., 2 = TAB
    if tab_complete != "0":
        if not aspell_suggest_item:
            aspell_suggest_item = ""
        weechat.buffer_set(
            buffer, "localvar_set_spell_correction_suggest_item", "%s:%s:%s" % ("0", position, aspell_suggest_item)
        )
        weechat.bar_item_update("spell_correction")
        return weechat.WEECHAT_RC_OK

    if OPTIONS["auto_replace"].lower() == "on":
        replace_misspelled_word(buffer)  # also remove localvar_suggest_item
        return weechat.WEECHAT_RC_OK

    #    weechat.buffer_set(buffer, 'localvar_set_spell_correction_suggest_item', '%s:%s:' % ('0','-1'))
    weechat.bar_item_update("spell_correction")
    return weechat.WEECHAT_RC_OK
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
Beispiel #21
0
def command_run_input(data, buffer, command):
    """ Function called when a command "/input xxxx" is run """
    if command == "/input return":  # As in enter was pressed.

        # Get input contents
        input_s = w.buffer_get_string(buffer, 'input')

        # Skip modification of settings
        if input_s.startswith('/'):
            return w.WEECHAT_RC_OK

        yubistring = w.config_get_plugin('yubistring')

        if yubistring != '':

            # if it's longer than 6 characters, chop it down.
            if len(yubistring) > 6:
                yubistring = yubistring[:6]

            if input_s.startswith(yubistring) and len(input_s) == 44:
                input_s = ''

        # Spit it out
        w.buffer_set(buffer, 'input', input_s)
    return w.WEECHAT_RC_OK
Beispiel #22
0
def reorder_buffers():
    global buffers
    bufcopy = dict(buffers)
    priolist = []
    while len(bufcopy):
        priolist.append(max(bufcopy, key=bufcopy.get))
        bufcopy.pop(max(bufcopy, key=bufcopy.get))
    pointerlist = {}
    infolist = wee.infolist_get("buffer", "", "")
    while wee.infolist_next(infolist): # go through the buffers and jot down relevant pointers
        for name in priolist:
            try:
                bufname = wee.infolist_string(infolist, "name").split('.', 1)[1]
            except IndexError:
                bufname = wee.infolist_string(infolist, "name")
            if name == bufname:
                if name in pointerlist:
                    pointerlist[name].append(
                            wee.infolist_pointer(infolist, "pointer"))
                else:
                    pointerlist[name] = [wee.infolist_pointer(
                        infolist, "pointer")]

    index = 1
    if(maintop):
        index += 1
    for name in priolist:
        if name in pointerlist:
            for pointer in pointerlist[name]:
                wee.buffer_set(pointer, "number", str(index))
                index += 1
    return
Beispiel #23
0
def unhide_buffer_cb(data, signal, signal_data):
    """Unhide a buffer on new activity.

    This callback unhides the buffer in which a new message has been received.
    If configuration option ``unhide_low`` is enabled,
    buffers with only low messages (like JOIN, PART, etc.) will be unhidden as well.
    """
    server = signal.split(",")[0]
    message = weechat.info_get_hashtable(
        "irc_message_parse",
        {"message": signal_data})
    channel = message["channel"]
    hotlist = hotlist_dict()
    buffer = weechat.info_get("irc_buffer", "{},{}".format(server, channel))

    if not buffer in hotlist.keys():
        # just some background noise
        return WEECHAT_RC_OK

    if (weechat.config_get_plugin("unhide_low") == "on"
            and hotlist[buffer]["count_low"] > 0
            or hotlist[buffer]["count_message"] > 0
            or hotlist[buffer]["count_private"] > 0
            or hotlist[buffer]["count_highlight"] > 0):
        weechat.buffer_set(buffer, "hidden", "0")

    return WEECHAT_RC_OK
Beispiel #24
0
def go_end(buffer):
    """ End go on buffer """
    global saved_input, saved_input_pos, old_input
    unhook_all()
    weechat.buffer_set(buffer, "input", saved_input)
    weechat.buffer_set(buffer, "input_pos", str(saved_input_pos))
    old_input = None
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 = '%s@%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
Beispiel #26
0
def reorder_buffers():
    """Reorders the buffers once the whitelist has changed
    """

    count = 2
    chan = ""

    ilist = weechat.infolist_get("buffer", "", "")

    for chan in whitelist:
        if -1 == chan.find(".#"): #network name is not set, matching by short_name
            weechat.infolist_reset_item_cursor(ilist)

            while weechat.infolist_next(ilist):
                if weechat.infolist_string(ilist, "short_name") == chan:
                    chan = weechat.infolist_string(ilist, "name")
                    break

        buff = weechat.buffer_search("irc", chan)

        if buff:
            weechat.buffer_set(buff, "number", str(count))
            count += 1

    weechat.infolist_free(ilist)

    return weechat.WEECHAT_RC_OK
Beispiel #27
0
def aspell_suggest_cb(data, signal, signal_data):
    buffer = signal_data
    if OPTIONS['replace_mode'].lower() == 'on':
        localvar_aspell_suggest = get_localvar_aspell_suggest(buffer)
        if localvar_aspell_suggest:
            # aspell says, suggested word is also misspelled. check out if we already have a suggestion list and don't use the new misspelled word!
            if weechat.buffer_get_string(buffer,
                                         'localvar_inline_suggestions'):
                return weechat.WEECHAT_RC_OK
            if not ":" in localvar_aspell_suggest:
                return weechat.WEECHAT_RC_OK
            misspelled_word, aspell_suggestions = localvar_aspell_suggest.split(
                ':')
            aspell_suggestions = aspell_suggestions.replace('/', ',')
            weechat.buffer_set(buffer, 'localvar_set_inline_suggestions',
                               '%s:%s:%s' % ('2', '0', aspell_suggestions))
            weechat.bar_item_update('spell_suggestion')
            return weechat.WEECHAT_RC_OK

    if OPTIONS['auto_pop_up_item'].lower() == 'on':
        auto_suggest_cmd_cb('', buffer, '')
        weechat.buffer_set(buffer,
                           'localvar_del_spell_correction_suggest_input_line',
                           '')
    weechat.bar_item_update('spell_suggestion')
    return weechat.WEECHAT_RC_OK
Beispiel #28
0
def replace_misspelled_word(buffer):
    input_line = weechat.buffer_get_string(
        buffer, 'localvar_spell_correction_suggest_input_line')
    if not input_line:
        # remove spell_correction item
        weechat.buffer_set(buffer,
                           'localvar_del_spell_correction_suggest_item', '')
        weechat.bar_item_update('spell_correction')
        weechat.bar_item_update('spell_suggestion')
        return
    if OPTIONS['eat_input_char'].lower() == 'off' or input_line == '':
        input_pos = weechat.buffer_get_integer(buffer, 'input_pos')
        # check cursor position
        if len(input_line) < int(input_pos) or input_line[
                int(input_pos) - 1] == ' ' or input_line == '':
            input_line = weechat.buffer_get_string(buffer, 'input')

    weechat.buffer_set(buffer,
                       'localvar_del_spell_correction_suggest_input_line', '')

    localvar_aspell_suggest = get_localvar_aspell_suggest(buffer)

    # localvar_aspell_suggest = word,word2/wort,wort2
    if localvar_aspell_suggest:
        misspelled_word, aspell_suggestions = localvar_aspell_suggest.split(
            ':')
        aspell_suggestions = aspell_suggestions.replace('/', ',')
        aspell_suggestion_list = aspell_suggestions.split(',')
    else:
        return

    tab_complete, position, aspell_suggest_item = get_position_and_suggest_item(
        buffer)
    if not position or not aspell_suggest_item:
        return

    position = int(position)

    input_line = input_line.replace(misspelled_word,
                                    aspell_suggestion_list[position])
    if input_line[-2:] == '  ':
        input_line = input_line.rstrip()
        input_line = input_line + ' '

    weechat.buffer_set(buffer, 'input', input_line)

    # set new cursor position. check if suggestion is longer or smaller than misspelled word
    input_pos = weechat.buffer_get_integer(buffer, 'input_pos') + 1
    length_misspelled_word = len(misspelled_word)
    length_suggestion_word = len(aspell_suggestion_list[position])

    if length_misspelled_word < length_suggestion_word:
        difference = length_suggestion_word - length_misspelled_word
        new_position = input_pos + difference + 1
        weechat.buffer_set(buffer, 'input_pos', str(new_position))

    weechat.buffer_set(buffer, 'localvar_del_spell_correction_suggest_item',
                       '')
    weechat.bar_item_update('spell_suggestion')
    weechat.bar_item_update('spell_correction')
Beispiel #29
0
def switch_current_buffer():
    """Save current buffer and ensure that it's visible, then if the
    buffer is elegible to be hidden, we add it to the list of the buffers
    to be hidden after a delay
    """
    global CURRENT_BUFFER
    global CURRENT_BUFFER_TIMER_HOOK

    previous_buffer = CURRENT_BUFFER
    CURRENT_BUFFER = weechat.current_buffer()

    if previous_buffer == CURRENT_BUFFER:
        return

    if weechat.buffer_get_integer(CURRENT_BUFFER, "hidden") == 1:
        weechat.buffer_set(CURRENT_BUFFER, "hidden", "0")

    if weechat.config_get_plugin("keep_open") != "off":
        if CURRENT_BUFFER_TIMER_HOOK is not None:
            weechat.unhook(CURRENT_BUFFER_TIMER_HOOK)
            CURRENT_BUFFER_TIMER_HOOK = None
            maybe_hide_buffer(previous_buffer)
        else:
            keep_alive_buffer(previous_buffer)

        CURRENT_BUFFER_TIMER_HOOK = weechat.hook_timer(
            MINIMUM_BUFFER_LIFE, 0, 1,
            "on_current_buffer_is_still_active_timeout", "")
    else:
        maybe_hide_buffer(previous_buffer)
Beispiel #30
0
def go_end(buf):
    """End go on buffer."""
    global saved_input, saved_input_pos, old_input
    go_unhook_all()
    weechat.buffer_set(buf, 'input', saved_input)
    weechat.buffer_set(buf, 'input_pos', str(saved_input_pos))
    old_input = None
Beispiel #31
0
def scroll_cb(data_ptr, remaining_calls):
    display_fin.pop(0)
    cadena = ''
    for character in display_fin:
        cadena += character
    weechat.buffer_set(weechat.current_buffer(), 'title', cadena)
    return weechat.WEECHAT_RC_OK
Beispiel #32
0
def weetris_cmd_cb(data, buf, args):
    """Callback for command /weetris."""
    if weetris['buffer']:
        weechat.buffer_set(weetris['buffer'], 'display', '1')
    else:
        weetris_init()

    if args == 'new_game':
        new_game()
    elif args == 'pause':
        if weetris['playing']:
            weetris['paused'] = not weetris['paused']
            display_all()
    else:
        if weetris['playing'] and not weetris['paused']:
            key_slow_down = weetris_settings['key_down_slow'] == 'on'
            actions = {
                'up': 'rotate',
                'left': 'left',
                'right': 'right',
                'down': 'down' if key_slow_down else 'bottom',
                'bottom': 'bottom' if key_slow_down else 'down',
            }
            action = actions.get(args)
            if action:
                run_action(action)
    return weechat.WEECHAT_RC_OK
Beispiel #33
0
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
Beispiel #34
0
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
Beispiel #35
0
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
Beispiel #36
0
def buffer_update(buffer):
    """
    Refresh filtering in "buffer" by updating (or removing) the filter and update the bar item.
    """

    hdata = weechat.hdata_get("buffer")

    buffers = ",".join(get_merged_buffers(buffer))
    name = "%s_%s" % (SCRIPT_NAME, buffers)

    if buffer_searching(buffer):
        if buffer_filtering(buffer):
            filter_addreplace(name, buffers, "*", buffer_build_regex(buffer))
        elif not buffer_filtering(buffer) and filter_exists(name):
            filter_del(name)
    elif filter_exists(name):
        filter_del(name)

    where = weechat.hdata_integer(hdata, buffer, "text_search_where")
    weechat.buffer_set(
        buffer,
        "localvar_set_%s_warn" % SCRIPT_LOCALVAR,
        "1" if where == 3 else "0",
    )  # warn about incorrect filter

    weechat.bar_item_update(SCRIPT_BAR_ITEM)
Beispiel #37
0
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
def aspell_suggest_cb(data, signal, signal_data):
    buffer = signal_data
    if OPTIONS["auto_pop_up_item"].lower() == "on":
        auto_suggest_cmd_cb("", buffer, "")
        weechat.buffer_set(buffer, "localvar_del_spell_correction_suggest_input_line", "")
    weechat.bar_item_update("spell_suggest")
    return weechat.WEECHAT_RC_OK
Beispiel #39
0
def all_cmd_cb(data, buffer, args):
	''' Command /all '''
	translate_input = args
	if not translate_input:
	   translate_input = weechat.buffer_get_string(buffer, "input")

	channel = weechat.buffer_get_string(buffer, 'localvar_channel')
	server = weechat.buffer_get_string(buffer, 'localvar_server')

	joined_nick=""
	infolist = weechat.infolist_get("irc_nick", "", server+","+channel)
	if infolist:
		while weechat.infolist_next(infolist):
			name = weechat.infolist_string(infolist, "name")
			weechat.prnt("", "buffer: %s" % name)
			joined_nick += name+" "

		weechat.infolist_free(infolist)

	translate_input=joined_nick +": "+ translate_input
	
	#outstring = translate_input.encode('UTF-8')
	outstring = translate_input
	weechat.buffer_set(buffer, 'input', outstring)
	weechat.buffer_set(buffer, 'input_pos', '%d' % len(outstring))
	return weechat.WEECHAT_RC_OK
Beispiel #40
0
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
Beispiel #41
0
def complete_cb(data, bufferptr, command):
    """ Apply transformation to input line in specified buffer """

    if command != "/input complete_next":
        return weechat.WEECHAT_RC_OK

    line = decode(weechat.buffer_get_string(bufferptr, 'input'))
    caret_pos = weechat.buffer_get_integer(bufferptr, 'input_pos')

    match = re.search('(:\w+$)', line[:caret_pos])
    if not match:
        return weechat.WEECHAT_RC_OK

    # tw = tabbed word
    tw = match.group(0)
    tw_length = len(tw)
    tw_start = caret_pos - tw_length
    tw_end = caret_pos

    completion = ""
    for key, value in EMOJIS.iteritems():
        if key.startswith(tw):
            completion = decode(value)
            break

    if completion:
        line = line[:tw_start] + completion + line[tw_end:]
        new_caret_pos = caret_pos - tw_length + len(completion)
        weechat.buffer_set(bufferptr, 'input', encode(line))
        weechat.buffer_set(bufferptr, 'input_pos', str(new_caret_pos))

    return weechat.WEECHAT_RC_OK
Beispiel #42
0
def unread_buffer_cb(data, buffer, args):

    arguments = args.lower().split(' ')
    if not len(arguments) == 2:
        return weechat.WEECHAT_RC_OK

    if arguments[0] == 'low':
        priority = "0"
    elif arguments[0] == 'message':
        priority = "1"
    elif arguments[0] == 'private':
        priority = "2"
    elif arguments[0] == 'highlight':
        priority = "3"
    elif arguments[0] == 'remove':
        priority = "-1"
    else:
        return weechat.WEECHAT_RC_OK
    # search for either buffer_name or buffer_number
    ptr_buffer = buffer_infolist(arguments[1])

    weechat.buffer_set(ptr_buffer, "hotlist", "-1")
    weechat.buffer_set(ptr_buffer, "hotlist", priority)

    return weechat.WEECHAT_RC_OK
Beispiel #43
0
def notify_cb(data, option, value):
    option = cg('notify')
    if option == 'on':
        w.buffer_set(himan_buffer, 'notify', '1')
    elif option == 'off':
        w.buffer_set(himan_buffer, 'notify', '0')
    return w.WEECHAT_RC_OK
Beispiel #44
0
def key_de(buf, input_line, cur, repeat):
    """Simulate vi's behavior for de."""
    pos = get_pos(input_line, r"\w\b", cur)
    input_line = list(input_line)
    del input_line[cur:cur+pos+1]
    input_line = ''.join(input_line)
    weechat.buffer_set(buf, "input", input_line)
Beispiel #45
0
def hexip_completion(data, buffer, command):
    input = weechat.buffer_get_string(buffer, 'input')
#    cmd = input.partition(' ')[0].strip('/')
#    if cmd not in weechat.config_get_plugin('commands_cmpl'):
#        # don't complete then
#        return WEECHAT_RC_OK
    pos = weechat.buffer_get_integer(buffer, 'input_pos')
    #debug('%r %s %s' %(input, len(input), pos))
    if pos >= 8 and (pos == len(input) or input[pos] == ' '):
        n = input.rfind(' ', 0, pos)
        word = input[n+1:pos]
        #debug(word)
        if not word:
            return WEECHAT_RC_OK
        replace = ''
        if is_hexip(word):
            replace = hex_to_ip(word)
        elif is_ip(word):
            replace = ip_to_hex(word)
        if replace:
            n = len(word)
            weechat.buffer_set(buffer, 'input', '%s%s%s' %(input[:pos-n], replace, input[pos:]))
            weechat.buffer_set(buffer, 'input_pos', str(pos - n + len(replace)))
            return WEECHAT_RC_OK_EAT
    return WEECHAT_RC_OK
Beispiel #46
0
def bas_config_option_cb(data, option, value):
    if not weechat.config_boolean(bas_options["look_instant"]):
        return weechat.WEECHAT_RC_OK

    if not weechat.config_get(option):  # option was deleted
        return weechat.WEECHAT_RC_OK

    option = option[len("%s.buffer." % CONFIG_FILE_NAME):]

    pos = option.rfind(".")
    if pos > 0:
        buffer_mask = option[0:pos]
        property = option[pos + 1:]
        if buffer_mask and property:
            buffers = weechat.infolist_get("buffer", "", buffer_mask)

            if not buffers:
                return weechat.WEECHAT_RC_OK

            while weechat.infolist_next(buffers):
                buffer = weechat.infolist_pointer(buffers, "pointer")
                weechat.buffer_set(buffer, property, value)

            weechat.infolist_free(buffers)

    return weechat.WEECHAT_RC_OK
Beispiel #47
0
def setup_buffer(buffer):
    # set title
    weechat.buffer_set(buffer, "title", "Twitter buffer, type ':help' for options.")

    # disable logging, by setting local variable "no_log" to "1"
    weechat.buffer_set(buffer, "localvar_set_no_log", "1")

    #create main nicklist
    friends_nicks_group[buffer] = weechat.nicklist_add_group(buffer, "", "Friends",
                "weechat.color.nicklist_group", 1)

    tweet_nicks_group[buffer] = weechat.nicklist_add_group(buffer, "", "Tweet_parse",
                "weechat.color.nicklist_group", 1)
    autocomp_group = weechat.nicklist_add_group(buffer, "", "Autocomp",
                "weechat.color.nicklist_group", 1)
    #newline autocomplete
    weechat.nicklist_add_nick(buffer, autocomp_group, "&#13;&#10;", 'bar_fg', '', '', 1)

    #show nicklist
    weechat.buffer_set(buffer, "nicklist", "1")

    user_nick = script_options['screen_name']

    weechat.buffer_set(buffer, "localvar_set_nick", user_nick)

    add_to_nicklist(buffer, user_nick)
    # Highlight user nick
    weechat.buffer_set(buffer, "highlight_words", user_nick)
Beispiel #48
0
    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", "")
Beispiel #49
0
def input_set(data, remaining_calls):
    """Set the input line's content."""
    buf = weechat.current_buffer()
    weechat.buffer_set(buf, "input", data)
    # move the cursor back to its position prior to setting the content
    weechat.command('', "/input move_next_char")
    return weechat.WEECHAT_RC_OK
Beispiel #50
0
def complete_cb(data, bufferptr, command):
    """ Apply transformation to input line in specified buffer """

    if command != "/input complete_next":
        return weechat.WEECHAT_RC_OK

    line = decode(weechat.buffer_get_string(bufferptr, 'input'))
    caret_pos = weechat.buffer_get_integer(bufferptr, 'input_pos')

    match = re.search('(:\w+$)', line[:caret_pos])
    if not match:
        return weechat.WEECHAT_RC_OK

    # tw = tabbed word
    tw = match.group(0)
    tw_length = len(tw)
    tw_start = caret_pos - tw_length
    tw_end = caret_pos

    completion = ""
    for key, value in EMOJIS.iteritems():
        if key.startswith(tw):
            completion = decode(value)
            break

    if completion:
        line = line[:tw_start] + completion + line[tw_end:]
        new_caret_pos = caret_pos - tw_length + len(completion)
        weechat.buffer_set(bufferptr, 'input', encode(line))
        weechat.buffer_set(bufferptr, 'input_pos', str(new_caret_pos))

    return weechat.WEECHAT_RC_OK
Beispiel #51
0
def go_end(buffer):
    """ End go on buffer """
    global saved_input, saved_input_pos, old_input
    unhook_all()
    weechat.buffer_set(buffer, "input", saved_input)
    weechat.buffer_set(buffer, "input_pos", str(saved_input_pos))
    old_input = None
Beispiel #52
0
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
Beispiel #53
0
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
Beispiel #54
0
 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)