Esempio n. 1
0
def updatenotifier(message):
    """Receive and parse update notifications"""
    m = message.get_msg()
    if m[0] == '@':
        try:
            if message.get_chan() == Config.get("Updates", "notify-channel") and message.get_pnick() in Config.get("Updates", "notify-allow").split():
                params = m[1:].split("/", 3)
                if params[0] in Config.get("Updates", "notify-repo").split():
                    mtags = params[1].split(",")
                    ctags = Config.get("Updates", "notify-branch").split()
                    selected = False
                    if "all" in mtags or "all" in ctags:
                        selected = True
                    else:
                        for tag in mtags:
                            if tag in ctags:
                                selected = True
                                break
                            if tag == "unstable":
                                mtags.extend(["acl", "master"])
                            elif tag == "stable":
                                mtags.extend(["acl-stable", "legacy-stable"])
                    if selected == True:
                        levels = Config.get("Updates", "notify-level").split()
                        if params[2] in levels or ("all" in levels and params[2] != "forks"):
                            nu = Config.get("Updates", "notify-users").split()
                            message.privmsg("UPDATE (%s): %s in %s: %s" % (message.get_pnick(), params[2], "/".join(params[:1]), params[3]), 
                                            ",".join(nu) if nu else Config.options("Admins")[0], priority=+5)
        except (ChanParseError, PNickParseError):
            pass
Esempio n. 2
0
 def execute(self, message, user, params):
     
     if params.group(1) is not None:
         alliance = Alliance.load(params.group(1))
         if alliance is None:
             message.alert("No alliances match %s" % (params.group(1),))
             return
     elif self.is_user(user) and user.is_member():
         alliance = Alliance.load(Config.get("Alliance","name"))
         if alliance is None:
             message.alert("No alliances match %s" % (Config.get("Alliance","name"),))
             return
     else:
         self.get_user_planet(user)
         if user.planet.intel is None or user.planet.alliance is None:
             message.alert("Make sure you've set your planet with !pref and alliance with !intel")
             return
         else:
             alliance = user.planet.alliance
     
     penis = alliance.apenis
     if penis is None:
         message.alert("No apenis stats matching %s" % (alliance.name,))
         return
     
     message.reply("apenis for %s is %s score long. This makes %s rank: %s apenis. The average peon is sporting a %s score epenis." % (
                     alliance.name, penis.penis, alliance.name, penis.rank, int(penis.penis/alliance.members),))
Esempio n. 3
0
    def execute(self, message, user, params):

        get = urlencode(
            {
                "user": Config.get("clickatell", "user"),
                "password": Config.get("clickatell", "pass"),
                "api_id": Config.get("clickatell", "api"),
            }
        )

        try:
            status, msg = urlopen("https://api.clickatell.com/http/getbalance", get).read().split(":")

            if status in ("Credit",):
                balance = float(msg.strip())
                if not balance:
                    message.reply("Help me help you. I need the kwan. SHOW ME THE MONEY")
                else:
                    message.reply("Current kwan balance: %d" % (balance,))
            elif status in ("ERR",):
                raise SMSError(msg.strip())
            else:
                message.reply(
                    "That wasn't supposed to happen. I don't really know what wrong. Maybe your mother dropped you."
                )

        except (URLError, SSLError, SMSError) as e:
            message.reply("Error sending message: %s" % (str(e),))
Esempio n. 4
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))
Esempio n. 5
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))
Esempio n. 6
0
File: sms.py Progetto: berten/merlin
    def send_clickatell(self, user, receiver, public_text, phone, message):
        try:
            # HTTP POST
            post = urlencode({
                "user": Config.get("clickatell", "user"),
                "password": Config.get("clickatell", "pass"),
                "api_id": Config.get("clickatell", "api"),
                "to": phone,
                "text": message,
            })
            # Send the SMS
            status, msg = urlopen("https://api.clickatell.com/http/sendmsg",
                                  post, 5).read().split(":")

            # Check returned status for error messages
            if status in (
                    "OK",
                    "ID",
            ):
                self.log_message(user, receiver, phone, public_text,
                                 "clickatell")
                return None
            elif status in ("ERR", ):
                raise SMSError(msg.strip())
            else:
                return ""

        except (URLError, SSLError, SMSError) as e:
            return "Error sending message: %s" % (str(e), )
Esempio n. 7
0
 def execute(self, message, user, params):
     
     chan = 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
     
     try:
         session.add(Channel(name=chan, userlevel=access, maxlevel=user.access))
         session.commit()
         message.reply("Added chan %s at level %s" % (chan,access,))
         message.privmsg("set %s autoinvite on" %(chan,),Config.get("Services", "nick"));
         message.privmsg("invite %s" %(chan,),Config.get("Services", "nick"));
     except IntegrityError:
         session.rollback()
         message.reply("Channel %s already exists" % (chan,))
Esempio n. 8
0
    def execute(self, message, user, params):

        chan = 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

        try:
            session.add(Channel(name=chan, userlevel=access, maxlevel=user.access))
            session.commit()
            message.reply("Added chan %s at level %s" % (chan, access))
            message.privmsg("set %s autoinvite on" % (chan,), Config.get("Services", "nick"))
            message.privmsg("invite %s" % (chan,), Config.get("Services", "nick"))
        except IntegrityError:
            session.rollback()
            message.reply("Channel %s already exists" % (chan,))
Esempio n. 9
0
        def wrapper(hook):
            prefix = hook.__module__.split(".")[2] if pre else ""
            url = ("/%s/%s/%s/" % (
                prefix,
                hook.name,
                suffix,
            )).replace("//", "/")

            if head not in self.heads:
                self.heads.append(head)
                self.content[head] = {
                    "hook": hook,
                    "url": url,
                    "subs": [],
                    "content": {}
                }
                self.content[head][
                    "link"] = hook.name == "links" and not head == Config.get(
                        "Alliance", "name")
            if sub is not None:
                self.content[head]["subs"].append(sub)
                self.content[head]["content"][sub] = {"hook": hook, "url": url}
                self.content[head]["content"][sub][
                    "link"] = hook.name == "links" and not head == Config.get(
                        "Alliance", "name")

            return hook
Esempio n. 10
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)



        phone = self.prepare_phone_number(rec)
        if not phone or len(phone) <= 7:
            message.reply("No phone number or phone number is too short to be valid (under 6 digits). No call made." % (rec,))
            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." % (rec))
        else:
            message.reply("Error: Failed to get call ID from Twilio server.")
Esempio n. 11
0
 def robocop(self, message, pa_id, group=False):
     if Config.get("Misc", "shareto"):
         if group:
             url = Config.get("URL", "viewgroup") % pa_id
         else:
             url = Config.get("URL", "viewscan") % pa_id
         message.privmsg(url, Config.get("Misc", "shareto"), priority=+10)
Esempio n. 12
0
class parse(Thread):
    useragent = "Merlin (Python-urllib/%s); Alliance/%s; BotNick/%s; Admin/%s" % (
        urllib2.__version__, Config.get("Alliance", "name"),
        Config.get("Connection", "nick"), Config.items("Admins")[0][0])

    def __init__(self, uid, type, id, share=True):
        self.uid = uid
        self.type = type
        self.id = id
        self.share = share
        Thread.__init__(self)

    def run(self):
        scanlog(asctime())
        t_start = time()

        uid = self.uid
        type = self.type
        id = self.id
        try:
            if type == "scan":
                self.scan(uid, id)
            elif type == "group":
                self.group(uid, id)
        except Exception, e:
            scanlog("Exception in scan: %s" % (str(e), ), traceback=True)

        t1 = time() - t_start
        scanlog("Total time taken: %.3f seconds" % (t1, ), spacing=True)
        session.remove()
Esempio n. 13
0
def log(filename, log, traceback=True, spacing=True):
    def _log(file):
        file.write(encode(log) + "\n")
        if traceback is True:
            file.write(format_exc() + "\n")
        if spacing is True:
            file.write("\n\n")
    try:
        file = Config.get("Misc", filename)
        if file == "stdout":
            _log(stdout)
        else:
            with open(file, "a") as file:
                _log(file)
    finally:
        if filename == "excalibur":
            if "d" not in Config.get("Misc", "maillogs"):
                return
        elif filename[0] not in Config.get("Misc", "maillogs"):
            return
        if traceback:
            sep = "\n\n" if spacing else "\n"
            log = sep.join([log, format_exc()])
        for addr in Config.get("Misc", "logmail").split():
            send_email("%s: %s" % (Config.get("Connection", "nick"), filename), log, addr)
Esempio n. 14
0
    def connect(self, nick):
        # Configure socket
        server = Config.get("Connection", "server")
        port = Config.getint("Connection", "port")
        print "%s Connecting... (%s %s)" % (
            time.asctime(),
            server,
            port,
        )

        self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self.sock.settimeout(330)
        self.sock.connect((
            server,
            port,
        ))

        passwd = Config.get("Connection", "servpass")
        if passwd:
            self.write("PASS %s" % (passwd, ))

        self.write("NICK %s" % (nick, ))
        self.write("USER %s 0 * :%s bot. Admin: %s" % (
            nick,
            Config.get("Alliance", "name"),
            Config.items("Admins")[0][0],
        ))
        return self.sock
Esempio n. 15
0
    def robonotify(self, header, body):
        # Check for correct "From" address?
        if Config.getboolean("imap", "singleaddr"):
            uname_re = "%s\+(.+)@.+" % Config.get("imap", "user").split("@")[0].lower()
        else:
            uname_re = "<?(.+)@.+"
        uname = re.findall(uname_re, header['To'].lower())[0]

        dsuff = Config.get("imap", "defsuffix")
        if dsuff:
            if uname[-len(dsuff):] == dsuff:
                uname = uname[:-len(dsuff)]
            else:
                self.forwardMail(uname, header, body)
                return

        # Check for the main notificatino types
        tick = re.findall("events in tick (\d+)", body)[0]
        newfleets = re.findall("We have detected an open jumpgate from (.+), located at (\d{1,2}):(\d{1,2}):(\d{1,2}). ".replace(" ","\s+") +\
                               "The fleet will approach our system in tick (\d+) and appears to have (\d+) visible ships.".replace(" ","\s+"), body)
        recalls = re.findall("The (.+) fleet from (\d{1,2}):(\d{1,2}):(\d{1,2}) has been recalled.".replace(" ","\s+"), body)
        cons = len(re.findall("Our construction team reports that .+ has been finished".replace(" ","\s+"), body))
        res = len(re.findall("Our scientists report that .+ has been finished".replace(" ","\s+"), body))

        # Wrap it up in a bow
        for line in newfleets:
            push("defcall", etype="new", uname=uname, tick=tick, name=line[0], x=line[1], y=line[2], z=line[3], eta=line[4], size=line[5])
        for line in recalls:
            push("defcall", etype="rec", uname=uname, tick=tick, name=line[0], x=line[1], y=line[2], z=line[3])
        if res + cons > 0:
            push("defcall", etype="fin", uname=uname, tick=tick, res=res, cons=cons)

        if len(newfleets) + len(recalls) + cons + res == 0:
            self.forwardMail(uname, header, body)
Esempio n. 16
0
File: remuser.py Progetto: JDD/DLR
    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)
Esempio n. 17
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)
Esempio n. 18
0
File: call.py Progetto: JDD/merlin
    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.")
Esempio n. 19
0
    def execute(self, message, user, params):

        channel = params.group(1)
        chan = Channel.load(channel)
        if chan is None:
            message.reply("Channel '%s' does not exist" % (channel, ))
            if user.is_admin():
                #                message.privmsg("remuser %s %s" %(channel, Config.get('Connection', 'nick')),Config.get("Services", "nick"))
                message.privmsg("set %s autoinvite off" % (channel),
                                Config.get("Services", "nick"))
                message.part(channel)
            return

        if chan.userlevel >= user.access and not user.is_admin():
            message.reply(
                "You may not remove %s, the channel's access (%s) exceeds your own (%s)"
                % (
                    chan.name,
                    chan.userlevel,
                    user.access,
                ))
            return

        session.delete(chan)
        session.commit()

        #        message.privmsg("remuser %s %s" %(chan.name, Config.get('Connection', 'nick')),Config.get("Services", "nick"))
        message.privmsg("set %s autoinvite off" % (channel),
                        Config.get("Services", "nick"))
        message.part(chan.name)
        message.reply("Removed channel %s" % (chan.name, ))
Esempio n. 20
0
 def send_email(self, user, receiver, public_text, email, message):
     try:
         if (Config.get("smtp", "port") == "0"):
             smtp = SMTP("localhost")
         else:
             smtp = SMTP(Config.get("smtp", "host"), Config.get("smtp", "port"))
         
         if not ((Config.get("smtp", "host") == "localhost") or (Config.get("smtp", "host") == "127.0.0.1")): 
             try:
                 smtp.starttls()
             except SMTPException as e:
                 raise SMSError("unable to shift connection into TLS: %s" % (str(e),))
             
             try:
                 smtp.login(Config.get("smtp", "user"), Config.get("smtp", "pass"))
             except SMTPException as e:
                 raise SMSError("unable to authenticate: %s" % (str(e),))
         
         try:
              smtp.sendmail(Config.get("smtp", "frommail"), email, 
                           "To:%s\nFrom:%s\nSubject:%s\n\n%s\n" % (email,
                                                                 Config.get("smtp", "frommail"),
                                                                 Config.get("Alliance", "name"),
                                                                 message,))
         except SMTPSenderRefused as e:
             raise SMSError("sender refused: %s" % (str(e),))
         except SMTPRecipientsRefused as e:
             raise SMSError("unable to send: %s" % (str(e),))
         
         smtp.quit()
         self.log_message(user, receiver, email, public_text, "email")
         
     except (socket.error, SSLError, SMTPException, SMSError) as e:
         return "Error sending message: %s" % (str(e),)
Esempio n. 21
0
def main(url = Config.get("URL", "ships"), debug=False):
    req = urllib2.Request(url)
    req.add_header('User-Agent', useragent)
    stats = urllib2.urlopen(req).read()
    session.execute(Ship.__table__.delete())
    if Config.get("DB", "dbms") == "mysql":
        session.execute(text("ALTER TABLE ships AUTO_INCREMENT=1;", bindparams=[false]))
    else:
        session.execute(text("SELECT setval('ships_id_seq', 1, :false);", bindparams=[false]))
    
    for line in sre.findall(stats):
        ship = Ship()
        line = list(line)
        for index, key in enumerate(keys):
            if line[index] in mapping:
                line[index] = mapping[line[index]]
            elif line[index].isdigit():
                line[index] = int(line[index])
            if line[index] not in ('-', '',):
                setattr(ship,key,line[index])
        ship.total_cost = ship.metal + ship.crystal + ship.eonium
        if debug: print "%12s%12s%12s%12s" % (ship.name, ship.class_, ship.race, ship.type,)
        
        session.add(ship)
    
    session.commit()
    session.close()
Esempio n. 22
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)
Esempio n. 23
0
    def execute(self, message, user, params):

        get = urlencode({
            "user": Config.get("clickatell", "user"),
            "password": Config.get("clickatell", "pass"),
            "api_id": Config.get("clickatell", "api"),
        })

        try:
            status, msg = urlopen("https://api.clickatell.com/http/getbalance",
                                  get).read().split(":")

            if status in ("Credit", ):
                balance = float(msg.strip())
                if not balance:
                    message.reply(
                        "Help me help you. I need the kwan. SHOW ME THE MONEY")
                else:
                    message.reply("Current kwan balance: %d" % (balance, ))
            elif status in ("ERR", ):
                raise SMSError(msg.strip())
            else:
                message.reply(
                    "That wasn't supposed to happen. I don't really know what wrong. Maybe your mother dropped you."
                )

        except (URLError, SSLError, SMSError) as e:
            message.reply("Error sending message: %s" % (str(e), ))
Esempio n. 24
0
 def robocop(self, message, pa_id, group=False):
     if Config.get("Misc", "shareto"):
         if group:
             url = Config.get("URL","viewgroup") % pa_id
         else:
             url = Config.get("URL","viewscan") % pa_id
         message.privmsg(url, Config.get("Misc","shareto"), priority=+10)
Esempio n. 25
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,))
Esempio n. 26
0
def secure(message):
    """Secures the PNick of the bot."""
    message.privmsg("SET MAXLOGINS 2\nSET INVISIBLE ON\nSET AUTOKILL ON",
                    Config.get("Services", "nick"))
    message.reply("Secured the %s nick" % (Config.get("Services", "nick"), ))
    for chan, name in Config.items("Channels"):
        message.privmsg("SET %s AUTOINVITE ON" % (name, ),
                        Config.get("Services", "nick"))
Esempio n. 27
0
    def execute(self, message, user, params):

        links = [
            Config.get("URL", "game"),
            Config.get("URL", "bcalc"),
            Config.get("URL", "arthur"),
        ]

        message.reply(self.url("Links: " + " | ".join(links), user))
Esempio n. 28
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!!")
Esempio n. 29
0
def base_context(request):
    context = {"name": Config.get("Alliance", "name"), "slogan": Config.get("Alliance", "name")}
    if request.session is not None:
        slogan, count = Slogan.search("")
        if slogan is not None:
            context["slogan"] = str(slogan)
        context["user"] = request.session.user
        context["menu"] = menu.generate(request.session.user)
        context["tick"] = Updates.current_tick()
    return context
Esempio n. 30
0
def connected(message):
    # Successfully registered on the IRC server, check what nick
    Merlin.nick = message.get_chan()
    # Hide ourself
    message.write("MODE %s +ix" % Merlin.nick)
    # Kill the ghost
    nick = Config.get("Connection", "nick")
    if Merlin.nick != nick:
        message.privmsg("RECOVER %s %s %s" % (nick, nick, Config.get("Connection", "passwd")), Config.get("Services", "login"))
    login(message)
Esempio n. 31
0
def PNS(message):
    # Message from P or NickServ
    if message.get_hostmask().lower() in (Config.get("Services", "host").lower(),Config.get("Services", "nickserv").lower(),):
        if re.match(r"^(Recover Successful For|Unable to find)", message.get_msg()):
            # Ghosted
            message.nick(Config.get("Connection", "nick"))
            login(message)
        if re.match(r"^Your nickname is registered", message.get_msg()):
            # Login
            login(message)
Esempio n. 32
0
 def execute(self, request, user, link):
     link = {
             "game"        : Config.get("URL","game"),
             "forums"      : "http://pirate.planetarion.com",
             "bcalc"       : Config.get("URL","bcalc"),
             name          : reverse("alliance_members", kwargs={"name":name}),
            }.get(link)
     if link is None:
         return page_not_found(request)
     return HttpResponseRedirect(self.url(link, user))
Esempio n. 33
0
def loggedin(message):
    # Authentication complete
    if "is now your hidden host" == message.get_msg():
        nick = Config.get("Connection", "nick")
        if Merlin.nick != nick:
            message.nick(nick)
        return # This is now deprecated in favour of
               #  setting autoinvite when adding the chan
        for channel in session.query(Channel):
            message.privmsg("INVITE %s" % (channel.name,), Config.get("Services", "nick"))
Esempio n. 34
0
 def execute(self, request, user, link):
     link = {
         "game": Config.get("URL", "game"),
         "forums": "http://pirate.planetarion.com",
         "bcalc": Config.get("URL", "bcalc"),
         name: reverse("alliance_members", kwargs={"name": name}),
     }.get(link)
     if link is None:
         return page_not_found(request)
     return HttpResponseRedirect(self.url(link, user))
Esempio n. 35
0
def send_email(subject, message, addr):
    try:
        if (Config.get("smtp", "port") == "0"):
            smtp = SMTP("localhost")
        else:
            smtp = SMTP(Config.get("smtp", "host"), Config.get("smtp", "port"))

        if not ((Config.get("smtp", "host") == "localhost") or (Config.get("smtp", "host") == "127.0.0.1")):
            try:
                smtp.starttls()
            except SMTPException as e:
                raise SMSError("unable to shift connection into TLS: %s" % (str(e),))

            try:
                smtp.login(Config.get("smtp", "user"), Config.get("smtp", "pass"))
            except SMTPException as e:
                raise SMSError("unable to authenticate: %s" % (str(e),))

        try:
             smtp.sendmail(Config.get("smtp", "frommail"), addr, "To:%s\nFrom:%s\nSubject:%s\n%s\n" % (addr, "\"%s\" <%s>" % (
                                                           Config.get("Connection", "nick"), Config.get("smtp", "frommail")), subject, message))
        except SMTPSenderRefused as e:
            raise SMSError("sender refused: %s" % (str(e),))
        except SMTPRecipientsRefused as e:
            raise SMSError("unable to send: %s" % (str(e),))

        smtp.quit()

    except (socket.error, SSLError, SMTPException, SMSError) as e:
        return "Error sending message: %s" % (str(e),)
Esempio n. 36
0
 def flux_passwd(self, user):
     if not Config.getboolean("FluxBB", "enabled"):
         return -1
     if session.execute("SELECT username FROM %susers WHERE LOWER(username) LIKE '%s';" % (Config.get("FluxBB", "prefix"), user.name.lower())).rowcount > 0:
         return session.execute("UPDATE %susers SET password='******' WHERE LOWER(username) LIKE '%s';" % (Config.get("FluxBB", "prefix"), user.passwd, user.name.lower())).rowcount
     else:
         group = Config.get("FluxBB", "memgroup") if user.is_member() else Config.get("FluxBB", "galgroup")
         if group == 0:
             return -1
         return session.execute("INSERT INTO %susers (group_id, username, password, email, title) VALUES ('%s', '%s', '%s', '%s', '%s');" % (
                                Config.get("FluxBB", "prefix"), group, user.name, user.passwd, user.email, user.level)).rowcount
Esempio n. 37
0
 def flux_passwd(self, user):
     if not Config.getboolean("FluxBB", "enabled"):
         return -1
     if session.execute("SELECT username FROM %susers WHERE LOWER(username) LIKE '%s';" % (Config.get("FluxBB", "prefix"), user.name.lower())).rowcount > 0:
         return session.execute("UPDATE %susers SET password='******' WHERE LOWER(username) LIKE '%s';" % (Config.get("FluxBB", "prefix"), user.passwd, user.name.lower())).rowcount
     else:
         group = Config.get("FluxBB", "memgroup") if user.is_member() else Config.get("FluxBB", "galgroup")
         if group == 0:
             return -1
         return session.execute("INSERT INTO %susers (group_id, username, password, email, title) VALUES ('%s', '%s', '%s', '%s', '%s');" % (
                                Config.get("FluxBB", "prefix"), group, user.name, user.passwd, user.email, user.level)).rowcount
Esempio n. 38
0
 def execute(self, message, user, params):
     
     links = [Config.get("URL","game"),
              Config.get("URL","bcalc"),
              Config.get("URL","arthur"),
              Config.get("URL","ships"),
              "http://progression-uk.com/DLR/forum/index.php (Forums)",
              "http://kia.cthq.net/index.php (CT's sandmans)"
             ]
     
     message.reply(self.url("Links: "+" | ".join(links), user))
Esempio n. 39
0
File: links.py Progetto: JDD/DLR
 def execute(self, message, user, params):
     
     links = [Config.get("URL","arthur"),
              Config.get("URL","PA"),
              "http://progression-uk.com/DLR/forum/index.php",
              "http://sandmans.co.uk",
              "http://game.planetarion.com/bcalc.pl",
              Config.get("URL","ships"),
             ]
     
     message.reply("Links: "+" | ".join(links))
Esempio n. 40
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")))
Esempio n. 41
0
def channel(chan):
    if not chan.find("#") == 0:
        if chan in Config.options("Channels"):
            chan = Config.get("Channels",chan)
        elif chan == "PM":
            chan = Config.get("Connection","nick")
        else:
            raise LoadableError("Invalid channel")
    def wrapper(execute):
        execute._CHANNEL = chan
        return execute
    return wrapper
Esempio n. 42
0
    def new(self, message, user, params):
        tick = Updates.current_tick()
        comment = params.group(4) or ""
        when = int(params.group(1))
        waves = params.group(2) or Config.get("Misc", "attwaves")
        if when < PA.getint("numbers", "protection"):
            when += tick
        elif when <= tick:
            message.alert(
                "Can not create attacks in the past. You wanted tick %s, but current tick is %s."
                % (
                    when,
                    tick,
                ))
            return
        if when > 32767:
            when = 32767

        attack = Attack(landtick=when, comment=comment, waves=int(waves))
        session.add(attack)

        for coord in re.findall(loadable.coord, params.group(3)):
            if not coord[4]:
                galaxy = Galaxy.load(coord[0], coord[2])
                if galaxy:
                    attack.addGalaxy(galaxy)

            else:
                planet = Planet.load(coord[0], coord[2], coord[4])
                if planet:
                    attack.addPlanet(planet)

        session.commit()
        message.reply(str(attack))

        # Request scans
        if Config.has_option("Misc", "attscans"):
            scantypes = Config.get("Misc", "attscans")
        else:
            scantypes = ""

        for stype in scantypes:
            for p in attack.planets:
                scan = p.scan(stype)
                if scan and (int(tick) == scan.tick):
                    return
                else:
                    req = Request(target=p, scantype=stype, dists=0)
                    user.requests.append(req)
                    session.commit()
                    push("request", request_id=req.id, mode="request")
        if scantypes:
            message.reply("Scans requested: %s" % (scantypes))
Esempio n. 43
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"))
Esempio n. 44
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()
        if Config.has_option("Channels", "share"):
            message.privmsg(m.group(0), Config.get("Channels", "share"))
    for m in scangrpre.finditer(message.get_msg()):
        parse(uid, "group", m.group(1)).start()
        if Config.has_option("Channels", "share"):
            message.privmsg(m.group(0), Config.get("Channels", "share"))
Esempio n. 45
0
def channel(chan):
    if not chan.find("#") == 0:
        if chan in Config.options("Channels"):
            chan = Config.get("Channels", chan)
        elif chan == "PM":
            chan = Config.get("Connection", "nick")
        else:
            raise LoadableError("Invalid channel")

    def wrapper(execute):
        execute._CHANNEL = chan
        return execute

    return wrapper
Esempio n. 46
0
def base_context(request):
    context = {"name"   : Config.get("Alliance", "name"),
               "slogan" : Config.get("Alliance", "name"),
               "tick"   : Updates.current_tick(),
               "update" : Updates.load(),
               }
    if getattr(request, "user", None) is not None:
        context["user"] = request.user
        context["menu"] = menu.generate(request.user)
    if getattr(request, "session", None) is not None:
        slogan, count = Slogan.search("")
        if slogan is not None:
            context["slogan"] = str(slogan)
    return context
Esempio n. 47
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.")
Esempio n. 48
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())
Esempio n. 49
0
File: attack.py Progetto: JDD/merlin
    def new(self, message, user, params):
        tick = Updates.current_tick()
        comment = params.group(4) or ""
        when = int(params.group(1))
        waves = params.group(2) or Config.get("Misc", "attwaves")
        if when < PA.getint("numbers", "protection"):
            when += tick
        elif when <= tick:
            message.alert("Can not create attacks in the past. You wanted tick %s, but current tick is %s." % (when, tick,))
            return
        if when > 32767:
            when = 32767
        
        attack = Attack(landtick=when,comment=comment,waves=int(waves))
        session.add(attack)
        
        for coord in re.findall(loadable.coord, params.group(3)):
            if not coord[4]:
                galaxy = Galaxy.load(coord[0],coord[2])
                if galaxy:
                    attack.addGalaxy(galaxy)
            
            else:
                planet = Planet.load(coord[0],coord[2],coord[4])
                if planet:
                    attack.addPlanet(planet)
        
        session.commit()
        message.reply(str(attack))

        # Request scans
        if Config.has_option("Misc", "attscans"):
            scantypes = Config.get("Misc", "attscans")
        else:
            scantypes = ""

        for stype in scantypes:
           for p in attack.planets:
               scan = p.scan(stype)
               if scan and (int(tick) == scan.tick):
                   return
               else:
                   req = Request(target=p, scantype=stype, dists=0)
                   user.requests.append(req)
                   session.commit()
                   push("request", request_id=req.id, mode="request")
        if scantypes:
            message.reply("Scans requested: %s" % (scantypes))
Esempio n. 50
0
 def show_prefs(self, message, user, params):
     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"
         )
Esempio n. 51
0
 def is_user(self, user):
     if loadable.is_user(self, user):
         return True
     elif isinstance(user, User) and user.name == Config.get("Connection", "nick") and user.access == Config.getint("Access", "admin"):
         return True
     else:
         return False
Esempio n. 52
0
 def get_pnick(self):
     #Return the pnick. Raises ParseError on failure
     match = pnickre.match(self.line.split()[0])
     if not match:  # Raise a ParseError: User hasn't authed with P
         raise PNickParseError("Could not parse %s nick." %
                               (Config.get("Services", "nick"), ))
     return match.group(1)
Esempio n. 53
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,))