<commit_before>"""Mutes events from users that never talk.

- Muted events are: Joins, Parts, Renames and Mode Changes.
- If a recently joined user starts talking,
  his 'Join' event is late-emitted with the original timestamp.
- Handles renames.
- If a user that previously talked
  parts and joins again (or renames),
  the events are shown.
- Events for nicks in your notify list are always shown.
- Default threshold is 60 minutes.

Works with ZNC bouncers
and also works with *buffextras module
using [buffextras.py][].

[buffextras.py]: https://github.com/knitori/tools/blob/master/hexchat/buffextras.py
"""

from __future__ import print_function, absolute_import

import functools
import time
import hexchat

__module_name__ = 'SmartFilter'
__module_author__ = 'FichteFoll'
__module_version__ = '3.1.0'
__module_description__ = 'Intelligently hide parts, joins, user modes, and nick changes'

# TODO only hide +-qaohv in Raw Modes

LASTTALK_THRESHOLD = 1 * 60 * 60  # in seconds
CLEAN_INTERVAL = 5 * 60  # in seconds


def expand_server_channel(forward_context=False):
    def decorator(func, forward_context=False):
        @functools.wraps(func)
        def wrapper(*args, **kwargs):
            context = kwargs.pop('context', hexchat)
            kwargs.setdefault('server', context.get_info('server'))
            kwargs.setdefault('channel', context.get_info('channel'))
            if forward_context:
                kwargs['context'] = context
            return func(*args, **kwargs)
        return wrapper
    if callable(forward_context):
        return decorator(forward_context)
    else:
        return decorator


class TimestampMap(object):
<commit_msg>Use "correct" quotation marks<commit_after>"""Mutes events from users that never talk.

- Muted events are: Joins, Parts, Renames and Mode Changes.
- If a recently joined user starts talking,
  his 'Join' event is late-emitted with the original timestamp.
- Handles renames.
- If a user that previously talked
  parts and joins again (or renames),
  the events are shown.
- Events for nicks in your notify list are always shown.
- Default threshold is 60 minutes.

Works with ZNC bouncers
and also works with *buffextras module
using [buffextras.py][].

[buffextras.py]: https://github.com/knitori/tools/blob/master/hexchat/buffextras.py
"""

from __future__ import print_function, absolute_import

import functools
import time
import hexchat

__module_name__ = "SmartFilter"
__module_author__ = "FichteFoll"
__module_version__ = "3.1.0"
__module_description__ = "Intelligently hide parts, joins, user modes, and nick changes"

# TODO only hide +-qaohv in Raw Modes

LASTTALK_THRESHOLD = 1 * 60 * 60  # in seconds
CLEAN_INTERVAL = 5 * 60  # in seconds


def expand_server_channel(forward_context=False):
    def decorator(func, forward_context=False):
        @functools.wraps(func)
        def wrapper(*args, **kwargs):
            context = kwargs.pop('context', hexchat)
            kwargs.setdefault('server', context.get_info('server'))
            kwargs.setdefault('channel', context.get_info('channel'))
            if forward_context:
                kwargs['context'] = context
            return func(*args, **kwargs)
        return wrapper
    if callable(forward_context):
        return decorator(forward_context)
    else:
        return decorator


class TimestampMap(object):

{'fraction_non_alphanumeric': 0.09080118694362017, 'fraction_numerical': 0.00771513353115727, 'mean_word_length': 3.617808219178082, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6838015', 'n_tokens_mistral': 1017, 'n_tokens_neox': 991, 'n_words': 319}