Exemplo n.º 1
0
    def reload(self):
        ''' Load configuration variables. '''

        self.case_sensitive = weechat.config_boolean(self.__case_sensitive)
        self.group_irc = weechat.config_boolean(self.__group_irc)
        rules_blob = weechat.config_string(self.__rules)
        self.rules = RuleList.decode(rules_blob)
Exemplo n.º 2
0
	def reload(self):
		''' Load configuration variables. '''

		self.case_sensitive = weechat.config_boolean(self.__case_sensitive)
		self.group_irc      = weechat.config_boolean(self.__group_irc)
		rules_blob          = weechat.config_string(self.__rules)
		self.rules          = RuleList.decode(rules_blob)
Exemplo n.º 3
0
	def reload(self):
		''' Load configuration variables. '''

		self.case_sensitive = weechat.config_boolean(self.__case_sensitive)

		rules_blob    = weechat.config_string(self.__rules)
		helpers_blob  = weechat.config_string(self.__helpers)
		signals_blob  = weechat.config_string(self.__signals)

		self.rules          = decode_rules(rules_blob)
		self.helpers        = decode_helpers(helpers_blob)
		self.signals        = signals_blob.split()
		self.signal_delay   = weechat.config_integer(self.__signal_delay)
		self.sort_on_config = weechat.config_boolean(self.__sort_on_config)
Exemplo n.º 4
0
	def reload(self):
		''' Load configuration variables. '''

		self.case_sensitive = weechat.config_boolean(self.__case_sensitive)
		self.group_irc      = weechat.config_boolean(self.__group_irc)

		rules_blob          = weechat.config_string(self.__rules)
		replacements_blob   = weechat.config_string(self.__replacements)
		signals_blob        = weechat.config_string(self.__signals)

		self.rules          = RuleList.decode(rules_blob)
		self.replacements   = decode_replacements(replacements_blob)
		self.signals        = signals_blob.split()
		self.sort_on_config = weechat.config_boolean(self.__sort_on_config)
Exemplo n.º 5
0
	def reload(self):
		''' Load configuration variables. '''

		self.case_sensitive = weechat.config_boolean(self.__case_sensitive)
		self.group_irc      = weechat.config_boolean(self.__group_irc)

		rules_blob          = weechat.config_string(self.__rules)
		replacements_blob   = weechat.config_string(self.__replacements)
		signals_blob        = weechat.config_string(self.__signals)

		self.rules          = RuleList.decode(rules_blob, self.case_sensitive)
		self.replacements   = decode_replacements(replacements_blob)
		self.signals        = signals_blob.split()
		self.sort_on_config = weechat.config_boolean(self.__sort_on_config)
Exemplo n.º 6
0
def get_config_options():
    global COLOR_RESET, COLOR_CHAT_DELIMITERS, COLOR_CHAT_NICK, COLOR_CHAT_HOST, \
           COLOR_CHAT_CHANNEL, COLOR_CHAT, COLOR_MESSAGE_JOIN, COLOR_MESSAGE_QUIT, \
           COLOR_REASON_QUIT, SMART_FILTER
    global send_signals, znc_timestamp

    config_get_string = lambda s: weechat.config_string(weechat.config_get(s))
    COLOR_RESET = weechat.color('reset')
    COLOR_CHAT_DELIMITERS = weechat.color('chat_delimiters')
    COLOR_CHAT_NICK = weechat.color('chat_nick')
    COLOR_CHAT_HOST = weechat.color('chat_host')
    COLOR_CHAT_CHANNEL = weechat.color('chat_channel')
    COLOR_CHAT = weechat.color('chat')
    COLOR_MESSAGE_JOIN = weechat.color(
        config_get_string('irc.color.message_join'))
    COLOR_MESSAGE_QUIT = weechat.color(
        config_get_string('irc.color.message_quit'))
    COLOR_REASON_QUIT = weechat.color(
        config_get_string('irc.color.reason_quit'))

    SMART_FILTER = weechat.config_boolean(
        weechat.config_get("irc.look.smart_filter"))

    send_signals = get_config_boolean('send_signals')
    znc_timestamp = weechat.config_get_plugin('timestamp')
Exemplo n.º 7
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
Exemplo n.º 8
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
Exemplo n.º 9
0
def open_query_buffer(server_name, nick):
    starting_buffer = weechat.current_buffer()
    noswitch = ""
    switch_autojoin = weechat.config_get("irc.look.buffer_switch_autojoin")
    if not weechat.config_boolean(switch_autojoin):
        noswitch = "-noswitch"
    weechat.command('','/query %s -server %s %s' % ( noswitch, server_name, nick ))
    weechat.buffer_set(starting_buffer, 'display', 'auto')
Exemplo n.º 10
0
 def __getitem__(self, key):
     if key == "historysize":
         return weechat.config_integer(self.data[key])
     elif key == 'output_main_buffer':
         return weechat.config_boolean(self.data[key])
     #elif key.startswith('color'):
     #    return weechat.config_color(self.data[key])
     else:
         return weechat.config_string(self.data[key])
Exemplo n.º 11
0
def topic(data, tags, msg):
    server = tags.split(",")[0]

    match = re.search(r':(\S+)\s+TOPIC\s+(\S+)\s+:(.*)', msg)

    if not match:
        return weechat.WEECHAT_RC_ERROR

    usermask, channel, newtopic = match.groups()
    nick, host = usermask.split("!", 1)

    buffer = weechat.buffer_search("irc", server + "." + channel)
    weechat.prnt("", server + "." + channel)

    if not buffer:
        return weechat.WEECHAT_RC_ERROR

    oldtopic = weechat.buffer_get_string(buffer, "title")
    if oldtopic == None:
        oldtopic = ""

    dmp = diff_match_patch.diff_match_patch()
    diff = dmp.diff_main(oldtopic, newtopic)
    dmp.diff_cleanupEfficiency(diff)

    topic = ""

    color_reset = weechat.color("reset")
    color_ins = weechat.color(weechat.config_get_plugin("color_ins"))
    color_del = weechat.color(weechat.config_get_plugin("color_del"))

    for chunk in diff:
        changed, text = chunk

        topic += "%s%s%s" % (
            # 0 (unchanged), 1 (added), -1 (removed)
            ["", color_ins, color_del][changed],
            text,
            ["", color_reset, color_reset][changed]
        )

    weechat.prnt_date_tags(buffer, 0, "irc_topicdiff",
        "%s%s%s%s has changed topic for %s%s%s: %s" % (
        weechat.prefix("network"),
        weechat.color(weechat.info_get("irc_nick_color", nick)) \
            if weechat.config_boolean("irc.look.color_nicks_in_server_messages") \
            else weechat.color("chat_nick"),
        nick,
        color_reset,
        weechat.color("chat_channel"),
        channel,
        color_reset,
        topic
    ))

    return weechat.WEECHAT_RC_OK
Exemplo n.º 12
0
def topic(data, tags, msg):
    server = tags.split(",")[0]

    match = re.search(r':(\S+)\s+TOPIC\s+(\S+)\s+:(.*)', msg)

    if not match:
        return weechat.WEECHAT_RC_ERROR

    usermask, channel, newtopic = match.groups()
    nick, host = usermask.split("!", 1)

    buffer = weechat.buffer_search("irc", server + "." + channel)
    weechat.prnt("", server + "." + channel)

    if not buffer:
        return weechat.WEECHAT_RC_ERROR

    oldtopic = weechat.buffer_get_string(buffer, "title")
    if oldtopic == None:
        oldtopic = ""

    dmp = diff_match_patch.diff_match_patch()
    diff = dmp.diff_main(oldtopic, newtopic)
    dmp.diff_cleanupEfficiency(diff)

    topic = ""

    color_reset = weechat.color("reset")
    color_ins = weechat.color(weechat.config_get_plugin("color_ins"))
    color_del = weechat.color(weechat.config_get_plugin("color_del"))

    for chunk in diff:
        changed, text = chunk

        topic += "%s%s%s" % (
            # 0 (unchanged), 1 (added), -1 (removed)
            ["", color_ins, color_del][changed],
            text,
            ["", color_reset, color_reset][changed])

    weechat.prnt_date_tags(buffer, 0, "irc_topicdiff",
        "%s%s%s%s has changed topic for %s%s%s: %s" % (
        weechat.prefix("network"),
        weechat.color(weechat.info_get("irc_nick_color", nick)) \
            if weechat.config_boolean("irc.look.color_nicks_in_server_messages") \
            else weechat.color("chat_nick"),
        nick,
        color_reset,
        weechat.color("chat_channel"),
        channel,
        color_reset,
        topic
    ))

    return weechat.WEECHAT_RC_OK
Exemplo n.º 13
0
def fish_announce_broken(buffer, target):
    global fish_encryption_announced, fish_config_option

    if not weechat.config_boolean(fish_config_option['announce']):
        return

    (server, nick) = target.split("/")
    buffer = fish_get_target_buffer(buffer, server, nick)

    fish_alert(
        buffer,
        "Message from %s was not fully decrypted because it cut off" % target)
Exemplo n.º 14
0
def fish_announce_unencrypted(buffer, target):
    global fish_encryption_announced, fish_config_option

    if (not weechat.config_boolean(fish_config_option['announce']) or
            not fish_encryption_announced.get(target)):
        return

    fish_alert(buffer, "Messages to/from %s are %s*not*%s encrypted." % (
            target,
            weechat.color(weechat.config_color(fish_config_option["alert"])),
            weechat.color("chat")))

    del fish_encryption_announced[target]
Exemplo n.º 15
0
def fish_announce_unencrypted(buffer, target):
    global fish_encryption_announced, fish_config_option

    if (not weechat.config_boolean(fish_config_option['announce']) or
            not fish_encryption_announced.get(target)):
        return

    fish_alert(buffer, "Messages to/from %s are %s*not*%s encrypted." % (
            target,
            weechat.color(weechat.config_color(fish_config_option["alert"])),
            weechat.color("chat")))

    del fish_encryption_announced[target]
Exemplo n.º 16
0
def fish_announce_encrypted(buffer, target):
    global fish_encryption_announced, fish_config_option

    if (not weechat.config_boolean(fish_config_option['announce'])
            or fish_encryption_announced.get(target)):
        return

    (server, nick) = target.split("/")
    buffer = fish_get_target_buffer(buffer, server, nick)

    fish_alert(buffer, "Messages to/from %s are encrypted." % target)

    fish_encryption_announced[target] = True
Exemplo n.º 17
0
    def getPolicy(self, key):
        """Get the value of a policy option for this context."""
        option = weechat.config_get(self.policy_config_option(key))

        if option == '':
            option = weechat.config_get(
                config_prefix('policy.default.%s' % key.lower()))

        result = bool(weechat.config_boolean(option))

        debug(('getPolicy', key, result))

        return result
Exemplo n.º 18
0
    def getPolicy(self, key):
        """Get the value of a policy option for this context."""
        key_lower = key.lower()

        if key_lower in READ_ONLY_POLICIES:
            result = READ_ONLY_POLICIES[key_lower]
        else:
            option = weechat.config_get(self.policy_config_option(key))

            if option == '':
                option = weechat.config_get(
                    config_prefix('policy.default.%s' % key_lower))

            result = bool(weechat.config_boolean(option))

        debug(('getPolicy', key, result))

        return result
Exemplo n.º 19
0
def load_query_buffer_irc_server_opened(server_connected):
    global query_buffer_list

    filename = get_filename_with_path()

    if os.path.isfile(filename):
        f = open(filename, 'rb')
        for line in f:
            servername,nick = line.split(' ')
            if servername == server_connected:
                noswitch = ""
                switch_autojoin = weechat.config_get("irc.look.buffer_switch_autojoin")
                if not weechat.config_boolean(switch_autojoin):
                    noswitch = "-noswitch"
                weechat.command('','/query %s -server %s %s' % ( noswitch, servername, nick ))
        f.close()
    else:
        weechat.prnt('','%s%s: Error loading query buffer from "%s"' % (weechat.prefix('error'), SCRIPT_NAME, filename))
Exemplo n.º 20
0
    def getPolicy(self, key):
        """Get the value of a policy option for this context."""
        key_lower = key.lower()

        if key_lower in READ_ONLY_POLICIES:
            result = READ_ONLY_POLICIES[key_lower]
        else:
            option = weechat.config_get(self.policy_config_option(key))

            if option == '':
                option = weechat.config_get(
                    config_prefix('policy.default.%s' % key_lower))

            result = bool(weechat.config_boolean(option))

        debug(('getPolicy', key, result))

        return result
Exemplo n.º 21
0
def fish_announce_encrypted(buffer, target):
    global fish_encryption_announced, fish_config_option

    if (not weechat.config_boolean(fish_config_option['announce']) or
        fish_encryption_announced.get(target)):
        return

    (server, nick) = target.split("/")

    if (weechat.info_get("irc_is_nick", nick) and
            weechat.buffer_get_string(buffer, "localvar_type") != "private"):
        # if we get a private message and there no buffer yet, create one and
        # jump back to the previous buffer
        weechat.command(buffer, "/mute -all query %s" % nick)
        buffer = weechat.info_get("irc_buffer", "%s,%s" % (server, nick))
        weechat.command(buffer, "/input jump_previously_visited_buffer")

    fish_alert(buffer, "Messages to/from %s are encrypted." % target)

    fish_encryption_announced[target] = True
Exemplo n.º 22
0
def fish_announce_encrypted(buffer, target):
    global fish_encryption_announced, fish_config_option

    if (not weechat.config_boolean(fish_config_option['announce']) or
            fish_encryption_announced.get(target)):
        return

    (server, nick) = target.split("/")

    if (weechat.info_get("irc_is_nick", nick) and
            weechat.buffer_get_string(buffer, "localvar_type") != "private"):
        # if we get a private message and there no buffer yet, create one and
        # jump back to the previous buffer
        weechat.command(buffer, "/mute -all query %s" % nick)
        buffer = weechat.info_get("irc_buffer", "%s,%s" % (server, nick))
        weechat.command(buffer, "/input jump_previously_visited_buffer")

    fish_alert(buffer, "Messages to/from %s are encrypted." % target)

    fish_encryption_announced[target] = True
Exemplo n.º 23
0
def get_config_options():
    global COLOR_RESET, COLOR_CHAT_DELIMITERS, COLOR_CHAT_NICK, COLOR_CHAT_HOST, \
           COLOR_CHAT_CHANNEL, COLOR_CHAT, COLOR_MESSAGE_JOIN, COLOR_MESSAGE_QUIT, \
           COLOR_REASON_QUIT, SMART_FILTER
    global send_signals, znc_timestamp 

    config_get_string = lambda s: weechat.config_string(weechat.config_get(s))
    COLOR_RESET           = weechat.color('reset')
    COLOR_CHAT_DELIMITERS = weechat.color('chat_delimiters')
    COLOR_CHAT_NICK       = weechat.color('chat_nick')
    COLOR_CHAT_HOST       = weechat.color('chat_host')
    COLOR_CHAT_CHANNEL    = weechat.color('chat_channel')
    COLOR_CHAT            = weechat.color('chat')
    COLOR_MESSAGE_JOIN    = weechat.color(config_get_string('irc.color.message_join'))
    COLOR_MESSAGE_QUIT    = weechat.color(config_get_string('irc.color.message_quit'))
    COLOR_REASON_QUIT     = weechat.color(config_get_string('irc.color.reason_quit'))

    SMART_FILTER = weechat.config_boolean(weechat.config_get("irc.look.smart_filter"))
        
    send_signals = get_config_boolean('send_signals')
    znc_timestamp = weechat.config_get_plugin('timestamp')
Exemplo n.º 24
0
def load_query_buffer_irc_server_opened(server_connected):
    global query_buffer_list

    filename = get_filename_with_path()

    if os.path.isfile(filename):
        f = open(filename, 'rb')
        for line in f:
            servername, nick = line.split(' ')
            if servername == server_connected:
                noswitch = ""
                switch_autojoin = weechat.config_get(
                    "irc.look.buffer_switch_autojoin")
                if not weechat.config_boolean(switch_autojoin):
                    noswitch = "-noswitch"
                weechat.command(
                    '',
                    '/query %s -server %s %s' % (noswitch, servername, nick))
        f.close()
    else:
        weechat.prnt(
            '', '%s%s: Error loading query buffer from "%s"' %
            (weechat.prefix('error'), SCRIPT_NAME, filename))
Exemplo n.º 25
0
def jmh_enabled():
    """ Return True if jmh is enabled. """
    global jmh_config_option
    if weechat.config_boolean(jmh_config_option["enabled"]):
        return True
    return False
Exemplo n.º 26
0
 def reload(self):
     self.mail_dir = weechat.config_string(self._mail_dir)
     self.bar_text = weechat.config_string(self._bar_text)
     self.interval = weechat.config_integer(self._interval)
     self.should_log = weechat.config_boolean(self._log_to_weechat)
Exemplo n.º 27
0
def debug(msg):
    """Send a debug message to the WeeChat core buffer."""
    debug_option = weechat.config_get(config_prefix('general.debug'))

    if weechat.config_boolean(debug_option):
        prnt('', ('%s debug\t%s' % (SCRIPT_NAME, unicode(msg))))
Exemplo n.º 28
0
def debug(msg):
    """Send a debug message to the WeeChat core buffer."""
    debug_option = weechat.config_get(config_prefix('general.debug'))

    if weechat.config_boolean(debug_option):
        prnt('', ('%s debug\t%s' % (SCRIPT_NAME, unicode(msg))))
Exemplo n.º 29
0
def jmh_verbose():
    """ Return True if jmh verbose is on. """
    global jmh_config_option
    if weechat.config_boolean(jmh_config_option["verbose"]):
        return True
    return False