<commit_before>from twisted.plugin import IPlugin
from twisted.words.protocols import irc
from txircd.channel import IRCChannel
from txircd.module_interface import ICommand, IModuleData, Command, ModuleData
from zope.interface import implements

class SajoinCommand(ModuleData, Command):
    implements(IPlugin, IModuleData, ICommand)

    name = "SajoinCommand"

    def hookIRCd(self, ircd):
        self.ircd = ircd

    def userCommands(self):
        return [ ("SAJOIN", 1, self) ]

    def actions(self):
        return [ ("commandpermission-SAJOIN", 1, self.restrictToOpers) ]

    def restrictToOpers(self, user, command, data):
        if not self.ircd.runActionUntilValue("userhasoperpermission", user, "command-sajoin", users=[user]):
            user.sendMessage(irc.ERR_NOPRIVILEGES, ":Permission denied - You do not have the correct operator privileges")
            return False
        return None

    def parseParams(self, user, params, prefix, tags):
        if len(params) < 2:
            user.sendSingleError("SajoinCmd", irc.ERR_NEEDMOREPARAMS, "SAJOIN", ":Not enough parameters")
            return None
        if params[0] not in self.ircd.userNicks:
            user.sendSingleError("SajoinCmd", irc.ERR_NOSUCHNICK, params[0], ":No such nick/channel")
        channame = params[1]
        if channame[0] != "#":
            channame = "#{}".format(channame)
        if channame in self.ircd.channels:
            channel = self.ircd.channels[channame]
        else:
            channel = IRCChannel(self.ircd, channame)
        return {
            "user": self.ircd.users[self.ircd.userNicks[params[0]]],
            "channel": channel
        }

    def execute(self, user, data):
        data["user"].joinChannel(data["channel"], override=True)
        return True<commit_msg>Stop processing when the user for SAJOIN doesn't exist<commit_after>from twisted.plugin import IPlugin
from twisted.words.protocols import irc
from txircd.channel import IRCChannel
from txircd.module_interface import ICommand, IModuleData, Command, ModuleData
from zope.interface import implements

class SajoinCommand(ModuleData, Command):
    implements(IPlugin, IModuleData, ICommand)

    name = "SajoinCommand"

    def hookIRCd(self, ircd):
        self.ircd = ircd

    def userCommands(self):
        return [ ("SAJOIN", 1, self) ]

    def actions(self):
        return [ ("commandpermission-SAJOIN", 1, self.restrictToOpers) ]

    def restrictToOpers(self, user, command, data):
        if not self.ircd.runActionUntilValue("userhasoperpermission", user, "command-sajoin", users=[user]):
            user.sendMessage(irc.ERR_NOPRIVILEGES, ":Permission denied - You do not have the correct operator privileges")
            return False
        return None

    def parseParams(self, user, params, prefix, tags):
        if len(params) < 2:
            user.sendSingleError("SajoinCmd", irc.ERR_NEEDMOREPARAMS, "SAJOIN", ":Not enough parameters")
            return None
        if params[0] not in self.ircd.userNicks:
            user.sendSingleError("SajoinCmd", irc.ERR_NOSUCHNICK, params[0], ":No such nick/channel")
            return None
        channame = params[1]
        if channame[0] != "#":
            channame = "#{}".format(channame)
        if channame in self.ircd.channels:
            channel = self.ircd.channels[channame]
        else:
            channel = IRCChannel(self.ircd, channame)
        return {
            "user": self.ircd.users[self.ircd.userNicks[params[0]]],
            "channel": channel
        }

    def execute(self, user, data):
        data["user"].joinChannel(data["channel"], override=True)
        return True
{'fraction_non_alphanumeric': 0.10905629589339136, 'fraction_numerical': 0.004351373402230079, 'mean_word_length': 2.908607863974495, 'pattern_counts': {'":': 12, '<': 5, '<?xml version=': 0, '>': 3, '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': '4488351', 'n_tokens_mistral': 1125, 'n_tokens_neox': 1099, 'n_words': 271}