<commit_before>import datetime
import sys


class Plugin:
    def on_message(self, bot, msg, reply):
        bot.storage["seen." + msg["sender"]] = {
            "action": "spoke",
            "datetime": datetime.datetime.now()
        }

    def on_command(self, bot, msg):
        if len(sys.argv) >= 2:
            user = sys.argv[1]
            try:
                info = bot.storage["seen." + user]
                print("{0} {1} on {2}.".format(user, info["action"],
                                               info["datetime"].strftime("%a %d %b %H:%M %Z").strip()))
            except KeyError:
                print("I don't know anything about {0}.".format(user))
        else:
            print(self.on_help())

    def on_help(self):
        return "Usage: seen <user>"<commit_msg>Add tests for seen plugin<commit_after>import datetime
import io
import unittest


class Plugin:
    def on_message(self, bot, msg, reply):
        bot.storage["seen." + msg["sender"]] = {
            "action": "spoke",
            "datetime": datetime.datetime.now()
        }

    def on_command(self, bot, msg, stdin, stdout, reply):
        if len(msg["args"]) >= 2:
            user = msg["args"][1]
            try:
                info = bot.storage["seen." + user]
                datetime_str = info["datetime"].strftime("%a %d %b %H:%M %Z").strip()
                print("{0} {1} on {2}.".format(user, info["action"], datetime_str), file=stdout)
            except KeyError:
                print("I don't know anything about {0}.".format(user), file=stdout)
        else:
            print(self.on_help(), file=stdout)

    def on_help(self):
        return "Usage: seen <user>"


class Test(unittest.TestCase):
    class ExampleBot:
        def __init__(self):
            self.storage = {}

    def setUp(self):
        self.plugin = Plugin()

    def test_message(self):
        bot = Test.ExampleBot()
        self.plugin.on_message(bot, {"sender": "test"}, None)
        self.assertIn("seen.test", bot.storage)

    def test_command(self):
        stdout = io.StringIO()
        bot = Test.ExampleBot()
        bot.storage["seen.test"] = {"action": "spoke", "datetime": datetime.datetime.now()}
        self.plugin.on_command(bot, {"args": [None, "test"]}, None, stdout, None)
        self.assertNotEqual("I don't know anything about test.", stdout.getvalue().strip())

        stdout = io.StringIO()
        self.plugin.on_command(bot, {"args": [None, "test2"]}, None, stdout, None)
        self.assertEqual("I don't know anything about test2.", stdout.getvalue().strip())

    def test_help(self):
        self.assertTrue(self.plugin.on_help())

    def test_no_args(self):
        stdout = io.StringIO()
        self.plugin.on_command(None, {"args": [None]}, stdout, stdout, None)
        self.assertEqual(self.plugin.on_help(), stdout.getvalue().strip())
{'fraction_non_alphanumeric': 0.16086350974930363, 'fraction_numerical': 0.004874651810584958, 'mean_word_length': 2.2280898876404494, 'pattern_counts': {'":': 10, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5474465', 'n_tokens_mistral': 890, 'n_tokens_neox': 857, 'n_words': 202}