<commit_before>"""Transforms raw mode messages to remove redundant information.

FichteFoll sets mode #channel +o FichteFoll => FichteFoll sets mode +o FichteFoll
FichteFoll sets mode FichteFoll +i => FichteFoll sets mode :+i

Requires the irc_raw_modes setting to be enabled
(`/set irc_raw_modes 1`).
"""
import hexchat

try:
    from .util import print_event
except SystemError:
    # Add addons path to sys.path for win32
    # See https://github.com/hexchat/hexchat/issues/1396
    import os
    import sys

    if sys.platform == "win32":
        addons_path = os.path.join(hexchat.get_info("configdir"), "addons")
        if addons_path not in sys.path:
            sys.path.append(addons_path)

    from util import print_event


###############################################################################

__module_name__ = "Better Raw Modes"
__module_author__ = "FichteFoll"
__module_version__ = "0.3.0"
__module_description__ = "Improves display of the 'Raw Modes' text event"


def split_irc_message(message):
    if message.startswith(":"):
        return [message]
    first, _, last = message.partition(" :")
    args = list(filter(None, first.split(" ")))
    if last:
        args.append(last)
    return args


def raw_modes_cb(word, word_eol, event):
    """
    ['FichteFoll', '#channel +o FichteFoll'] => ['FichteFoll', '+o FichteFoll']
    ['FichteFoll', 'FichteFoll :+Tix'] => ['FichteFoll', ':+Tix']
    ['FichteFoll', 'FichteFoll +Tix'] => ['FichteFoll', ':+Tix']
    """
    target, *mode_args = split_irc_message(word[1])
    if target not in (hexchat.get_info('channel'), hexchat.get_info('nick')):
        return hexchat.EAT_NONE

    print_event('Raw Modes', word[0], " ".join(mode_args))
    return hexchat.EAT_ALL


def main():
    hexchat.hook_print('Raw Modes', raw_modes_cb, priority=hexchat.PRI_LOWEST)

    print(__module_name__, __module_version__, "loaded")
<commit_msg>Only need to eat for hexchat<commit_after>"""Transforms raw mode messages to remove redundant information.

FichteFoll sets mode #channel +o FichteFoll => FichteFoll sets mode +o FichteFoll
FichteFoll sets mode FichteFoll +i => FichteFoll sets mode :+i

Requires the irc_raw_modes setting to be enabled
(`/set irc_raw_modes 1`).
"""
import hexchat

try:
    from .util import print_event
except SystemError:
    # Add addons path to sys.path for win32
    # See https://github.com/hexchat/hexchat/issues/1396
    import os
    import sys

    if sys.platform == "win32":
        addons_path = os.path.join(hexchat.get_info("configdir"), "addons")
        if addons_path not in sys.path:
            sys.path.append(addons_path)

    from util import print_event


###############################################################################

__module_name__ = "Better Raw Modes"
__module_author__ = "FichteFoll"
__module_version__ = "0.3.0"
__module_description__ = "Improves display of the 'Raw Modes' text event"


def split_irc_message(message):
    if message.startswith(":"):
        return [message]
    first, _, last = message.partition(" :")
    args = list(filter(None, first.split(" ")))
    if last:
        args.append(last)
    return args


def raw_modes_cb(word, word_eol, event):
    """
    ['FichteFoll', '#channel +o FichteFoll'] => ['FichteFoll', '+o FichteFoll']
    ['FichteFoll', 'FichteFoll :+Tix'] => ['FichteFoll', ':+Tix']
    ['FichteFoll', 'FichteFoll +Tix'] => ['FichteFoll', ':+Tix']
    """
    target, *mode_args = split_irc_message(word[1])
    if target not in (hexchat.get_info('channel'), hexchat.get_info('nick')):
        return hexchat.EAT_NONE

    print_event('Raw Modes', word[0], " ".join(mode_args))
    return hexchat.EAT_HEXCHAT


def main():
    hexchat.hook_print('Raw Modes', raw_modes_cb, priority=hexchat.PRI_LOWEST)

    print(__module_name__, __module_version__, "loaded")

{'fraction_non_alphanumeric': 0.166016133229248, 'fraction_numerical': 0.007285974499089253, 'mean_word_length': 4.111702127659575, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5960658', 'n_tokens_mistral': 1332, 'n_tokens_neox': 1277, 'n_words': 319}