twisted.words.protocols.irc.ERR_NOTREGISTERED

Here are the examples of the python api twisted.words.protocols.irc.ERR_NOTREGISTERED taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

54 Examples 7

Example 1

Project: txircd
Source File: cmd_admin.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "ADMIN", ":You have not registered")
            return {}
        return {
            "user": user
        }

Example 2

Project: txircd
Source File: cmd_away.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "AWAY", ":You have not registered")
            return {}
        if not params or not params[0]:
            return {
                "user": user
            }
        return {
            "user": user,
            "reason": params[0]
        }

Example 3

Project: txircd
Source File: cmd_info.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "INFO", ":You have not registered")
            return {}
        return {
            "user": user
        }

Example 4

Project: txircd
Source File: cmd_ison.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "ISON", ":You have not registered")
            return {}
        if not params:
            user.sendMessage(irc.ERR_NEEDMOREPARAMS, "ISON", ":Not enough parameters")
            return {}
        extraNicks = params.pop().split(" ")
        return {
            "user": user,
            "nicklist": params + extraNicks
        }

Example 5

Project: txircd
Source File: cmd_links.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "LINKS", ":You have not registered")
            return {}
        return {
            "user": user
        }

Example 6

Project: txircd
Source File: cmd_list.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "LIST", ":You have not registered")
            return {}
        if params:
            chanFilter = irc_lower(params[0]).split(",")
        else:
            chanFilter = None
        return {
            "user": user,
            "chanfilter": chanFilter
        }

Example 7

Project: txircd
Source File: cmd_lusers.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "LUSERS", ":You have not registered")
            return {}
        return {
            "user": user
        }

Example 8

Project: txircd
Source File: cmd_motd.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "MOTD", ":You have not registered")
            return {}
        return {
            "user": user
        }

Example 9

Project: txircd
Source File: cmd_oper.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "OPER", ":You have not registered")
            return {}
        if len(params) < 2:
            user.sendMessage(irc.ERR_NEEDMOREPARAMS, "OPER", ":Not enough parameters")
            return {}
        if self.ircd.servconfig["oper_ips"] and user.ip not in self.ircd.servconfig["oper_ips"]:
            user.sendMessage(irc.ERR_NOOPERHOST, ":No O-lines for your host")
            if "sendservernotice" in self.ircd.module_data_cache:
                self.ircd.module_data_cache["sendservernotice"]("oper", "Failed OPER attempt from {} (bad IP)".format(user.nickname))
            return {}
        return {
            "user": user,
            "username": params[0],
            "password": params[1]
        }

Example 10

Project: txircd
Source File: cmd_rehash.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "REHASH", ":You have not registered")
            return {}
        if "o" not in user.mode:
            user.sendMessage(irc.ERR_NOPRIVILEGES, ":Permission denied - You do not have the required operator privileges")
            return {}
        if params:
            return {
                "user": user,
                "servers": params[0]
            }
        return {
            "user": user,
            "servers": self.ircd.name
        }

Example 11

Project: txircd
Source File: cmd_squit.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "SQUIT", ":You have not registered")
            return {}
        if "o" not in user.mode:
            user.sendMessage(irc.ERR_NOPRIVILEGES, ":Permission denied - You do not have the correct operator privileges")
            return {}
        if not params:
            user.sendMessage(irc.ERR_NEEDMOREPARAMS, "SQUIT", ":Not enough parameters")
            return {}
        if params[0] not in self.ircd.servers:
            user.sendMessage(irc.ERR_NOSUCHSERVER, params[0], ":No such server")
            return {}
        server = self.ircd.servers[params[0]]
        return {
            "user": user,
            "server": server
        }

Example 12

Project: txircd
Source File: cmd_time.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "TIME", ":You are not registered")
            return {}
        return {
            "user": user
        }

Example 13

Project: txircd
Source File: cmd_userhost.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "USERHOST", ":You have not registered")
            return {}
        if not params:
            user.sendMessage(irc.ERR_NEEDMOREPARAMS, "USERHOST", ":Not enough parameters")
            return {}
        nickList = [nick for nick in params[:5] if nick in self.ircd.users]
        return {
            "user": user,
            "targetnick": nickList
        }

Example 14

Project: txircd
Source File: cmd_wallops.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "WALLOPS", ":You have not registered")
            return {}
        if "o" not in user.mode:
            user.sendMessage(irc.ERR_NOPRIVILEGES, ":Permission denied - command WALLOPS requires oper privileges")
            return {}
        if not params:
            user.sendMessage(irc.ERR_NEEDMOREPARAMS, "WALLOPS", ":Not enough parameters")
            return {}
        return {
            "user": user,
            "message": " ".join(params)
        }

Example 15

Project: txircd
Source File: db_services_leaf.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "START", ":You have not registered")
            return {}
        if not self.module.isServiceAdmin(user, "bidserv"):
            user.sendMessage(irc.ERR_NOPRIVILEGES, ":Permission denied - You do not have the correct operator privileges")
            return {}
        return {
            "user": user,
            "params": params
        }

Example 16

Project: txircd
Source File: db_services_leaf.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "STOP", ":You have not registered")
            return {}
        if not self.module.isServiceAdmin(user, "bidserv"):
            user.sendMessage(irc.ERR_NOPRIVILEGES, ":Permission denied - You do not have the correct operator privileges")
            return {}
        return {
            "user": user,
            "params": params
        }

Example 17

Project: txircd
Source File: db_services_leaf.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "REVERT", ":You have not registered")
            return {}
        if not self.module.isServiceAdmin(user, "bidserv"):
            user.sendMessage(irc.ERR_NOPRIVILEGES, ":Permission denied - You do not have the correct operator privileges")
            return {}
        return {
            "user": user,
            "params": params
        }

Example 18

Project: txircd
Source File: db_services_leaf.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "ONCE", ":You have not registered")
            return {}
        if not self.module.isServiceAdmin(user, "bidserv"):
            user.sendMessage(irc.ERR_NOPRIVILEGES, ":Permission denied - You do not have the correct operator privileges")
            return {}
        return {
            "user": user,
            "params": params
        }

Example 19

Project: txircd
Source File: db_services_leaf.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "TWICE", ":You have not registered")
            return {}
        if not self.module.isServiceAdmin(user, "bidserv"):
            user.sendMessage(irc.ERR_NOPRIVILEGES, ":Permission denied - You do not have the correct operator privileges")
            return {}
        return {
            "user": user,
            "params": params
        }

Example 20

Project: txircd
Source File: db_services_leaf.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "SOLD", ":You have not registered")
            return {}
        if not self.module.isServiceAdmin(user, "bidserv"):
            user.sendMessage(irc.ERR_NOPRIVILEGES, ":Permission denied - You do not have the correct operator privileges")
            return {}
        return {
            "user": user,
            "params": params
        }

Example 21

Project: txircd
Source File: db_services_leaf.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "SERVADMIN", ":You have not registered")
            return {}
        if not self.module.isServiceAdmin(user, "operserv"):
            user.sendMessage(irc.ERR_NOPRIVILEGES, ":Permission denied - You do not have the correct operator privileges")
            return {}
        return {
            "user": user,
            "params": params
        }

Example 22

Project: txircd
Source File: die.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "DIE", ":You have not registered")
            return {}
        if "o" not in user.mode:
            user.sendMessage(irc.ERR_NOPRIVILEGES, ":Permission denied - You do not have the correct operator privileges")
            return {}
        return {
            "user": user
        }

Example 23

Project: txircd
Source File: globops.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "GLOBOPS", ":You have not registered")
            return {}
        if "o" not in user.mode:
            user.sendMessage(irc.ERR_NOPRIVILEGES, ":Permission denied - command GLOBOPS requires oper privileges")
            return {}
        if not params:
            user.sendMessage(irc.ERR_NEEDMOREPARAMS, "GLOBOPS", ":Not enough parameters")
            return {}
        return {
            "user": user,
            "message": " ".join(params)
        }

Example 24

Project: txircd
Source File: ircv3_monitor.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "MONITOR", ":You have not registered")
            return {}
        if not params:
            user.sendMessage(irc.ERR_NEEDMOREPARAMS, "MONITOR", ":Not enough parameters")
            return {}
        if params[0] in ["C", "L", "S"]:
            return {
                "user": user,
                "modifier": params[0]
            }
        if params[0] in ["+", "-"]:
            return {
                "user": user,
                "modifier": params[0],
                "targetlist": params[1].split(",")
            }
        return {}

Example 25

Project: txircd
Source File: modules.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "MODULES", ":You have not registered")
            return {}
        return {
            "user": user
        }

Example 26

Project: txircd
Source File: restart.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "RESTART", ":You have not registered")
            return {}
        if "o" not in user.mode:
            user.sendMessage(irc.ERR_NOPRIVILEGES, ":Permission denied - You do not have the correct operator privileges")
            return {}
        return {
            "user": user
        }

Example 27

Project: txircd
Source File: satopic.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "SATOPIC", ":You have not registered")
            return {}
        if "o" not in user.mode:
            user.sendMessage(irc.ERR_NOPRIVILEGES, ":Permission denied - You do not have the correct operator privileges")
            return {}
        if not params or len(params) < 2:
            user.sendMessage(irc.ERR_NEEDMOREPARAMS, "SATOPIC", ":Not enough parameters")
            return {}
        if params[0] not in self.ircd.channels:
            user.sendMessage(irc.ERR_NOSUCHCHANNEL, params[0], ":No such channel")
            return {}
        return {
            "user": user,
            "targetchan": self.ircd.channels[params[0]],
            "topic": " ".join(params[1:])
        }

Example 28

Project: txircd
Source File: badword.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "BADWORD", ":You have not registered")
            return {}
        if "o" not in user.mode:
            user.sendMessage(irc.ERR_NOPRIVILEGES, ":Permission denied - You do not have the correct operator privileges")
            return {}
        if not params:
            user.sendMessage(irc.ERR_NEEDMOREPARAMS, "BADWORD", ":Not enough parameters")
            return {}
        if param[0][0] == "-":
            badword = params[0][1:]
            if badword not in self.badwords:
                user.sendMessage(irc.ERR_NOSUCHBADWORD, badword, ":No such badword")
                return {}
            return {
                "user": user,
                "badword": badword
            }
        return {
            "user": user,
            "badword": params[0],
            "replacement": params[1] if len(params) > 1 else ""
        }

Example 29

Project: txircd
Source File: cmd_connect.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "CONNECT", ":You have not registered")
            return {}
        if "o" not in user.mode:
            user.sendMessage(irc.ERR_NOPRIVILEGES, ":Permission denied - You do not have the correct operator privileges")
            return {}
        if not params:
            user.sendMessage(irc.ERR_NEEDMOREPARAMS, "CONNECT", ":Not enough parameters")
            return {}
        if len(params) >= 2:
            if params[0] not in self.ircd.servers:
                user.sendMessage(irc.ERR_NOSUCHSERVER, params[0], ":No such server")
                return {}
            if params[1] in self.ircd.servers:
                server = self.ircd.servers[params[1]]
                user.sendMessage(irc.ERR_NOSUCHSERVER, server.name, ":The server is already connected to {}".format(server.nearHop)) # Steal this numeric because I can't find a better one
                return {}
            return {
                "user": user,
                "sourceserver": params[0],
                "destserver": params[1]
            }
        if params[0] in self.ircd.servers:
            server = self.ircd.servers[params[0]]
            user.sendMessage(irc.ERR_NOSUCHSERVER, server.name, ":The server is already connected to {}".format(server.nearHop))
        return {
            "user": user,
            "destserver": params[0]
        }

Example 30

Project: txircd
Source File: cmd_eline.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "ELINE", ":You have not registered")
            return {}
        if "o" not in user.mode:
            user.sendMessage(irc.ERR_NOPRIVILEGES, ":Permission denied - You do not have the correct operator privileges")
            return {}
        if not params:
            user.sendMessage(irc.ERR_NEEDMOREPARAMS, "ELINE", ":Not enough parameters")
            return {}
        banmask = params[0]
        if banmask in self.ircd.users:
            udata = self.ircd.users[banmask]
            banmask = "{}@{}".format(udata.username, udata.hostname)
        elif "@" not in banmask:
            banmask = "*@{}".format(banmask)
        self.expire_elines()
        if banmask[0] == "-":
            banmask = banmask[1:]
            if not banmask:
                user.sendMessage(irc.ERR_NEEDMOREPARAMS, "ELINE", ":Not enough parameters")
                return {}
            if banmask not in self.exceptList:
                user.sendMessage("NOTICE", ":*** E:line for {} not found! Check /stats E to view currently set e:lines.".format(banmask))
                return {}
            return {
                "user": user,
                "mask": banmask
            }
        if len(params) < 3 or not params[2]:
            user.sendMessage(irc.ERR_NEEDMOREPARAMS, "ELINE", ":Not enough parameters")
            return {}
        if banmask[0] == "+":
            banmask = banmask[1:]
            if not banmask:
                user.sendMessage(irc.ERR_NEEDMOREPARAMS, "ELINE", ":Not enough parameters")
                return {}
        if banmask in self.exceptList:
            user.sendMessage("NOTICE", ":*** An e:line is already set on {}!  Check /stats E to view currently set e:lines.".format(banmask))
            return {}
        return {
            "user": user,
            "mask": banmask,
            "duration": parse_duration(params[1]),
            "reason": " ".join(params[2:])
        }

Example 31

Project: txircd
Source File: cmd_gline.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "GLINE", ":You have not registered")
            return {}
        if "o" not in user.mode:
            user.sendMessage(irc.ERR_NOPRIVILEGES, ":Permission denied - You do not have the correct operator privileges")
            return {}
        if not params:
            user.sendMessage(irc.ERR_NEEDMOREPARAMS, "GLINE", ":Not enough parameters")
            return {}
        banmask = params[0]
        if banmask in self.ircd.users:
            banmask = "{}@{}".format(user.username, user.hostname)
        elif "@" not in banmask:
            banmask = "*@{}".format(banmask)
        self.expire_glines()
        if banmask[0] == "-":
            banmask = banmask[1:]
            if not banmask:
                user.sendMessage(irc.ERR_NEEDMOREPARAMS, "GLINE", ":Not enough parameters")
                return {}
            if banmask not in self.banList:
                user.sendMessage("NOTICE", ":*** G:line for {} does not currently exist; check /stats G for a list of active g:lines".format(banmask))
                return {}
            return {
                "user": user,
                "mask": banmask
            }
        if len(params) < 3 or not params[2]:
            user.sendMessage(irc.ERR_NEEDMOREPARAMS, "GLINE", ":Not enough parameters")
            return {}
        if banmask[0] == "+":
            banmask = banmask[1:]
            if not banmask:
                user.sendMessage(irc.ERR_NEEDMOREPARAMS, "GLINE", ":Not enough parameters")
                return {}
        if banmask in self.banList:
            user.sendMessage("NOTICE", ":*** There's already a g:line set on {}!  Check /stats G for a list of active g:lines.".format(banmask))
            return {}
        return {
            "user": user,
            "mask": banmask,
            "duration": parse_duration(params[1]),
            "reason": " ".join(params[2:])
        }

Example 32

Project: txircd
Source File: cmd_invite.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "INVITE", ":You have not registered")
            return {}
        if not params or len(params) < 2:
            user.sendMessage(irc.ERR_NEEDMOREPARAMS, "INVITE", ":Not enough parameters")
            return {}
        if params[0] not in self.ircd.users:
            user.sendMessage(irc.ERR_NOSUCHNICK, params[0], ":No such nick/channel")
            return {}
        if params[1] not in self.ircd.channels:
            user.sendMessage(irc.ERR_NOSUCHNICK, params[1], ":No such nick/channel")
            return {}
        udata = self.ircd.users[params[0]]
        cdata = self.ircd.channels[params[1]]
        if udata in cdata.users:
            user.sendMessage(irc.ERR_USERONCHANNEL, udata.nickname, cdata.name, ":is already on channel")
            return {}
        if user not in cdata.users:
            user.sendMessage(irc.ERR_NOTONCHANNEL, cdata.name, ":You're not on that channel")
            return {}
        if "i" in cdata.mode and not user.hasAccess(cdata, self.ircd.servconfig["channel_minimum_level"]["INVITE"]):
            user.sendMessage(irc.ERR_CHANOPRIVSNEEDED, cdata.name, ":You're not a channel operator")
            return {}
        return {
            "user": user,
            "targetuser": udata,
            "targetchan": cdata
        }

Example 33

Project: txircd
Source File: cmd_join.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "JOIN", ":You have not registered")
            return {}
        if not params:
            user.sendMessage(irc.ERR_NEEDMOREPARAMS, "JOIN", ":Not enough parameters")
            return {}
        channels = params[0].split(",")
        keys = params[1].split(",") if len(params) > 1 else []
        joining = []
        for i in range(0, len(channels)):
            channame = channels[i][:64]
            if not channame:
                user.sendMessage(irc.ERR_BADCHANMASK, "*", ":Bad Channel Mask")
                continue
            if channame[0] != "#":
                user.sendMessage(irc.ERR_BADCHANMASK, channame, ":Bad Channel Mask")
                continue
            if channame in self.ircd.channels:
                cdata = self.ircd.channels[channame]
            else:
                cdata = IRCChannel(self.ircd, channame)
            joining.append({"channel": cdata, "key": keys[i] if i < len(keys) else None})
        remove = []
        for chan in joining:
            if user in chan["channel"].users:
                remove.append(chan)
        for chan in remove:
            joining.remove(chan)
        channels = []
        keys = []
        for chan in joining:
            channels.append(chan["channel"])
            keys.append(chan["key"])
        return {
            "user": user,
            "targetchan": channels,
            "keys": keys,
            "moreparams": params[2:]
        }

Example 34

Project: txircd
Source File: cmd_kick.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "KICK", ":You have not registered")
            return {}
        if not params or len(params) < 2:
            user.sendMessage(irc.ERR_NEEDMOREPARAMS, "KICK", ":Not enough parameters")
            return {}
        if params[0] not in self.ircd.channels:
            user.sendMessage(irc.ERR_NOSUCHCHANNEL, params[0], ":No such channel")
            return {}
        cdata = self.ircd.channels[params[0]]
        if not user.hasAccess(cdata, self.ircd.servconfig["channel_minimum_level"]["KICK"]):
            user.sendMessage(irc.ERR_CHANOPRIVSNEEDED, cdata.name, ":You must have channel operator access to kick users")
            return {}
        if params[1] not in self.ircd.users:
            user.sendMessage(irc.ERR_NOSUCHNICK, params[1], ":No such nick")
            return {}
        udata = self.ircd.users[params[1]]
        if udata not in cdata.users:
            user.sendMessage(irc.ERR_USERNOTINCHANNEL, udata.nickname, cdata.name, ":They are not on that channel")
            return {}
        if cdata.users[udata] and not user.hasAccess(cdata, cdata.users[udata][0]):
            user.sendMessage(irc.ERR_CHANOPRIVSNEEDED, cdata.name, ":You must have higher operator access than the user to kick")
            return {}
        if len(params) < 3 or not params[2]:
            reason = user.nickname
        else:
            reason = params[2]
        return {
            "user": user,
            "targetchan": cdata,
            "targetuser": udata,
            "reason": reason
        }

Example 35

Project: txircd
Source File: cmd_kill.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "KILL", ":You have not registered")
            return {}
        if "o" not in user.mode:
            user.sendMessage(irc.ERR_NOPRIVILEGES, ":Permission denied - You do not have the correct operator privileges")
            return {}
        if not params or len(params) < 2:
            user.sendMessage(irc.ERR_NEEDMOREPARAMS, "KILL", ":Not enough parameters")
            return {}
        if params[0] not in self.ircd.users:
            user.sendMessage(irc.ERR_NOSUCHNICK, params[0], ":No such nick/channel")
            return {}
        target = self.ircd.users[params[0]]
        if "o" in target.mode:
            user.sendMessage(irc.ERR_NOPRIVILEGES, ":Permission denied - You cannot KILL another oper")
            return {}
        return {
            "user": user,
            "targetuser": target,
            "reason": " ".join(params[1:])
        }

Example 36

Project: txircd
Source File: cmd_kline.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "KLINE", ":You have not registered")
            return {}
        if "o" not in user.mode:
            user.sendMessage(irc.ERR_NOPRIVILEGES, ":Permission denied - You do not have the correct operator privileges")
            return {}
        if not params:
            user.sendMessage(irc.ERR_NEEDMOREPARAMS, "KLINE", ":Not enough parameters")
            return {}
        banmask = params[0]
        if banmask in self.ircd.users:
            banmask = "{}@{}".format(user.username, user.hostname)
        elif "@" not in banmask:
            banmask = "*@{}".format(banmask)
        self.expire_klines()
        if banmask[0] == "-":
            banmask = banmask[1:]
            if not banmask:
                user.sendMessage(irc.ERR_NEEDMOREPARAMS, "KLINE", ":Not enough parameters")
                return {}
            if banmask not in self.banList:
                user.sendMessage("NOTICE", ":*** K:line for {} does not currently exist; check /stats K for a list of active k:lines".format(banmask))
                return {}
            return {
                "user": user,
                "mask": banmask
            }
        if len(params) < 3 or not params[2]:
            user.sendMessage(irc.ERR_NEEDMOREPARAMS, "KLINE", ":Not enough parameters")
            return {}
        if banmask[0] == "+":
            banmask = banmask[1:]
            if not banmask:
                user.sendMessage(irc.ERR_NEEDMOREPARAMS, "KLINE", ":Not enough parameters")
                return {}
        if banmask in self.banList:
            user.sendMessage("NOTICE", ":*** There's already a k:line set on {}!  Check /stats K for a list of active k:lines.".format(banmask))
            return {}
        return {
            "user": user,
            "mask": banmask,
            "duration": parse_duration(params[1]),
            "reason": " ".join(params[2:])
        }

Example 37

Project: txircd
Source File: cmd_mode.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "MODE", ":You have not registered")
            return {}
        if not params:
            user.sendMessage(irc.ERR_NEEDMOREPARAMS, "MODE", ":Not enough parameters")
            return {}
        if params[0] in self.ircd.users:
            if len(params) > 1 and params[1]:
                return {
                    "user": user,
                    "targetuser": self.ircd.users[params[0]],
                    "modes": params[1],
                    "params": params[2:]
                }
            return {
                "user": user,
                "targetuser": self.ircd.users[params[0]]
            }
        if params[0] in self.ircd.channels:
            cdata = self.ircd.channels[params[0]]
            if not user.hasAccess(cdata, self.ircd.servconfig["channel_minimum_level"]["MODE"]):
                if len(params) > 2:
                    user.sendMessage(irc.ERR_CHANOPRIVSNEEDED, cdata.name, ":You must have channel operator access to set channel modes")
                    return {}
                if len(params) > 1:
                    for mode in params[1]:
                        if mode == "+" or mode == "-":
                            continue
                        if mode in self.ircd.channel_mode_type and self.ircd.channel_mode_type[mode] != 0:
                            user.sendMessage(irc.ERR_CHANOPRIVSNEEDED, cdata.name, ":You must have channel operator access to set channel modes")
                            return {}
            if len(params) > 1 and params[1]:
                return {
                    "user": user,
                    "targetchan": cdata,
                    "modes": params[1],
                    "params": params[2:]
                }
            return {
                "user": user,
                "targetchan": cdata
            }
        user.sendMessage(irc.ERR_NOSUCHNICK, params[0], ":No such nick/channel")
        return {}

Example 38

Project: txircd
Source File: cmd_names.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "NAMES", ":You have not registered")
            return {}
        if params:
            channames = params[0].split(",")
            channels = []
            for chan in channames:
                if chan in self.ircd.channels:
                    channels.append(self.ircd.channels[chan])
                else:
                    user.sendMessage(irc.ERR_NOSUCHNICK, chan, ":No such nick/channel")
        else:
            channels = []
            for chan in self.ircd.channels.itervalues:
                if user in chan.users:
                    channels.append(chan)
        return {
            "user": user,
            "targetchan": channels
        }

Example 39

Project: txircd
Source File: cmd_part.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "PART", ":You have not registered")
            return {}
        if not params:
            user.sendMessage(irc.ERR_NEEDMOREPARAMS, "PART", ":Not enough parameters")
            return {}
        channels = params[0].split(",")
        reason = params[1] if len(params) > 1 else None
        chanInstList = []
        for chan in channels:
            if chan not in self.ircd.channels:
                user.sendMessage(irc.ERR_NOSUCHCHANNEL, chan, ":No such channel")
                continue
            cdata = self.ircd.channels[chan]
            if user not in cdata.users:
                user.sendMessage(irc.ERR_NOTONCHANNEL, chan, ":You're not on that channel")
            else:
                chanInstList.append(cdata)
        if reason:
            return {
                "user": user,
                "targetchan": chanInstList,
                "reason": reason
            }
        return {
            "user": user,
            "targetchan": chanInstList
        }

Example 40

Project: txircd
Source File: cmd_privmsg_notice.py
View license
    def processParams(self, cmd, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, cmd, ":You have not registered")
            return {}
        if not params:
            user.sendMessage(irc.ERR_NEEDMOREPARAMS, cmd, ":Not enough parameters")
            return {}
        if len(params) < 2:
            user.sendMessage(irc.ERR_NOTEXTTOSEND, ":No text to send")
            return {}
        targetChans = []
        targetUsers = []
        targetChanModifiers = []
        for target in params[0].split(","):
            if target in self.ircd.users:
                targetUsers.append(self.ircd.users[target])
            elif target in self.ircd.channels:
                targetChans.append(self.ircd.channels[target])
                targetChanModifiers.append("")
            elif target[0] in self.ircd.prefix_symbols and target[1:] in self.ircd.channels:
                targetChans.append(self.ircd.channels[target[1:]])
                targetChanModifiers.append(target[0])
            else:
                user.sendMessage(irc.ERR_NOSUCHNICK, target, ":No such nick/channel")
        return {
            "user": user,
            "targetchan": targetChans,
            "chanmod": targetChanModifiers,
            "targetuser": targetUsers,
            "message": params[1]
        }

Example 41

Project: txircd
Source File: cmd_qline.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "QLINE", ":You have not registered")
            return {}
        if "o" not in user.mode:
            user.sendMessage(irc.ERR_NOPRIVILEGES, ":Permission denied - You do not have the correct operator privileges")
            return {}
        if not params:
            user.sendMessage(irc.ERR_NEEDMOREPARAMS, "QLINE", ":Not enough parameters")
            return {}
        self.expire_qlines()
        banmask = params[0]
        if banmask[0] == "-":
            banmask = banmask[1:]
            if not banmask:
                user.sendMessage(irc.ERR_NEEDMOREPARAMS, "QLINE", ":Not enough parameters")
                return {}
            if banmask not in self.banList:
                user.sendMessage("NOTICE", ":*** There is not a q:line set on {}; check /stats Q for a list of existing q:lines".format(banmask))
                return {}
            return {
                "user": user,
                "mask": banmask
            }
        if len(params) < 3 or not params[2]:
            user.sendMessage(irc.ERR_NEEDMOREPARAMS, "QLINE", ":Not enough parameters")
            return {}
        if banmask[0] == "+":
            banmask = banmask[1:]
            if not banmask:
                user.sendMessage(irc.ERR_NEEDMOREPARAMS, "QLINE", ":Not enough parameters")
                return {}
        if banmask in self.banList:
            user.sendMessage("NOTICE", ":*** Q:line already exists for {}!  Check /stats Q for a list of existing q:lines.".format(params[0]))
            return {}
        bancheck = banmask.replace("*", "")
        if not bancheck or ("*" in banmask and bancheck == "?"):
            user.sendMessage("NOTICE", ":*** That q:line will match all nicks!  Please check your nick mask and try again.")
            return {}
        if not VALID_NICKNAME.match(params[0].replace("*", "").replace("?", "a")):
            user.sendMessage("NOTICE", ":*** That isn't a valid nick mask and won't match any nicks.  Please check your nick mask and try again.")
            return {}
        return {
            "user": user,
            "mask": banmask,
            "duration": parse_duration(params[1]),
            "reason": " ".join(params[2:])
        }

Example 42

Project: txircd
Source File: cmd_stats.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "STATS", ":You have not registered")
            return {}
        if not params or not params[0]:
            user.sendMessage(irc.ERR_NEEDMOREPARAMS, "STATS", ":Not enough parameters")
            return {}
        statschar = params[0][0]
        if "o" not in user.mode and statschar not in self.ircd.servconfig["server_stats_public"]:
            user.sendMessage(irc.ERR_NOPRIVILEGES, ":Permission denied - Stats {} requires operator privileges".format(statschar))
            return {}
        if len(params) == 1:
            return {
                "user": user,
                "statstype": statschar
            }
        if params[1] not in self.ircd.servers:
            user.sendMessage(irc.ERR_NOSUCHSERVER, params[1], ":No such server")
            return {}
        return {
            "user": user,
            "statstype": statschar,
            "server": self.ircd.servers[params[1]]
        }

Example 43

Project: txircd
Source File: cmd_topic.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "TOPIC", ":You have not registered")
            return {}
        if not params:
            user.sendMessage(irc.ERR_NEEDMOREPARAMS, "TOPIC", ":Not enough parameters")
            return {}
        if params[0] not in self.ircd.channels:
            user.sendMessage(irc.ERR_NOSUCHCHANNEL, params[0], ":No such channel")
            return {}
        cdata = self.ircd.channels[params[0]]
        if user not in cdata.users:
            user.sendMessage(irc.ERR_NOTONCHANNEL, cdata.name, ":You're not in that channel")
            return {}
        if len(params) == 1:
            return {
                "user": user,
                "targetchan": cdata
            }
        return {
            "user": user,
            "targetchan": cdata,
            "topic": params[1]
        }

Example 44

Project: txircd
Source File: cmd_who.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "WHO", ":You have not registered")
            return {}
        if not params:
            return {
                "user": user
            }
        target = params[0]
        filters = params[1] if len(params) > 1 else ""
        if "%" in filters:
            filters, fields = filters.split("%", 1)
        else:
            fields = ""
        if target[0][0] == "#" and target not in self.ircd.channels:
            user.sendMessage(irc.RPL_ENDOFWHO, channel, ":End of /WHO list")
            return {}
        return {
            "user": user,
            "target": target,
            "filters": filters,
            "fields": fields
        }

Example 45

Project: txircd
Source File: cmd_whois.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "WHOIS", ":You have not registered")
            return {}
        if not params:
            user.sendMessage(irc.ERR_NONICKNAMEGIVEN, ":No nickname given")
            return {}
        users = params[0].split(",")
        targets = []
        for u in users:
            if u not in self.ircd.users:
                user.sendMessage(irc.ERR_NOSUCHNICK, u, ":No such nick/channel")
                continue
            targets.append(self.ircd.users[u])
        if not targets:
            user.sendMessage(irc.RPL_ENDOFWHOIS, "*", ":End of /WHOIS list")
            return {}
        return {
            "user": user,
            "targetuser": targets
        }

Example 46

Project: txircd
Source File: cmd_whowas.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "WHOWAS", ":You have not registered")
            return {}
        if not params:
            user.sendMessage(irc.ERR_NONICKNAMEGIVEN, ":No nickname given")
            return {}
        users = params[0].split(",")
        if len(params) >= 2:
            count = None
            hostType = None
            if params[1].isdigit():
                count = int(params[1])
            elif "o" in user.mode:
                hostType = params[1].lower()
            if len(params) >= 3 and hostType is None and "o" in user.mode:
                hostType = params[2].lower()
            if hostType not in ("realhost", "ip"):
                hostType = None
            if count and count > 0 and hostType:
                return {
                    "user": user,
                    "nicks": users,
                    "count": count,
                    "hosttype": hostType
                }
            elif hostType:
                return {
                    "user": user,
                    "nicks": users,
                    "hosttype": hostType
                }
            elif count and count > 0:
                return {
                    "user": user,
                    "nicks": users,
                    "count": count
                }
        return {
            "user": user,
            "nicks": users
        }

Example 47

Project: txircd
Source File: cmd_zline.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "ZLINE", ":You have not registered")
            return {}
        if "o" not in user.mode:
            user.sendMessage(irc.ERR_NOPRIVILEGES, ":Permission denied - You do not have the correct operator privileges")
            return {}
        if not params:
            user.sendMessage(irc.ERR_NEEDMOREPARAMS, "ZLINE", ":Not enough parameters")
            return {}
        banmask = params[0]
        if banmask in self.ircd.users:
            banmask = self.ircd.users[banmask].ip
        self.expire_zlines()
        if banmask[0] == "-":
            banmask = banmask[1:]
            if not banmask:
                user.sendMessage(irc.ERR_NEEDMOREPARAMS, "ZLINE", ":Not enough parameters")
                return {}
            if banmask not in self.banList:
                user.sendMessage("NOTICE", ":*** Z:line on {} not found!  Check /stats Z for a list of active z:lines.".format(banmask))
                return {}
            return {
                "user": user,
                "mask": banmask
            }
        if len(params) < 3 or not params[2]:
            user.sendMessage(irc.ERR_NEEDMOREPARAMS, "ZLINE", ":Not enough parameters")
            return {}
        if banmask[0] == "+":
            banmask = banmask[1:]
            if not banmask:
                user.sendMessage(irc.ERR_NEEDMOREPARAMS, "ZLINE", ":Not enough parameters")
                return {}
        if banmask in self.banList:
            user.sendMessage("NOTICE", ":*** There is already a z:line set on {}!  Check /stats Z for a list of active z:lines.".format(banmask))
            return {}
        return {
            "user": user,
            "mask": banmask,
            "duration": parse_duration(params[1]),
            "reason": " ".join(params[2:])
        }

Example 48

Project: txircd
Source File: ircv3_metadata.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "METADATA", ":You have not registered")
            return {}
        if not params or len(params) < 2:
            user.sendMessage(irc.ERR_NEEDMOREPARAMS, "METADATA", ":Not enough parameters")
            return {}
        target = None
        targetname = None
        if params[0] in self.ircd.channels:
            target = self.ircd.channels[params[0]]
            targetname = target.name
        elif params[0] in self.ircd.users:
            target = self.ircd.users[params[0]]
            targetname = target.nickname
        else:
            user.sendMessage(irc.ERR_TARGETINVALID, params[0], ":invalid metadata target")
            return {}
        subcmd = params[1].upper()
        if subcmd == "LIST":
            return {
                "user": user,
                "targetname": targetname,
                "target": target,
                "subcmd": "LIST",
                "filter": params[2] if len(params) >= 3 else None
            }
        if subcmd == "SET":
            if len(params) < 3:
                user.sendMessage(irc.ERR_NEEDMOREPARAMS, "METADATA", ":Not enough parameters")
                return {}
            if "o" not in user.mode:
                try:
                    if not user.hasAccess(target, self.ircd.servconfig["channel_minimum_level"]["METADATA"]):
                        user.sendMessage(irc.ERR_CHANOPRIVSNEEDED, target.name, ":You do not have access to set metadata on this channel")
                        return {}
                except AttributeError: # in this case, it's a user, not a channel
                    if user != target:
                        user.sendMessage(irc.ERR_NOPRIVILEGES, ":Permission denied - You do not have the correct operator privileges")
                        return {}
            if "." not in params[2]:
                user.sendMessage(irc.ERR_KEYINVALID, params[2], ":invalid metadata key")
                return {}
            return {
                "user": user,
                "targetname": targetname,
                "target": target,
                "subcmd": "SET",
                "key": params[2],
                "value": params[3] if len(params) >= 4 else None
            }
        if subcmd == "CLEAR":
            if "o" not in user.mode and user != target:
                user.sendMessage(irc.ERR_NOPRIVILEGES, ":Permission denied - You do not have the correct operator privileges")
                return {}
            return {
                "user": user,
                "targetname": targetname,
                "target": target,
                "subcmd": "CLEAR"
            }
        user.sendMessage(irc.ERR_NEEDMOREPARAMS, "METADATA", ":Incorrect metadata subcommand") # borrowing this numeric is fine
        return {}

Example 49

Project: txircd
Source File: knock.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "KNOCK", ":You have not registered")
            return {}
        if not params:
            user.sendMessage(irc.ERR_NEEDMOREPARAMS, "KNOCK", ":Not enough parameters")
            return {}
        if params[0] not in self.ircd.channels:
            user.sendMessage(irc.ERR_NOSUCHCHANNEL, params[0], ":No such channel")
            return {}
        cdata = self.ircd.channels[params[0]]
        if user in cdata.users:
            user.sendMessage(irc.ERR_KNOCKONCHAN, cdata.name, ":You are already on that channel")
            return {}
        if "i" not in cdata.mode:
            user.sendMessage(irc.ERR_CHANOPEN, cdata.name, ":Channel is open")
            return {}
        if "knocks" in user.cache and cdata.name in user.cache["knocks"]:
            user.sendMessage(irc.ERR_TOOMANYKNOCK, cdata.name, ":Too many KNOCKs (user)")
            return {}
        return {
            "user": user,
            "targetchan": cdata,
            "reason": " ".join(params[1:]) if len(params) > 1 else "has asked for an invite"
        }

Example 50

Project: txircd
Source File: sajoin.py
View license
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "SAJOIN", ":You have not registered")
            return {}
        if "o" not in user.mode:
            user.sendMessage(irc.ERR_NOPRIVILEGES, ":Permission denied - You do not have the correct operator privileges")
            return {}
        if not params or len(params) < 2:
            user.sendMessage(irc.ERR_NEEDMOREPARAMS, "SAJOIN", ":Not enough parameters")
            return {}
        if params[0] not in self.ircd.users:
            user.sendMessage(irc.ERR_NOSUCHNICK, params[0], ":No such nick/channel")
            return {}
        if params[1][0] != "#":
            user.sendMessage(irc.ERR_BADCHANMASK, chan["channel"], ":Bad Channel Mask")
            return {}
        if params[1] in self.ircd.channels:
            cdata = self.ircd.channels[params[1]]
        else:
            cdata = IRCChannel(self.ircd, params[1])
        return {
            "user": user,
            "targetuser": self.ircd.users[params[0]],
            "targetchan": cdata
        }