<commit_before>from tehbot.plugins import *

class GreetingHandler(ChannelJoinHandler):
    def default_settings(self):
        return {
                "no_greet" : [ ]
                }

    def initialize(self, dbconn):
        ChannelJoinHandler.initialize(self, dbconn)
        with dbconn:
            dbconn.execute("create table if not exists Greetings(id integer primary key, text varchar)")
            dbconn.executemany("insert or ignore into Greetings values(?, ?)", [
                (1, "Konnichiwa %s"),
                (2, "Welcome %s"),
                (3, "Hi %s"),
                (4, "Salut %s"),
                (5, "S<NAME>ikum, %s"),
                (6, "Hello %s"),
                (7, "Ciao %s"),
                (8, "Hei %s"),
                (9, "Ahoj %s"),
                (10, "Hola %s"),
            ])

    def config(self, args, dbconn):
        if args[0] == "modify":
            if args[1] == "add" and args[2] == "no_greet":
                who = args[3]
                if not self.settings.has_key("no_greet"):
                    self.settings["no_greet"] = []
                self.settings["no_greet"].append(who)
                self.save(dbconn)
                return "Okay"

        return ChannelJoinHandler.config(self, args, dbconn)

    def execute(self, connection, event, extra, dbconn):
        for network, channels in self.settings["where"].items():
            if connection.name != network or (event.target not in channels and channels != "__all__"):
                return

        if event.source.nick in self.settings["no_greet"]:
            return<commit_msg>GreetingPlugin: add rm config option<commit_after>from tehbot.plugins import *

class GreetingHandler(ChannelJoinHandler):
    def default_settings(self):
        return {
                "no_greet" : [ ]
                }

    def initialize(self, dbconn):
        ChannelJoinHandler.initialize(self, dbconn)
        with dbconn:
            dbconn.execute("create table if not exists Greetings(id integer primary key, text varchar)")
            dbconn.executemany("insert or ignore into Greetings values(?, ?)", [
                (1, "<NAME>"),
                (2, "Welcome %s"),
                (3, "Hi %s"),
                (4, "Salut %s"),
                (5, "S<NAME>, %s"),
                (6, "Hello %s"),
                (7, "Ciao %s"),
                (8, "Hei %s"),
                (9, "Ahoj %s"),
                (10, "Hola %s"),
            ])

    def config(self, args, dbconn):
        if args[0] == "modify":
            if args[1] in ["add", "rm"] and args[2] == "no_greet":
                who = args[3]
                if not self.settings.has_key("no_greet"):
                    self.settings["no_greet"] = []
                no_greet = set(self.settings["no_greet"])

                if args[1] == "add":
                    if who in no_greet:
                        return "%s already is in no_greet" % who
                    no_greet.add(who)
                elif args[1] == "rm":
                    if who not in no_greet:
                        return "%s is not in no_greet" % who
                    no_greet.remove(who)
                self.settings["no_greet"] = list(no_greet)
                self.save(dbconn)
                return "Okay"

        return ChannelJoinHandler.config(self, args, dbconn)

    def execute(self, connection, event, extra, dbconn):
        for network, channels in self.settings["where"].items():
            if connection.name != network or (event.target not in channels and channels != "__all__"):
                return

        if event.source.nick in self.settings["no_greet"]:
            return
{'fraction_non_alphanumeric': 0.12988069414316702, 'fraction_numerical': 0.008676789587852495, 'mean_word_length': 1.5547091412742382, 'pattern_counts': {'":': 6, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, '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': '6942259', 'n_tokens_mistral': 1102, 'n_tokens_neox': 1048, 'n_words': 274}