Exemple #1
0
    def execute(self, message, user, params):
        if not Config.get("Twilio", "sid"):
            message.reply("Twilio support not configured. Tell the admin. If you are the admin, configure Twilio or disable !call to prevent this message.")
            return

        rec = params.group(1)
        receiver=User.load(name=rec,exact=False,access="member") or User.load(name=rec)
        if not receiver:
            message.reply("Who exactly is %s?" % (rec,))
            return
        if receiver.smsmode == "Retard":
            message.reply("I refuse to talk to that incompetent retard. Check %s's mydef comment and use !phone show to try sending it using your own phone." %(receiver.name,))
            return 

        if not (receiver.pubphone or user in receiver.phonefriends or user.is_admin()):
            message.reply("%s's phone number is private or they have not chosen to share their number with you. No call made." % (receiver.name,))
            return

        phone = self.prepare_phone_number(receiver.phone)
        if not phone or len(phone) <= 7:
            message.reply("%s has no phone number or their phone number is too short to be valid (under 6 digits). No call made." % (receiver.name,))
            return

        client = Client(Config.get("Twilio", "sid"), Config.get("Twilio", "auth_token"))
        if Config.getboolean("Twilio", "warn"):
            url="http://twimlets.com/echo?Twiml=%3CResponse%3E%3CSay%20voice%3D%22alice%22%20language%3D%22en-GB%22%20%3EHello.%20This%20is%20" +\
                Config.get("Connection", "nick") + ".%20Stop%20wasting%20our%20credit!%3C%2FSay%3E%3CHangup%2F%3E%3C%2FResponse%3E&",
        else:
            url="http://twimlets.com/echo?Twiml=%3CResponse%3E%3CHangup%2F%3E%3C%2FResponse%3E&",
        tw = client.api.account.calls.create(to=phone, from_=Config.get("Twilio", "number"), url=url, timeout=Config.getint("Twilio", "timeout"))

        if tw.sid:
            message.reply("Successfully called %s." % (receiver.name))
        else:
            message.reply("Error: Failed to get call ID from Twilio server.")
Exemple #2
0
    def execute(self, message, user, params):

        rec = params.group(1)
        shortmsg = params.group(2) is not None
        public_text = params.group(3) + (' - %s' %
                                         (user.name, ) if not shortmsg else '')
        text = encode(public_text)
        receiver = User.load(name=rec, exact=False,
                             access="member") or User.load(name=rec)
        if not receiver:
            message.reply("Who exactly is %s?" % (rec, ))
            return

        email = receiver.email
        if not email:
            message.reply(
                "That incompetent retard %s hasn't provided an address. Super secret message not sent."
                % (receiver.name, ))
            return

        error = ""

        error = self.send_email(user, receiver, public_text, email, text,
                                shortmsg)

        if error is None:
            message.reply("Successfully processed To: %s Message: %s" %
                          (receiver.name, decode(text)))
        else:
            message.reply(
                error or
                "That wasn't supposed to happen. I don't really know what went wrong. Maybe your mother dropped you."
            )
Exemple #3
0
    def execute(self, message, user, params):

        # assign param variables
        search = params.group(1)

        # do stuff here
        if search.lower() == Config.get("Connection", "nick").lower():
            message.reply("I am %s. Hear me roar." %
                          (Config.get("Connection", "nick"), ))
            return

        w***e = User.load(name=search, exact=False,
                          access="member") or User.load(name=search)
        if w***e is None:
            message.reply("No users matching '%s'" % (search, ))
            return

        reply = ""
        if w***e == user:
            reply += "You are %s, you are a %s" + (
                " and you are also known as %s" if w***e.alias else
                "%s") + ". Your sponsor is %s. You have %s carebears."
        else:
            reply += "Information about %s; they are a %s" + (
                " and they are also known as %s" if w***e.alias else
                "%s") + ". Their sponsor is %s. They have %s carebears."
        reply = reply % (
            w***e.name,
            w***e.level,
            w***e.alias or "",
            w***e.sponsor,
            w***e.carebears,
        )

        message.reply(reply)
Exemple #4
0
    def execute(self, message, user, params):

        rec = params.group(1)
        shortmsg = params.group(2) is not None
        public_text = params.group(3) + (" - %s" % (user.name,) if not shortmsg else "")
        text = encode(public_text)
        receiver = User.load(name=rec, exact=False, access="member") or User.load(name=rec)
        if not receiver:
            message.reply("Who exactly is %s?" % (rec,))
            return

        email = receiver.email
        if not email:
            message.reply(
                "That incompetent retard %s hasn't provided an address. Super secret message not sent."
                % (receiver.name,)
            )
            return

        error = ""

        error = self.send_email(user, receiver, public_text, email, text, shortmsg)

        if error is None:
            message.reply("Successfully processed To: %s Message: %s" % (receiver.name, decode(text)))
        else:
            message.reply(
                error
                or "That wasn't supposed to happen. I don't really know what went wrong. Maybe your mother dropped you."
            )
Exemple #5
0
    def user_alliance(self, message, user, params):
        alliance = Alliance.load(
            params.group(1)) if params.group(1) is not None else None
        # Alliance
        if alliance is not None:
            message.reply(str(alliance))
            return

        # User
        if not self.is_user(user):
            raise PNickParseError
        elif not user.is_member():
            message.reply("No alliance matching '%s' found" %
                          (params.group(1), ))
            return
        else:
            lookup = User.load(params.group(1), exact=False,
                               access="member") or User.load(params.group(1))
            if lookup is None:
                message.reply("No alliance or user matching '%s' found" %
                              (params.group(1), ))
                return
            elif lookup.planet is None:
                message.reply("User %s has not entered their planet details" %
                              (lookup.name, ))
                return
            else:
                message.reply(str(lookup.planet))
                return
Exemple #6
0
    def execute(self, message, user, params):

        adoptee = params.group(1)
        if adoptee.lower() == Config.get("Connection", "nick").lower():
            message.reply("F**k off you stupid twat, stop trying to be a clever shit.")
            return
        if adoptee.lower() == user.name.lower():
            message.reply("Stop wanking your own dick and find a daddy to do it for you, retard.")
            return

        a = User.load(name=adoptee, access="member")
        if a is None:
            message.reply("No members matching '%s'" % (adoptee,))
            return

        s = User.load(name=a.sponsor, access="member") if a.sponsor else None
        if s is not None:
            message.reply("%s already has a daddy you filthy would-be kidnapper!" % (a.name,))
            return

        anc = user.has_ancestor(a.name)
        if anc is True:
            message.reply("Ew, incest.")
            return
        if anc is None:
            message.reply("Filthy orphans should be castrated.")
            return

        a.sponsor = user.name
        session.commit()
        message.reply("Congratulations! You're now the proud father of a not-so newly born %s!" % (a.name,))
Exemple #7
0
 def auth_user(self, name, channel, pnickf, username, password):
     # Update CUT with new nicks
     if channel is not None and self.mode_is("rapid", "join", "command"):
         self.join(channel, name)
     
     # Trying to authenticate with !letmein or !auth
     nick = self.Nicks.get(name)
     if (nick is not None) and (nick.puser is not None):
         # They already have a user associated
         return None
     
     try:
         pnick = pnickf()
         # They have a pnick, so shouldn't need to auth, let's auth them anyway
         user = User.load(name=pnick)
     except PNickParseError:
         # They don't have a pnick, expected
         user = User.load(name=username, passwd=password)
     
     if user is None:
         raise UserError
     
     if (nick is not None) and self.mode_is("rapid", "join", "command"):
         if self.Pusers.get(user.name) is None:
             # Add the user to the tracker
             self.Pusers[user.name] = Puser(user.name)
         
         if nick.puser is None:
             # Associate the user and nick
             nick.puser = self.Pusers[user.name]
             nick.puser.nicks.add(nick)
     
     # Return the SQLA User
     return user
Exemple #8
0
    def auth_user(self, name, channel, pnickf, username, password):
        # Trying to authenticate with !letmein or !auth
        nick = self.Nicks.get(name)
        if (nick is not None) and (nick.puser is not None):
            # They already have a user associated
            return None

        try:
            if pnickf is not None:
                pnick = pnickf()
            else:
                pnick = username
            # They have a pnick, so shouldn't need to auth, let's auth them anyway
            user = User.load(name=pnick)
            if user is None:
                return None
        except PNickParseError:
            # They don't have a pnick, expected
            user = User.load(name=username, passwd=password)

        if user is None:
            raise UserError

        if (nick is not None) and self.mode_is("rapid", "join"):
            if self.Pusers.get(user.name) is None:
                # Add the user to the tracker
                self.Pusers[user.name] = Puser(user.name)

            if nick.puser is None:
                # Associate the user and nick
                nick.puser = user.name
                self.Pusers[user.name].nicks.add(nick.name)

        # Return the SQLA User
        return user
Exemple #9
0
    def execute(self, message, user, params):
        text = params.group(2)
        rec = params.group(1)
        receiver=User.load(name=rec,exact=False,access="member") or User.load(name=rec)
        if not receiver:
            message.reply("Who exactly is %s?" % (rec,))
            return

        receiver.tells.append(Tell(sender_id=user.id, message=text))
        session.commit()

        message.reply("Successfully stored message for %s. Message: %s" % (receiver.name, text))
Exemple #10
0
    def execute(self, message, user, params):
        text = params.group(2)
        rec = params.group(1)
        receiver = User.load(name=rec, exact=False,
                             access="member") or User.load(name=rec)
        if not receiver:
            message.reply("Who exactly is %s?" % (rec, ))
            return

        receiver.tells.append(Tell(sender_id=user.id, message=text))
        session.commit()

        message.reply("Successfully stored message for %s. Message: %s" %
                      (receiver.name, text))
Exemple #11
0
    def execute(self, message, user, params):
        if not Config.get("Twilio", "sid"):
            message.reply(
                "Twilio support not configured. Tell the admin. If you are the admin, configure Twilio or disable !call to prevent this message."
            )
            return

        rec = params.group(1)
        receiver = User.load(name=rec, exact=False,
                             access="member") or User.load(name=rec)
        if not receiver:
            message.reply("Who exactly is %s?" % (rec, ))
            return
        if receiver.smsmode == "Retard":
            message.reply(
                "I refuse to talk to that incompetent retard. Check %s's mydef comment and use !phone show to try sending it using your own phone."
                % (receiver.name, ))
            return

        if not (receiver.pubphone or user in receiver.phonefriends
                or user.is_admin()):
            message.reply(
                "%s's phone number is private or they have not chosen to share their number with you. No call made."
                % (receiver.name, ))
            return

        phone = self.prepare_phone_number(receiver.phone)
        if not phone or len(phone) <= 7:
            message.reply(
                "%s has no phone number or their phone number is too short to be valid (under 6 digits). No call made."
                % (receiver.name, ))
            return

        client = Client(Config.get("Twilio", "sid"),
                        Config.get("Twilio", "auth_token"))
        if Config.getboolean("Twilio", "warn"):
            url="http://twimlets.com/echo?Twiml=%3CResponse%3E%3CSay%20voice%3D%22alice%22%20language%3D%22en-GB%22%20%3EHello.%20This%20is%20" +\
                Config.get("Connection", "nick") + ".%20Stop%20wasting%20our%20credit!%3C%2FSay%3E%3CHangup%2F%3E%3C%2FResponse%3E&",
        else:
            url = "http://twimlets.com/echo?Twiml=%3CResponse%3E%3CHangup%2F%3E%3C%2FResponse%3E&",
        tw = client.api.account.calls.create(
            to=phone,
            from_=Config.get("Twilio", "number"),
            url=url,
            timeout=Config.getint("Twilio", "timeout"))

        if tw.sid:
            message.reply("Successfully called %s." % (receiver.name))
        else:
            message.reply("Error: Failed to get call ID from Twilio server.")
Exemple #12
0
    def robocop(self,
                message,
                scantype,
                pa_id,
                x,
                y,
                z,
                names,
                scanner,
                reqs,
                old=False):
        nicks = []
        reply = "Old " if old else ""
        reply += "%s on %s:%s:%s " % (
            PA.get(scantype, "name"),
            x,
            y,
            z,
        )
        if ("showscanner" in Config.options("Misc")
                and Config.getboolean("Misc", "showscanner")
                and scanner != 'None'):
            reply += "from %s " % (User.load(id=scanner).name) if User.load(
                id=scanner) not in (None, 'None') else ""
        reply += Config.get("URL", "viewscan") % (pa_id, )
        if old:
            reply += " !request cancel %s if this is suitable." % (reqs)

        for name in names.split(","):
            user = User.load(name)
            for nick in CUT.get_user_nicks(name):
                nicks.append(nick)
                message.privmsg(self.url(reply, user), nick)

        if not old:
            reply = "[-%s] %s on %s:%s:%s " % (
                reqs,
                PA.get(scantype, "name"),
                x,
                y,
                z,
            )
            reply += "delivered to: "
            reply += ", ".join(nicks) if not Config.getboolean(
                "Misc", "anonscans") else "Anon"
            if Config.getboolean("Misc", "showurls"):
                reply += " (%s)" % (Config.get("URL", "viewscan") % (pa_id, ))
            from Hooks.scans.request import request
            message.privmsg(reply, request().scanchan())
Exemple #13
0
    def execute(self, message, user, params):

        rec = params.group(1)
        public_text = params.group(2) + ' - %s' % (user.name,)
        text = encode(public_text + '/%s' %(user.phone,))
        receiver=User.load(name=rec,exact=False,access="member") or User.load(name=rec)
        if not receiver:
            message.reply("Who exactly is %s?" % (rec,))
            return
        if receiver.smsmode == "Retard":
            message.reply("I refuse to talk to that incompetent retard. Check %s's mydef comment and use !phone show to try sending it using your own phone." %(receiver.name,))
            return

        if not receiver.pubphone and user not in receiver.phonefriends:
            message.reply("%s's phone number is private or they have not chosen to share their number with you. Supersecret message not sent." % (receiver.name,))
            return

        if receiver.smsmode == "Email":
            mode = receiver.smsmode
            phone = receiver.email
        else:
            mode = Config.get("Misc", "sms")
            phone = self.prepare_phone_number(receiver.phone)
            if not phone or len(phone) <= 7:
               message.reply("%s has no phone number or their phone number is too short to be valid (under 6 digits). Super secret message not sent." % (receiver.name,))
               return

        if len(text) >= 160:
            message.reply("Max length for a text is 160 characters. Your text was %i characters long. Super secret message not sent." % (len(text),))
            return

        mode = receiver.smsmode or mode if mode == "combined" else mode
        mode = mode.lower()
        error = ""

        if mode == "email":
            error = self.send_email(user, receiver, public_text, phone, text)
            sent = "Email"
        if mode == "googlevoice" or mode == "combined":
            error = self.send_googlevoice(user, receiver, public_text, phone, text)
            sent = "Google Voice"
        if mode == "clickatell" or (mode == "combined" and error is not None):
            error = self.send_clickatell(user, receiver, public_text, phone, text)
            sent = "Clickatell"
        
        if error is None:
            message.reply("%s successfully processed message to: %s saying: %s" % (sent,receiver.name,decode(text)))
        else:
            message.reply(error or "That wasn't supposed to happen. I don't really know what went wrong. Maybe your mother dropped you.")
    def get_user(self, name, channel, pnick=None, pnickf=None):
        # Regular user check
        if (pnick is None) and (pnickf is None):
            # This shouldn't happen
            return None

        nick = self.Nicks.get(name)

        if (nick and nick.puser) is not None:
            # They already have a user associated
            pnick = nick.puser
        elif pnickf is not None:
            # Call the pnick function, might raise PNickParseError
            try:
                pnick = pnickf()
            except PNickParseError:
                return None

        user = User.load(name=pnick)
        if user is None and Config.getboolean("Misc", "autoreg"):
            if nick and not nick.puser:
                if "galmate" in Config.options("Access"):
                    access = Config.getint("Access", "galmate")
                else:
                    access = 0
                user = User.load(name=pnick, active=False)
                if user is None:
                    user = User(name=pnick, access=access)
                    session.add(user)
                else:
                    user.active = True
                    user.access = access
                session.commit()
        if user is None:
            return None

        if (nick is not None) and self.mode_is("rapid", "join"):
            if self.Pusers.get(user.name) is None:
                # Add the user to the tracker
                self.Pusers[user.name] = Puser(user.name)

            if nick.puser is None:
                # Associate the user and nick
                nick.puser = user.name
                self.Pusers[user.name].nicks.add(nick.name)

        # Return the SQLA User
        return user
Exemple #15
0
 def user(self, message, user, params):
     name=params.group(1)
     u = User.load(name=name, exact=False, access="member")
     if u is None:
         message.reply("No members matching %s found"%(name,))
     else:
         self.execute(message, u)
Exemple #16
0
    def execute(self, message, user, params):

        username = params.group(1)
        member = User.load(name=username, active=False)
        if member is None:
            message.alert("No such user '%s'" % (username, ))
            return
        if member.access > user.access:
            message.reply(
                "You may not remove %s, his or her access (%s) exceeds your own (%s)"
                % (
                    member.name,
                    member.access,
                    user.access,
                ))
            return

        mbraxx = Config.getint("Access", "member")
        home = Config.get("Channels", "home")

        if member.active and member.access >= mbraxx:
            message.privmsg("remuser %s %s" % (
                home,
                member.name,
            ), Config.get("Services", "nick"))
#            message.privmsg("ban %s *!*@%s.%s GTFO, EAAD"%(home, member.name, Config.get("Services", "usermask"),), Config.get("Services", "nick"))
        session.delete(member)
        session.commit()
        message.reply("Removed user %s" % (member.name, ))
        CUT.untrack_user(member.name)
Exemple #17
0
 def execute(self, message, user, params):
     
     if params.group(1) is not None:
         penis = User.load(name=params.group(1),exact=False,access="member")
     else:
         penis = user
     if not self.is_user(penis):
         message.reply("Who the f**k is %s?" % (params.group(1),))
         return
     
     if penis.planet is None:
         if user == penis:
             message.reply("Set your planet first git.")
         else:
             message.reply("%s is too embarrassed about his tiny penis that he won't let me tell you how small it is." % (penis.name,))
         return
     
     if penis.epenis is None:
         if user == penis:
             message.reply("Wait for the tick, bitch.")
         else:
             message.reply("That freak %s doesn't have a penis!" % (penis.name,))
         return
     
     message.reply("epenis for %s is %s score long. This makes %s rank: %s for epenis in %s!" % (
                     penis.name, penis.epenis.penis, penis.name, penis.epenis.rank, Config.get("Alliance","name"),))
Exemple #18
0
    def execute(self, message, user, params):

        search = params.group(1)

        Q = session.query(FleetLog)

        if search is not None:
            ship = Ship.load(name=search)
            if ship is not None:
                Q = Q.filter(FleetLog.ship == ship)
            else:
                u = User.load(search, exact=False, access="member")
                if u is not None:
                    Q = Q.filter(FleetLog.user == u)
                else:
                    Q = Q.filter(FleetLog.id == -1)
        Q = Q.order_by(desc(FleetLog.tick))

        result = Q[:10]

        if len(result) < 1:
            message.reply("No matches found in the deflog for search '%s'" %
                          (search, ))
            return

        tick = Updates.current_tick()
        reply = ", ".join(
            map(
                lambda x: "%s gave %s %s to %s (%s)" %
                (x.user.name, self.num2short(x.ship_count), x.ship.name, x.
                 taker.name, x.tick - tick), result))
        message.reply(reply)
Exemple #19
0
 def get_user(self, name, pnick=None, pnickf=None):
     # Regular user check
     if (pnick is None) and (pnickf is None):
         # This shouldn't happen
         return None
     
     nick = self.Nicks.get(name)
     
     if (nick and nick.puser) is not None:
         # They already have a user associated
         pnick = nick.puser.name
     elif pnickf is not None:
         # Call the pnick function, might raise PNickParseError
         try:
             pnick = pnickf()
         except PNickParseError:
             return None
     
     user = User.load(name=pnick)
     if user is None:
         return None
     
     if (nick is not None) and (Config.get("Misc","usercache") in ("join", "command",)):
         if self.Pusers.get(user.name) is None:
             # Add the user to the tracker
             self.Pusers[user.name] = Puser(user.name)
         
         if nick.puser is None:
             # Associate the user and nick
             nick.puser = self.Pusers[user.name]
             nick.puser.nicks.add(nick)
     
     # Return the SQLA User
     return user
Exemple #20
0
    def execute(self, message, user, params):

        # assign param variables
        alias = params.group(1)
        if alias is None:
            m = message.get_msg().split()
            if len(m) > 1 and m[1] in self.nulls:
                pass
            else:
                message.reply("You are %s, your alias is %s" % (
                    user.name,
                    user.alias,
                ))
                return

        if alias is not None:
            if User.load(name=alias) is not None:
                message.reply(
                    "Your alias is already in use or is someone else's pnick (not allowed). Tough noogies."
                )
                return
            if session.query(User).filter(User.active == True).filter(
                    User.alias.ilike(alias)).first() is not None:
                message.reply(
                    "Your alias is already in use or is someone else's pnick (not allowed). Tough noogies."
                )
                return

        user.alias = alias
        session.commit()
        message.reply("Update alias for %s (that's you) to %s" % (
            user.name,
            user.alias,
        ))
Exemple #21
0
 def execute(self, message, user, params):
     
     if params.group(1) is not None:
         penis = User.load(name=params.group(1),exact=False,access="member")
     else:
         penis = user
     if not self.is_user(penis):
         message.reply("Who the f**k is %s?" % (params.group(1),))
         return
     
     if penis.planet is None:
         if user == penis:
             message.reply("Set your planet first git.")
         else:
             message.reply("%s is too embarrassed about his tiny penis that he won't let me tell you how small it is." % (penis.name,))
         return
     
     if penis.epenis is None:
         if user == penis:
             message.reply("Growth data will be available after 72 ticks of setting your planet in !pref.")
         else:
             message.reply("No growth data available for %s, or it is not tick 72 yet" % (penis.name,))
         return
     
     message.reply("Growth for %s is %s score long. This makes %s rank: %s for growth in %s!" % (
                     penis.name, penis.epenis.penis, penis.name, penis.epenis.rank, Config.get("Alliance","name"),))
Exemple #22
0
    def kick(self, message, user, params):
        person = params.group(1)
        if person.lower() == Config.get("Connection", "nick").lower():
            message.reply("I'll peck your eyes out, c**t.")
            return
        u = User.load(name=person, access="member")
        if u is None:
            message.reply(
                "Stupid %s, you can't kick %s, they're not a member." %
                (user.name, person))
            return
        if self.is_already_proposed_kick(person):
            message.reply("Silly %s, there's already a proposal to kick %s." %
                          (user.name, person))
            return
        if u.access > user.access:
            message.reply(
                "Unfortunately I like %s more than you. So none of that." %
                (u.name, ))
            return

        prop = Kick(proposer=user, kicked=u, comment_text=params.group(2))
        session.add(prop)
        session.commit()

        reply = "%s created a new proposition (nr. %d) to kick %s." % (
            user.name, prop.id, person)
        reply += " When people have been given a fair shot at voting you can call a count using !prop expire %d." % (
            prop.id, )
        message.reply(reply)
Exemple #23
0
 def execute(self, message, user, params):
     
     search=params.group(1)
     
     Q = session.query(FleetLog)
     
     if search != "":
         ship = Ship.load(name=search)
         if ship is not None:
             Q = Q.filter(FleetLog.ship == ship)
         else:
             u = User.load(search, exact=False, access="member")
             if u is not None:
                 Q = Q.filter(FleetLog.user == u)
             else:
                 Q = Q.filter(FleetLog.id == -1)
     Q = Q.order_by(desc(FleetLog.tick))
     
     result = Q[:10]
     
     if len(result) < 1:
         message.reply("No matches found in the deflog for search '%s'"%(search,))
         return
     
     tick = Updates.current_tick()
     reply = ", ".join(map(lambda x:"%s gave %s %s to %s (%s)"%(x.user.name,self.num2short(x.ship_count),x.ship.name,x.taker.name,x.tick-tick),result))
     message.reply(reply)
Exemple #24
0
    def show_prefs(self, message, user, params):

        name=params.group(1)
        u = User.load(name=name, exact=False)
        if u is None:
            message.reply("No members matching %s found"%(name,))
            return
        else:
            user=u

        reply = ""
        if user.planet is not None:
            reply += " planet=%s:%s:%s" % (user.planet.x,user.planet.y,user.planet.z,)
        if user.url:
            reply += " url: %s" % (Config.get("alturls", user.url),)
        if user.email:
            reply += " email=%s" % (user.email,)
        if user.phone:
            reply += " phone=%s pubphone=%s" % (user.phone, str(user.pubphone)[0],)
            if user.smsmode is not None:
                reply += " smsmode=%s" % (user.smsmode,)
        if len(reply) > 0:
            message.reply("Your preferences are:" + reply)
        else:
            message.reply("You haven't set any preferences, use !help pref to view the options")
Exemple #25
0
    def show(self, message, user, params):
        trustee = params.group(1)
        member = User.load(name=trustee, exact=False)
        if member is None:
            message.alert("%s is not a valid user." % (trustee, ))
            return

        # Show a phone number
        # Instead of the no-public-Alki message, message.alert() will always return in private
        if user == member:
            if user.phone:
                reply = "Your phone number is %s." % (user.phone, )
            else:
                reply = "You haven't set your phone number. To set your phone number, do !pref phone=1-800-HOT-BIRD."
            message.alert(reply)
            return

        if member.pubphone and user.is_member():
            message.alert("%s says his phone number is %s" %
                          (member.name, member.phone))
            return
        friends = member.phonefriends
        if user not in friends:
            message.reply(
                "%s won't let you see their phone number. That paranoid c**t just doesn't trust you I guess."
                % (member.name, ))
            return
        if member.phone:
            message.alert("%s says his phone number is %s" %
                          (member.name, member.phone))
        else:
            message.reply(
                "%s hasn't shared his phone number. What a paranoid c**t ." %
                (member.name, ))
            return
Exemple #26
0
 def invite(self, message, user, params):
     person = params.group(1)
     if person.lower() == Config.get("Connection","nick").lower():
         message.reply("I am already here, shitface.")
         return
     u = User.load(name=person,access="member")
     if u is not None:
         message.reply("Stupid %s, that wanker %s is already a member."%(user.name,person))
         return
     if self.is_already_proposed_invite(person):
         message.reply("Silly %s, there's already a proposal to invite %s."%(user.name,person))
         return
     if not self.member_count_below_limit():
         message.reply("You have tried to invite somebody, but we have too many losers and I can't be bothered dealing with more than %s of you."%(Config.getint("Alliance", "members"),))
         return
     anc = user.has_ancestor(person)
     if anc is True:
         message.reply("Ew, incest.")
         return
     if anc is None:
         message.reply("Filthy orphans should be castrated.")
         return
     
     prop = Invite(proposer=user, person=person, comment_text=params.group(2))
     session.add(prop)
     session.commit()
     
     reply = "%s created a new proposition (nr. %d) to invite %s." %(user.name, prop.id, person)
     reply+= " When people have been given a fair shot at voting you can call a count using !prop expire %d."%(prop.id,)
     message.reply(reply)
Exemple #27
0
    def execute(self, message, user, params):

        # do stuff here
        if params.group(1).lower() == Config.get("Connection","nick").lower():
            message.reply("I'll peck your eyes out, c**t.")
            return
        idiot = User.load(name=params.group(1), access="member")
        if idiot is None:
            message.reply("That idiot isn't a member!")
            return
        if (not user.is_admin()) and user != idiot and idiot.sponsor != user.name:
            message.reply("You are not %s's sponsor"%(idiot.name,))
            return
        
        if "galmate" in Config.options("Access"):
            idiot.access = Config.getint("Access","galmate")
        else:
            idiot.access = 0
        
        if idiot.planet is not None and idiot.planet.intel is not None:
            intel = idiot.planet.intel
            alliance = Alliance.load(Config.get("Alliance","name"))
            if intel.alliance == alliance:
                intel.alliance = None
        
        session.commit()
        
        message.privmsg("remuser %s %s"%(Config.get("Channels","home"), idiot.name,),Config.get("Services", "nick"))
        message.privmsg("ban %s *!*@%s.%s Your sponsor doesn't like you anymore"%(Config.get("Channels","home"), idiot.name, Config.get("Services", "usermask"),),Config.get("Services", "nick"))
        if idiot.sponsor != user.name:
            message.privmsg("note send %s Some admin has removed you for whatever reason. If you still wish to be a member, go ahead and find someone else to sponsor you back."%(idiot.name,),Config.get("Services", "nick"))
            message.reply("%s has been reduced to \"galmate\" level and removed from the channel. %s is no longer %s's sponsor. If anyone else would like to sponsor that person back, they may."%(idiot.name,idiot.sponsor,idiot.name))
        else:
            message.privmsg("note send %s Your sponsor (%s) no longer wishes to be your sponsor. If you still wish to be a member, go ahead and find someone else to sponsor you back."%(idiot.name,user.name,),Config.get("Services", "nick"))
            message.reply("%s has been reduced to \"galmate\" level and removed from the channel. You are no longer %s's sponsor. If anyone else would like to sponsor that person back, they may."%(idiot.name,idiot.name))
Exemple #28
0
 def list_other(self, message, user, params):
     member = User.load(name=params.group(1), exact=False)
     if member is None:
         message.alert("%s is not a valid user."%(params.group(1),))
         return
     
     message.reply(self.list_reply(member, user==member))
Exemple #29
0
    def execute(self, message, user, params):

        if params.group(1) is not None:
            penis = User.load(name=params.group(1), exact=False)
        else:
            penis = user
        if not self.is_user(penis):
            message.reply("Who the f**k is %s?" % (params.group(1),))
            return

        if penis.planet is None:
            if user == penis:
                message.reply("Set your planet first git.")
            else:
                message.reply(
                    "%s is too embarrassed about his tiny penis that he won't let me tell you how small it is."
                    % (penis.name,)
                )
            return

        if penis.epenis is None:
            if user == penis:
                message.reply("Wait for the tick, bitch.")
            else:
                message.reply("That freak %s doesn't have a penis!" % (penis.name,))
            return

        message.reply(
            "epenis for %s is %s score long. This makes %s rank: %s for epenis in %s!"
            % (penis.name, penis.epenis.penis, penis.name, penis.epenis.rank, Config.get("Alliance", "name"))
        )
Exemple #30
0
 def authenticate(self, request):
     request.session = None
     request.user = None
     key = request.COOKIES.get(SESSION_KEY)
     if key:
         auth = Arthur.load(key, datetime.now())
         if auth is None:
             raise UserError("Your session has expired, please login again.")
         if request.path == LOGOUT:
             session.delete(auth)
             session.commit()
             raise UserError("Logged out.")
         request.session = auth
         return auth.user, None, key
     elif (request.POST.get(USER) and request.POST.get(PASS)):
         user = User.load(name=request.POST.get(USER), passwd=request.POST.get(PASS))
         if user is None:
             raise UserError("Invalid user.")
         else:
             key = self.generate_key(user)
             auth = Arthur(key=key, expire=datetime.now()+timedelta(days=1), user=user)
             session.query(Arthur).filter(Arthur.user == user).delete()
             session.add(auth)
             session.commit()
             request.session = auth
             return user, key, key
     else:
         return None, None, None
Exemple #31
0
 def show(self, message, user, params):
     trustee=params.group(1)
     member = User.load(name=trustee,exact=False)
     if member is None:
         message.alert("%s is not a valid user."%(trustee,))
         return
     
     # Show a phone number
     # Instead of the no-public-Alki message, message.alert() will always return in private
     if user == member:
         if user.phone:
             reply="Your phone number is %s."%(user.phone,)
         else:
             reply="You haven't set your phone number. To set your phone number, do !pref phone=1-800-HOT-BIRD."
         message.alert(reply)
         return
     
     if member.pubphone and user.is_member():
         message.alert("%s says his phone number is %s"%(member.name,member.phone))
         return
     friends = member.phonefriends
     if user not in friends:
         message.reply("%s won't let you see their phone number. That paranoid c**t just doesn't trust you I guess."%(member.name,))
         return
     if member.phone:
         message.alert("%s says his phone number is %s"%(member.name,member.phone))
     else:
         message.reply("%s hasn't shared his phone number. What a paranoid c**t ."%(member.name,))
         return
Exemple #32
0
    def execute(self, message, user, params):
        if params.group(1):
            u = User.load(params.group(1))
            if u:
                message.reply("%s has %s amps." % (u.name, u.planet.intel.amps))
                return
            else:
                if not params.group(1).isdigit():
                    message.reply("No users matching '%s'" % (params.group(1)))
                    return

        Q = session.query(User, Intel)
        Q = Q.join(Intel, User.planet_id == Intel.planet_id)
        if params.group(1):
            Q = Q.filter(Intel.amps >= int(params.group(1)))
        else:
            Q = Q.filter(Intel.amps > 0)
        Q = Q.order_by(desc(Intel.amps))
        Q = Q.limit(10)
        if Q.count() == 0:
            message.reply("No scanners found with at least %s amps." % (params.group(1) if params.group(1) else "1"))
            return
        reply = "Scanners%s:  " % ((" with at least %s amps" % (params.group(1))) if params.group(1) else "")
        for scanner in Q:
            reply += "%s: %s  " % (scanner[0].name, scanner[1].amps)
        message.reply(reply[:-2])
        return
Exemple #33
0
    def execute(self, message, user, params):

        # do stuff here
        if params.group(1).lower() == Config.get("Connection","nick").lower():
            message.reply("I'll peck your eyes out, c**t.")
            return
        idiot = User.load(name=params.group(1), access="member")
        if idiot is None:
            message.reply("That idiot isn't a member!")
            return
        if (not user.is_admin()) and user != idiot and idiot.sponsor != user.name:
            message.reply("You are not %s's sponsor"%(idiot.name,))
            return
        
        if "galmate" in Config.options("Access"):
            idiot.access = Config.getint("Access","galmate")
        else:
            idiot.access = 0
        
        if idiot.planet is not None and idiot.planet.intel is not None:
            intel = idiot.planet.intel
            alliance = Alliance.load(Config.get("Alliance","name"))
            if intel.alliance == alliance:
                intel.alliance = None
        
        session.commit()
        
        message.privmsg("remuser %s %s"%(Config.get("Channels","home"), idiot.name,),'p')
        message.privmsg("ban %s *!*@%s.users.netgamers.org Your sponsor doesn't like you anymore"%(Config.get("Channels","home"), idiot.name,),'p')
        if idiot.sponsor != user.name:
            message.privmsg("note send %s Some admin has removed you for whatever reason. If you still wish to be a member, go ahead and find someone else to sponsor you back."%(idiot.name,),'p')
            message.reply("%s has been reduced to \"galmate\" level and removed from the channel. %s is no longer %s's sponsor. If anyone else would like to sponsor that person back, they may."%(idiot.name,idiot.sponsor,idiot.name))
        else:
            message.privmsg("note send %s Your sponsor (%s) no longer wishes to be your sponsor. If you still wish to be a member, go ahead and find someone else to sponsor you back."%(idiot.name,user.name,),'p')
            message.reply("%s has been reduced to \"galmate\" level and removed from the channel. You are no longer %s's sponsor. If anyone else would like to sponsor that person back, they may."%(idiot.name,idiot.name))
Exemple #34
0
 def authenticate(self, request):
     request.session = None
     request.user = None
     key = request.COOKIES.get(SESSION_KEY)
     if key:
         auth = Arthur.load(key, datetime.now())
         if auth is None:
             raise UserError(
                 "Your session has expired, please login again.")
         if request.path == LOGOUT:
             session.delete(auth)
             session.commit()
             raise UserError("Logged out.")
         request.session = auth
         return auth.user, None, key
     elif (request.REQUEST.get(USER) and request.REQUEST.get(PASS)):
         user = User.load(name=request.REQUEST.get(USER),
                          passwd=request.REQUEST.get(PASS))
         if user is None:
             raise UserError("Invalid user.")
         else:
             key = self.generate_key(user)
             auth = Arthur(key=key,
                           expire=datetime.now() + timedelta(days=1),
                           user=user)
             session.query(Arthur).filter(Arthur.user == user).delete()
             session.add(auth)
             session.commit()
             request.session = auth
             return user, key, key
     else:
         return None, None, None
Exemple #35
0
    def show_prefs(self, message, user, params):

        name = params.group(1)
        u = User.load(name=name, exact=False)
        if u is None:
            message.reply("No members matching %s found" % (name, ))
            return
        else:
            user = u

        reply = ""
        if user.planet is not None:
            reply += " planet=%s:%s:%s" % (
                user.planet.x,
                user.planet.y,
                user.planet.z,
            )
        if user.url:
            reply += " url: %s" % (Config.get("alturls", user.url), )
        if user.email:
            reply += " email=%s" % (user.email, )
        if user.phone:
            reply += " phone=%s pubphone=%s" % (
                user.phone,
                str(user.pubphone)[0],
            )
            if user.smsmode is not None:
                reply += " smsmode=%s" % (user.smsmode, )
        if len(reply) > 0:
            message.reply("Preferences for %s:" % (user.name, ) + reply)
        else:
            message.reply("%s hasn't set any preferences" % (user.name, ))
Exemple #36
0
    def execute(self, message, user, params):
        if params.group(1):
            u = User.load(params.group(1))
            if u:
                message.reply("%s has %s amps." %
                              (u.name, u.planet.intel.amps))
                return
            else:
                if not params.group(1).isdigit():
                    message.reply("No users matching '%s'" % (params.group(1)))
                    return

        Q = session.query(User, Intel)
        Q = Q.join(Intel, User.planet_id == Intel.planet_id)
        if params.group(1):
            Q = Q.filter(Intel.amps >= int(params.group(1)))
        else:
            Q = Q.filter(Intel.amps > 0)
        Q = Q.order_by(desc(Intel.amps))
        Q = Q.limit(10)
        if Q.count() == 0:
            message.reply("No scanners found with at least %s amps." %
                          (params.group(1) if params.group(1) else "1"))
            return
        reply = "Scanners%s:  " % (
            (" with at least %s amps" %
             (params.group(1))) if params.group(1) else "")
        for scanner in Q:
            reply += "%s: %s  " % (scanner[0].name, scanner[1].amps)
        message.reply(reply[:-2])
        return
Exemple #37
0
 def invite(self, message, user, params):
     person = params.group(1)
     if person.lower() == Config.get("Connection","nick").lower():
         message.reply("I am already here, shitface.")
         return
     u = User.load(name=person,access="member")
     if u is not None:
         message.reply("Stupid %s, that wanker %s is already a member."%(user.name,person))
         return
     if self.is_already_proposed_invite(person):
         message.reply("Silly %s, there's already a proposal to invite %s."%(user.name,person))
         return
     if not self.member_count_below_limit():
         message.reply("You have tried to invite somebody, but we have too many losers and I can't be bothered dealing with more than %s of you."%(Config.getint("Alliance", "members"),))
         return
     anc = user.has_ancestor(person)
     if anc is True:
         message.reply("Ew, incest.")
         return
     if anc is None:
         message.reply("Filthy orphans should be castrated.")
         return
     
     prop = Invite(id=self.new_prop_id(), proposer=user, person=person, comment_text=params.group(2))
     session.add(prop)
     session.commit()
     
     reply = "%s created a new proposition (nr. %d) to invite %s." %(user.name, prop.id, person)
     reply+= " When people have been given a fair shot at voting you can call a count using !prop expire %d."%(prop.id,)
     message.reply(reply)
Exemple #38
0
    def execute(self, message, user, params):

        name = params.group(1)
        ships = params.group(2)
        u = User.load(name, exact=False, access="member")
        if u is None:
            message.reply("No members matching %s found" % (name, ))
            return

        if u.fleetcount == 0:
            reply = "%s's fleetcount was already 0, please ensure that they actually had a fleet free to launch." % (
                u.name, )
        else:
            u.fleetcount -= 1
            reply = "Removed a fleet for %s, they now have %s fleets left." % (
                u.name,
                u.fleetcount,
            )

        removed = self.drop_ships(u, user, ships)

        reply += " Used the following ships: "
        reply += ", ".join(
            map(lambda x: "%s %s" % (self.num2short(removed[x]), x),
                removed.keys()))
        message.reply(reply)
Exemple #39
0
    def execute(self, message, cmd, usr, prms):
        if usr is not None:
            spy = User.load(name=usr)
            if spy is None:
                message.reply("No such user '%s'" % (usr, ))
                return

        Q = session.query(Command)
        Q = Q.filter(Command.command.ilike(cmd)) if cmd else Q
        Q = Q.filter(Command.command_parameters.ilike(prms)) if prms else Q
        Q = Q.filter(Command.username == spy.name) if usr else Q
        Q = Q.order_by(desc(Command.id))
        result = Q[:5]

        if len(result) < 1:
            message.reply(
                "No logs matching command '%s' with parameters like '%s'" % (
                    cmd,
                    prms,
                ))
            return

        reply = "\n".join(
            map(
                lambda c: "[ %5s | %s | %-30s | %-15s | %-15s | %s]" % (
                    c.id,
                    c.command,
                    c.command_parameters.strip(),
                    c.nick,
                    c.username,
                    c.command_time.ctime(),
                ), result))
        message.reply(reply)
Exemple #40
0
    def execute(self, message, user, params):
        name = params.group(1)
        u = User.load(name=name, exact=False, access="member")
        if u is None:
            message.reply("No members matching %s found" % (name, ))
            return
        else:
            user = u

        fleetcount = int(params.group(2))
        garbage = params.group(3)
        # assign param variables
        reset_ships = False
        ships = {}
        comment = ""
        if garbage in self.nulls:
            reset_ships = True
        else:
            (ships, comment) = self.parse_garbage(garbage)

        self.reset_ships_and_comment(user, ships, fleetcount, comment,
                                     reset_ships)

        ships = user.fleets.all()

        reply = "Updated %s's def info to: fleetcount %s, updated: pt%s ships: " % (
            user.name, user.fleetcount, user.fleetupdated)
        reply += ", ".join(
            map(
                lambda x: "%s %s" %
                (self.num2short(x.ship_count), x.ship.name), ships))
        reply += " and comment: %s" % (user.fleetcomment)
        message.reply(reply)
Exemple #41
0
    def robocop(self, message, scantype, pa_id, x, y, z, names):
        nicks = []
        reply = "%s on %s:%s:%s " % (
            PA.get(scantype, "name"),
            x,
            y,
            z,
        )
        reply += Config.get("URL", "viewscan") % (pa_id, )

        for name in names.split(","):
            user = User.load(name)
            for nick in CUT.get_user_nicks(name):
                nicks.append(nick)
                message.privmsg(self.url(reply, user), nick)

        reply = "%s on %s:%s:%s " % (
            PA.get(scantype, "name"),
            x,
            y,
            z,
        )
        reply += "delivered to: "
        reply += ", ".join(nicks) if not Config.getboolean(
            "Misc", "anonscans") else "Anon"
        from Hooks.scans.request import request
        message.privmsg(reply, request().scanchan())
Exemple #42
0
    def execute(self, message, user, params):

        username = params.group(1)
        member = User.load(name=username, active=False)
        if member is None:
            message.alert("No such user '%s'" % (username,))
            return
        if member.access > user.access:
            message.reply(
                "You may not remove %s, his or her access (%s) exceeds your own (%s)"
                % (member.name, member.access, user.access)
            )
            return

        mbraxx = Config.getint("Access", "member")
        home = Config.get("Channels", "home")
        coraxx = Config.getint("Access", "core")
        core = Config.get("Channels", "core")

        if member.active and member.access >= mbraxx:
            message.privmsg("remuser %s %s" % (home, member.name), "P")
        if member.active and member.access >= coraxx:
            message.privmsg("remuser %s %s" % (core, member.name), "P")
        session.delete(member)
        session.commit()
        message.reply("Removed user %s" % (member.name,))
        CUT.untrack_user(member.name)
Exemple #43
0
    def list_other(self, message, user, params):
        member = User.load(name=params.group(1), exact=False)
        if member is None:
            message.alert("%s is not a valid user." % (params.group(1), ))
            return

        message.reply(self.list_reply(member, user == member))
Exemple #44
0
    def execute(self, message, user, params):
        name = params.group(1)
        u = User.load(name=name, exact=False, access="member")
        if u is None:
            message.reply("No members matching %s found" % (name,))
            return
        else:
            user = u

        fleetcount = int(params.group(2))
        garbage = params.group(3)
        # assign param variables
        reset_ships = False
        ships = {}
        comment = ""
        if garbage in self.nulls:
            reset_ships = True
        else:
            (ships, comment) = self.parse_garbage(garbage)

        self.reset_ships_and_comment(user, ships, fleetcount, comment, reset_ships)

        ships = user.fleets.all()

        reply = "Updated %s's def info to: fleetcount %s, updated: pt%s ships: " % (
            user.name,
            user.fleetcount,
            user.fleetupdated,
        )
        reply += ", ".join(map(lambda x: "%s %s" % (self.num2short(x.ship_count), x.ship.name), ships))
        reply += " and comment: %s" % (user.fleetcomment)
        message.reply(reply)
Exemple #45
0
 def user(self, message, user, params):
     name = params.group(1)
     u = User.load(name=name, exact=False, access="member")
     if u is None:
         message.reply("No members matching %s found" % (name, ))
     else:
         self.execute(message, u)
Exemple #46
0
    def show_prefs(self, message, user, params):

        name=params.group(1)
        u = User.load(name=name, exact=False)
        if u is None:
            message.reply("No members matching %s found"%(name,))
            return
        else:
            user=u

        reply = ""
        if user.planet is not None:
            reply += " planet=%s:%s:%s" % (user.planet.x,user.planet.y,user.planet.z,)
        if user.url:
            reply += " url: %s" % (Config.get("alturls", user.url),)
        if user.email:
            reply += " email=%s" % (user.email,)
        if user.tguser:
            reply += " tguser=%s" % (user.tguser,)
        if user.phone:
            reply += " phone=%s pubphone=%s" % (user.phone, str(user.pubphone)[0],)
            if user.smsmode is not None:
                reply += " smsmode=%s" % (user.smsmode,)
        if len(reply) > 0:
            message.reply("Preferences for %s:" % (user.name,) + reply)
        else:
            message.reply("%s hasn't set any preferences" % (user.name,))
Exemple #47
0
    def execute(self, message, user, params):

        # do stuff here
        if params.group(1).lower() == Config.get("Connection","nick").lower():
            message.reply("I'll peck your eyes out, c**t.")
            return
        idiot = User.load(name=params.group(1), access="member")
        if idiot is None:
            message.reply("That user isn't a member!")
            return
        if (not user.is_admin()) and user != idiot and idiot.sponsor != user.name:
            message.reply("You do not have sufficent access to demote this member.")
            return
        
        if "galmate" in Config.options("Access"):
            idiot.access = Config.getint("Access","galmate")
        else:
            idiot.access = 0
        
        if idiot.planet is not None and idiot.planet.intel is not None:
            intel = idiot.planet.intel
            alliance = Alliance.load(Config.get("Alliance","name"))
            if intel.alliance == alliance:
                intel.alliance = None
        
        session.commit()
        
        message.privmsg("remuser %s %s"%(Config.get("Channels","home"), idiot.name,),'p')
        message.privmsg("remuser %s %s"%(Config.get("Channels","core"), idiot.name,),'p')
        if idiot.sponsor != user.name:
#            message.privmsg("note send %s You have been removed from private channels."%(idiot.name,),'p')
            message.reply("%s has been reduced to \"galmate\" level and removed from the channel. "%(idiot.name,))
        else:
#            message.privmsg("note send %s You have been removed from private channels."%(idiot.name,),'p')
            message.reply("%s has been reduced to \"galmate\" level and removed from the channel."%(idiot.name,))
Exemple #48
0
    def execute(self, message, user, params):

        pnicks = params.group(1)
        access = params.group(2)
        if not access.isdigit():
            try:
                access = Config.getint("Access", access)
            except Exception:
                message.reply("Invalid access level '%s'" % (access, ))
                return
        else:
            access = int(access)

        if access > user.access:
            message.reply(
                "You may not add a user with higher access to your own")
            return

        added = []
        exists = []
        for pnick in pnicks.split():
            if pnick.lower() == Config.get("Connection", "nick").lower():
                message.reply("I am already here, shitface.")
                continue
            member = User.load(name=pnick, active=False)
            if member is None:
                member = User(name=pnick, access=access, sponsor=user.name)
                session.add(member)
                added.append(pnick)
            elif not member.active:
                member.active = True
                member.access = access
                member.sponsor = user.name
                added.append(pnick)
            elif not member.is_member():
                member.access = access
                member.sponsor = user.name
                added.append(pnick)
            else:
                exists.append(pnick)
        session.commit()
        if len(exists):
            message.reply("Users (%s) already exist" % (",".join(exists), ))
        if len(added):
            message.reply("Added users (%s) at level %s" %
                          (",".join(added), access))
        if len(added) and access >= Config.getint("Access", "member"):
            message.privmsg(
                "adduser %s %s 24" % (
                    Config.get("Channels", "home"),
                    ",".join(added),
                ), Config.get("Services", "nick"))
Exemple #49
0
    def write(self, text, color=False, priority=0):
        # Write something to the server, the message will be split up by newlines and at 450chars max

        # Set Priority
        l = len(text)
        p = 5 + priority
        if l < 100:
            p -= 1
        elif l > 150:
            p += min(l,400) // 100 + l // 450
        ##
        n = False
        try:
            n = self.get_pnick()
        except:
            p += 2
        if n:
            if n in Config.options("Admins"):
                p -= 2
            try:
                u = User.load(n)
                if u:
                    if u.is_admin():
                        p -= 1
                    elif u.is_galmate():
                        p += 1
                else:
                    p +=2
            except:
                p += 2

        # Split message and send
        colon = text.find(":")
        if colon != -1:
            while text[colon-1] != " " and colon != -1:
                colon = text.find(":",colon+1)
            if colon != -1:
                params = text[:colon+1]
                text = text[colon+1:]
        if colon == -1:
            params = text
            text = None
        if text:            
            if color:
                params += "\x03"+Config.get("Connection", "color")
            for line in text.split("\n"):
                line
                while line:
                    i = len(line)
                    while len(line[:i]) > (450 - len(params)):
                        i = line.rfind(" ", 0, i)
                        if i == -1:
                            Connection.write((params + line)[:450])
                            line = line[450 - len(params):]
                            continue
                    Connection.write(params + line[:i], p)
                    line = line[i+1:]
        else:
            Connection.write(params, p)
Exemple #50
0
 def execute(self, message, user, params):
     
     pnicks = params.group(1)
     access = params.group(2)
     if not access.isdigit():
         try:
             access = Config.getint("Access",access)
         except Exception:
             message.reply("Invalid access level '%s'" % (access,))
             return
     else:
         access = int(access)
     
     if access > user.access:
         message.reply("You may not add a user with higher access to your own")
         return
     
     added = []
     exists = []
     for pnick in pnicks.split():
         if pnick.lower() == Config.get("Connection","nick").lower():
             message.reply("I am already here, shitface.")
             continue
         member = User.load(name=pnick, active=False)
         if member is None:
             member = User(name=pnick, access=access, sponsor=user.name)
             session.add(member)
             added.append(pnick)
         elif not member.active:
             member.active = True
             member.access = access
             member.sponsor = user.name
             added.append(pnick)
         elif not member.is_member():
             member.access = access
             member.sponsor = user.name
             added.append(pnick)
         else:
             exists.append(pnick)
     session.commit()
     if len(exists):
         message.reply("Users (%s) already exist" % (",".join(exists),))
     # Bot access    
     if len(added):
         message.reply("Added users (%s) at level %s" % (",".join(added),access))
     # P access with netgamers.org (set up to adduser with access 100 to your Home channel from merlin.cfg)
     if len(added) and access == Config.getint("Access","member"):
         message.privmsg("adduser %s %s 100" %(Config.get("Channels","home"), ",".join(added),), "P")
         message.reply("Added users (%s) to %s with lvl 100 access" % (",".join(added), Config.get("Channels","home")))
     if len(added) and access >= Config.getint("Access","core"):
         message.privmsg("adduser %s %s 150" %(Config.get("Channels","home"), ",".join(added),), "P")
         message.reply("Added users (%s) to %s with lvl 150 access" % (",".join(added), Config.get("Channels","home")))
         message.privmsg("adduser %s %s 150" %(Config.get("Channels","core"), ",".join(added),), "P")
         message.reply("Added users (%s) to %s with lvl 150 access" % (",".join(added), Config.get("Channels","core")))
Exemple #51
0
    def execute(self, message, user, params):
        
        rec = params.group(1)
        public_text = params.group(2) + ' - %s' % (user.name,)
        text = public_text.encode('latin-1') + '/%s' %(user.phone,)
        receiver=User.load(name=rec,exact=False)
        if not receiver:
            message.reply("Who exactly is %s?" % (rec,))
            return

        if not receiver.pubphone and user not in receiver.phonefriends:
            message.reply("%s's phone number is private or they have not chosen to share their number with you. Supersecret message not sent." % (receiver.name,))
            return

        phone = self.prepare_phone_number(receiver.phone)
        if not phone or len(phone) <= 6:
            message.reply("%s has no phone number or their phone number is too short to be valid (under 6 digits). Super secret message not sent." % (receiver.name,))
            return

        if len(text) >= 160:
            message.reply("Max length for a text is 160 characters. Your text was %i characters long. Super secret message not sent." % (len(text),))
            return
        if not receiver.googlevoice:
            get = urlencode({"user": Config.get("clickatell", "user"),
                        "password": Config.get("clickatell", "pass"),
                        "api_id": Config.get("clickatell", "api"),
                        "to": phone,
                        "text": text,
            })
	
            status, msg = urlopen("https://api.clickatell.com/http/sendmsg", get).read().split(":")
	
            if status in ("OK","ID",):
	        message.reply("Successfully processed To: %s Message: %s" % (receiver.name,text))
	        self.log_message(user,receiver,phone, public_text)
            elif status in ("ERR",):
	        message.reply("Error sending message: %s" % (msg.strip(),))
            else:
	        message.reply("That wasn't supposed to happen. I don't really know what wrong. Maybe your mother dropped you.")
            return

	email = Config.get("googlevoice", "email")
        password = Config.get("googlevoice", "pass")
        gvoice = GoogleVoiceLogin(email, password)
        if not gvoice.logged_in:
            message.reply("Could not log in with provided credentials")
            return
        else:
            text_sender = TextSender(gvoice.opener, gvoice.key)
            text_sender.text = text
            number = phone
            text_sender.send_text(phone)
            if text_sender.response:
                message.reply("Sending message to {0} at {1}".format(receiver.name, phone),)
            else:
                message.reply("Failed!!")
Exemple #52
0
def catcher(message):
    try:
        user = User.load(name=message.get_pnick())
        uid = user.id if user else None
    except PNickParseError:
        uid = None
    for m in scanre.finditer(message.get_msg()):
        parse(uid, "scan", m.group(1)).start()
    for m in scangrpre.finditer(message.get_msg()):
        parse(uid, "group", m.group(1)).start()
Exemple #53
0
def catcher(message):
    try:
        user = User.load(name=message.get_pnick())
        uid = user.id if user else None
    except PNickParseError:
        uid = None
    for m in scanre.finditer(message.get_msg()):
        parse(uid, "scan", m.group(1)).start()
    for m in scangrpre.finditer(message.get_msg()):
        parse(uid, "group", m.group(1)).start()
Exemple #54
0
 def execute(self, request, user, username="", dashuser=None):
     dashuser = dashuser or User.load(username or user.name, exact=False)
     if dashuser is None:
         return HttpResponseRedirect(reverse("memberlist"))
     
     gimps = dashuser.gimps
     mums = dashuser.mums
     ships = dashuser.fleets.all()
     phonefriend = user == dashuser or user in dashuser.phonefriends
     
     return render("dashboard.tpl", request, dashuser=dashuser, planet=dashuser.planet, gimps=gimps, mums=mums, ships=ships, phonefriend=phonefriend)
Exemple #55
0
    def execute(self, request, user, username="", dashuser=None):
        dashuser = dashuser or User.load(username or user.name, exact=False)
        if dashuser is None:
            return HttpResponseRedirect(reverse("memberlist"))
        
#        gimps = dashuser.gimps
#        mums = dashuser.mums
        ships = dashuser.fleets.all()
        phonefriend = user == dashuser or user in dashuser.phonefriends
        
        return render("dashboard.tpl", request, dashuser=dashuser, planet=dashuser.planet, ships=ships, phonefriend=phonefriend)
Exemple #56
0
 def execute(self, message, user, params):
     
     username = params.group(1)
     access = params.group(2).lower()
     if access.isdigit():
         access = int(access)
     elif access in self.true:
         access = True
     elif access in self.false:
         access = False
     else:
         try:
             access = Config.getint("Access",access)
         except Exception:
             message.reply("Invalid access level '%s'" % (access,))
             return
     
     member = User.load(name=username, active=False)
     if member is None:
         message.alert("No such user '%s'" % (username,))
         return
     
     if type(access) is int and not member.active:
         message.reply("You should first re-activate user %s" %(member.name,))
         return
     
     if access > user.access or member.access > user.access:
         message.reply("You may not change access higher than your own")
         return
     
     mbraxx = Config.getint("Access","member")
     home = Config.get("Channels","home")
     
     if type(access) == int:
         if member.active == True and member.access < mbraxx and access >= mbraxx:
             message.privmsg("adduser %s %s 399" %(home, member.name,), Config.get("Services", "nick"))
             message.reply("%s has been added to %s"%(member.name, home,))
         if member.active == True and member.access >= mbraxx and access < mbraxx:
             message.privmsg("remuser %s %s"%(home, member.name,), Config.get("Services", "nick"))
             message.privmsg("ban %s *!*@%s.%s GTFO, EAAD"%(home, member.name, Config.get("Services", "usermask"),), Config.get("Services", "nick"))
         member.access = access
     else:
         if member.active != access and access == True and member.access >= mbraxx:
             message.privmsg("adduser %s %s 399" %(home, member.name,), Config.get("Services", "nick"))
             message.reply("%s has been added to %s"%(member.name, home,))
         if member.active != access and access == False and member.access >= mbraxx:
             message.privmsg("remuser %s %s"%(home, member.name,), Config.get("Services", "nick"))
             message.privmsg("ban %s *!*@%s.%s GTFO, EAAD"%(home, member.name, Config.get("Services", "usermask"),), Config.get("Services", "nick"))
         member.active = access
     session.commit()
     message.reply("Editted user %s access: %s" % (member.name, access,))
     if not member.active:
         CUT.untrack_user(member.name)
Exemple #57
0
 def check_access(self, user):
     user = user or User(access=0)
     if not Config.getboolean("Arthur",
                              "public") and not self.is_user(user):
         raise UserError("Hi! Please login below:")
     if getattr(self, "_USER", False) is True:
         if self.is_user(user) is False:
             raise UserError("You need to be logged in to use this feature")
     if user.access >= self.access:
         return user
     else:
         raise UserError("You don't have access to this page")
Exemple #58
0
 def forwardMail(self, uname, header, body):
     if not Config.getboolean("imap", "forwarding"):
         return
     body = "Original Message from %s\n\n" % (header['From']) + body
     user = User.load(uname)
     if user:
         addr = user.email
     else:
         addr = Config.get("imap", "bounce")
         body = "Bad username: %s\n\n" % (uname) + body
     if addr:
         self.send_email(header['Subject'], body, addr)
Exemple #59
0
 def forwardMail(self, uname, header, body):
     if not Config.getboolean("imap", "forwarding"):
         return
     body = "Original Message from %s\n\n" % (header['From']) + body
     user = User.load(uname)
     if user:
         addr = user.email
     else:
         addr = Config.get("imap", "bounce")
         body = "Bad username: %s\n\n" % (uname) + body
     if addr:
         self.send_email(header['Subject'], body, addr)
Exemple #60
0
 def check_access(self, message, access=None, user=None, channel=None):
     try:
         user = loadable.check_access(self, message, access, user, channel)
         if not self.is_user(user):
             raise UserError
         else:
             return user
     except UserError:
         if message.get_pnick() in Config.options("Admins"):
             return User(name=Config.get("Connection", "nick"),
                         access=Config.getint("Access", "admin"))
         else:
             raise