Exemple #1
0
 def execute(self, page, uid, pa_id, gid=None):
     scanlog("Scan: %s (group: %s)" %(pa_id,gid,))
     page = decode(page)
     
     m = re.search('>([^>]+) on (\d+)\:(\d+)\:(\d+) in tick (\d+)', page)
     if not m:
         scanlog("Expired/non-matchinng scan (id: %s)" %(pa_id,))
         return
     
     scantype = m.group(1)[0].upper()
     x = int(m.group(2))
     y = int(m.group(3))
     z = int(m.group(4))
     tick = int(m.group(5))
     
     planet = Planet.load(x,y,z)
     if planet is None:
         return
     try:
         scan = Scan(pa_id=pa_id, scantype=scantype, tick=tick, group_id=gid, scanner_id=uid)
         planet.scans.append(scan)
         session.commit()
         scan_id = scan.id
     except IntegrityError, e:
         session.rollback()
         scanlog("Scan %s may already exist: %s" %(pa_id,str(e),))
         return
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 scan(self, uid, pa_id, gid=None):
     page = urlopen(Config.get("URL","viewscan")%(pa_id,)).read()
     page = decode(page)
     
     m = re.search('>([^>]+) on (\d+)\:(\d+)\:(\d+) in tick (\d+)', page)
     if not m:
         print "Expired/non-matchinng scan (id: %s)" %(pa_id,)
         return
     
     scantype = m.group(1)[0].upper()
     x = int(m.group(2))
     y = int(m.group(3))
     z = int(m.group(4))
     tick = int(m.group(5))
     
     planet = Planet.load(x,y,z)
     if planet is None:
         return
     try:
         scan = Scan(pa_id=pa_id, scantype=scantype, tick=tick, group_id=gid, scanner_id=uid)
         planet.scans.append(scan)
         session.commit()
         scan_id = scan.id
     except IntegrityError, e:
         session.rollback()
         print "Scan %s may already exist" %(pa_id,)
         print e.__str__()
         return
Exemple #4
0
    def execute(self, page, uid, pa_id, gid=None):
        scanlog("Scan: %s (group: %s)" %(pa_id,gid,))
        page = decode(page)
        
        m = re.search('>([^>]+) on (\d+)\:(\d+)\:(\d+) in tick (\d+)', page)
        if not m:
            scanlog("Expired/non-matchinng scan (id: %s)" %(pa_id,))
            return
        
        scantype = m.group(1)[0].upper()
        x = int(m.group(2))
        y = int(m.group(3))
        z = int(m.group(4))
        tick = int(m.group(5))

        m = re.search("<p class=\"right scan_time\">Scan time: ([^<]*)</p>", page)
        scantime = m.group(1)
        
        planet = Planet.load(x,y,z,)

        try:
            Q = session.query(Scan).filter(Scan.pa_id == pa_id).filter(Scan.planet_id == None)
            if Q.count() > 0:
                scan = Q.first()
            else:
                scan = Scan(pa_id=pa_id, scantype=scantype, tick=tick, time=scantime, group_id=gid, scanner_id=uid)
                session.add(scan)
            if planet:
                planet.scans.append(scan)
            session.commit()
            scan_id = scan.id
        except IntegrityError, e:
            session.rollback()
            scanlog("Scan %s may already exist: %s" %(pa_id,str(e),))
            return
Exemple #5
0
    def execute(self, page, uid, pa_id, gid=None):
        scanlog("Scan: %s (group: %s)" % (
            pa_id,
            gid,
        ))
        page = decode(page)

        m = re.search('>([^>]+) on (\d+)\:(\d+)\:(\d+) in tick (\d+)', page)
        if not m:
            scanlog("Expired/non-matchinng scan (id: %s)" % (pa_id, ))
            return

        scantype = m.group(1)[0].upper()
        x = int(m.group(2))
        y = int(m.group(3))
        z = int(m.group(4))
        tick = int(m.group(5))

        m = re.search("<p class=\"right scan_time\">Scan time: ([^<]*)</p>",
                      page)
        scantime = m.group(1)

        planet = Planet.load(
            x,
            y,
            z,
        )

        try:
            Q = session.query(Scan).filter(Scan.pa_id == pa_id).filter(
                Scan.planet_id == None)
            if Q.count() > 0:
                scan = Q.first()
            else:
                scan = Scan(pa_id=pa_id,
                            scantype=scantype,
                            tick=tick,
                            time=scantime,
                            group_id=gid,
                            scanner_id=uid)
                session.add(scan)
            if planet:
                planet.scans.append(scan)
            session.commit()
            scan_id = scan.id
        except IntegrityError, e:
            session.rollback()
            scanlog("Scan %s may already exist: %s" % (
                pa_id,
                str(e),
            ))
            return
Exemple #6
0
 def read(self):
     # Read from socket
     line = decode(self.file.readline())
     if line:
         if line[-2:] == CRLF:
             line = line[:-2]
         if line[-1] in CRLF:
             line = line[:-1]
         pinging = self.ping.match(line)
         if pinging:
             self.write("PONG :%s" % pinging.group(1))
             # print "%s <<< PING? PONG!" % (time.asctime(),)
         else:
             print "%s <<< %s" % (time.asctime(), line)
         return line
     else:
         raise Reboot
Exemple #7
0
 def read(self):
     # Read from socket
     try:
         line = decode(self.file.readline())
     except socket.error as exc:
         raise Reboot(exc)
     if line:
         if line[-2:] == CRLF:
             line = line[:-2]
         if line[-1] in CRLF:
             line = line[:-1]
         pinging = self.ping.match(line)
         if pinging:
             self.write("PONG :%s" % pinging.group(1), 0)
             #print "%s << PING? PONG!" % (time.strftime("%Y%m%d %H:%M:%S |"),)
         else:
             print "%s << %s" % (time.strftime("%Y%m%d %H:%M:%S |"),encode(line),)
         return line
     else:
         raise Reboot
Exemple #8
0
 def read(self):
     # Read from socket
     try:
         line = decode(self.file.readline())
     except socket.error as exc:
         raise Reboot(exc)
     if line:
         if line[-2:] == CRLF:
             line = line[:-2]
         if line[-1] in CRLF:
             line = line[:-1]
         pinging = self.ping.match(line)
         if pinging:
             self.write("PONG :%s" % pinging.group(1))
             #print "%s <<< PING? PONG!" % (time.asctime(),)
         else:
             print "%s <<< %s" % (
                 time.asctime(),
                 encode(line),
             )
         return line
     else:
         raise Reboot
Exemple #9
0
    def execute(self, page, uid, pa_id, gid=None):
        scanlog("Scan: %s (group: %s)" % (
            pa_id,
            gid,
        ))
        page = decode(page)

        m = re.search('>([^>]+) on (\d+)\:(\d+)\:(\d+) in tick (\d+)', page)
        if not m:
            scanlog("Expired/non-matchinng scan (id: %s)" % (pa_id, ))
            return

        scantype = m.group(1)[0].upper()
        x = int(m.group(2))
        y = int(m.group(3))
        z = int(m.group(4))
        tick = int(m.group(5))

        planet = Planet.load(x, y, z)
        if planet is None:
            return
        try:
            scan = Scan(pa_id=pa_id,
                        scantype=scantype,
                        tick=tick,
                        group_id=gid,
                        scanner_id=uid)
            planet.scans.append(scan)
            session.commit()
            scan_id = scan.id
        except IntegrityError, e:
            session.rollback()
            scanlog("Scan %s may already exist: %s" % (
                pa_id,
                str(e),
            ))
            return
Exemple #10
0
Fichier : sms.py Projet : JDD/DLR
    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)
        if not receiver:
            message.reply("Who exactly is %s?" % (rec,))
            return
        if receiver.name.lower() == 'zeb':
            message.reply("FOR EMERGENCY ONLY!!!! Zeb only has a land line so only rings will work. Use !phone show Zeb to get his phone number.")
            return
        if receiver.name.lower() == 'cormik':
            message.reply("Cormik has no mobile, but usually responds to emails. Use !whois Cormik to get his email address.")
            return
        if receiver.name.lower() == 'richards':
            message.reply("SMS does not work, richards is Deaf(no really, he can't hear).")
            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":
            message.reply("Emailing not yet implemented")
            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). 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 = Config.get("Misc", "sms")
        mode = receiver.smsmode or mode if mode == "combined" else mode
        mode = mode.lower()
        error = ""
        
        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.")
Exemple #11
0
            print "Pre-shuffle dumps detected, emptying out the data"
            planets.readlines()
            galaxies.readlines()
            alliances.readlines()

        # Insert the data to the temporary tables, some DBMS do not support
        #  multiple row insert in the same statement so we have to do it one at
        #  a time which is a bit slow unfortunatly
        # Previously got around this with:
        #  INSERT INTO .. row UNION row UNION row...
        #  Some DBMS complained the resultant query was too long for the planet
        #  dumps, so back at one row per statement
        planet_insert = "INSERT INTO planet_temp (x, y, z, planetname, rulername, race, size, score, value, xp) "
        planet_insert+= "VALUES (%s, %s, %s, '%s', '%s', '%s', %s, %s, %s, %s);"
        for line in planets:
            p=decode(line).strip().split("\t")
            session.execute(text(planet_insert % (p[0], p[1], p[2], p[3].strip("\""), p[4].strip("\""), p[5], p[6], p[7], p[8], p[9],)))

        # As above
        galaxy_insert = "INSERT INTO galaxy_temp (x, y, name, size, score, value, xp) "
        galaxy_insert+= "VALUES (%s, %s, '%s', %s, %s, %s, %s);"
        for line in galaxies:
            g=decode(line).strip().split("\t")
            session.execute(text(galaxy_insert % (g[0], g[1], g[2].strip("\""), g[3], g[4], g[5], g[6],)))

        # As above
        alliance_insert = "INSERT INTO alliance_temp (score_rank, name, size, members, score, points, size_avg, score_avg) "
        alliance_insert+= "VALUES (%s, '%s', %s, %s, %s, %s, %s, %s);"
        for line in alliances:
            a=decode(line).strip().split("\t")
            session.execute(text(alliance_insert % (a[0], a[1].strip("\""), a[2], a[3], a[4], a[5], int(a[2])/int(a[3]), int(a[4])/min(PA.getint("numbers", "tag_count"),int(a[3])),)))
Exemple #12
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 #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 or receiver.smsmode == "Email"
                ) and user not in receiver.phonefriends and user.access < (
                    Config.getint("Access", "SMSer")
                    if "SMSer" in Config.options("Access") else 1000):
            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 = "email"
            phone = receiver.email
            if not phone:
                message.reply(
                    "That incompetent retard %s has set their sms mode to email but hasn't provided an address. Super secret message not sent."
                    % (receiver.name, ))
                return
        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 (receiver.smsmode == "WhatsApp"):
                if Config.get("WhatsApp", "login"):
                    mode = "whatsapp"
            elif (receiver.smsmode == "Twilio"):
                if Config.get("Twilio", "sid"):
                    mode = "twilio"
            else:
                mode = receiver.smsmode or mode if mode == "combined" else mode
                mode = mode.lower()
        error = ""

        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 mode == "email":
            error = self.send_email(user, receiver, public_text, phone, text)
        elif mode == "whatsapp":
            if receiver.phone[0] == "g":
                phone = receiver.phone
            wa = WhatsappEchoClient(phone[1:], text, True)
            wa.login(
                Config.get("WhatsApp", "login"),
                Config.get("WhatsApp", "password").decode("string_escape"))
            if wa.gotReceipt:
                error = None
                self.log_message(user, receiver, phone, public_text,
                                 "whatsapp")
            else:
                error = "No receipt received from the WhatsApp server."
        elif mode == "twilio":
            client = Client(Config.get("Twilio", "sid"),
                            Config.get("Twilio", "auth_token"))
            tw = client.messages.create(body=text,
                                        to=phone,
                                        from_=Config.get("Twilio", "number"))
            if tw.sid:
                error = None
                self.log_message(user, receiver, phone, public_text, "twilio")
            else:
                error = "Failed to get message ID from Twilio server."
        else:
            if mode == "googlevoice" or mode == "combined":
                if Config.get("googlevoice", "user"):
                    error = self.send_googlevoice(user, receiver, public_text,
                                                  phone, text)
                else:
                    error = "smsmode set to Google Voice but no Google Voice account is available."
            if mode == "clickatell" or (mode == "combined"
                                        and error is not None):
                if Config.get("clickatell", "user"):
                    error = self.send_clickatell(user, receiver, public_text,
                                                 phone, text)
                else:
                    if mode == "combined":
                        error = "smsmode set to combined but no SMS account is available."
                    else:
                        error = "smsmode set to Clickatell but no Clickatell account is available."

        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 #14
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 or receiver.smsmode =="Email") and user not in receiver.phonefriends and user.access < (Config.getint("Access","SMSer") if "SMSer" in Config.options("Access") else 1000):
            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 = "email"
            phone = receiver.email
            if not phone:
                message.reply("That incompetent retard %s has set their sms mode to email but hasn't provided an address. Super secret message not sent." % (receiver.name,))
                return
        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 (receiver.smsmode == "WhatsApp"):
                if Config.get("WhatsApp", "login"):
                    mode = "whatsapp"
            else:
                mode = receiver.smsmode or mode if mode == "combined" else mode
                mode = mode.lower()
        error = ""
        
        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 mode == "email":
            error = self.send_email(user, receiver, public_text, phone, text)
        elif mode == "whatsapp":
            wa = WhatsappEchoClient(phone[1:], text, True)
            wa.login(Config.get("WhatsApp", "login"), Config.get("WhatsApp", "password").decode("string_escape"))
            if wa.gotReceipt:
                error = None
            else:
                error = "No receipt received from the WhatsApp server."
        else:
            if mode == "googlevoice" or mode == "combined":
                error = self.send_googlevoice(user, receiver, public_text, phone, text)
            if mode == "clickatell" or (mode == "combined" and error is not None):
                error = self.send_clickatell(user, receiver, public_text, phone, text)
        
        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 #15
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
            if not phone:
                message.reply(
                    "That incompetent retard %s has set their sms mode to email but hasn't provided an address. Super secret message not sent."
                    % (receiver.name, ))
                return
        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)
        if mode == "googlevoice" or mode == "combined":
            error = self.send_googlevoice(user, receiver, public_text, phone,
                                          text)
        if mode == "clickatell" or (mode == "combined" and error is not None):
            error = self.send_clickatell(user, receiver, public_text, phone,
                                         text)

        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 #16
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.")
Exemple #17
0
    def execute(self, message, user, params):
        
        rec = params.group(1)
        public_text = params.group(2) + ' - %s' % (user.name,)
	print params.group(3);
        text = encode(public_text + '/%s' %(user.phone,))
        receiver=User.load(name=rec,exact=False,access="member") or User.load(name=rec)

	if (params.group(3) is not None):
		method = params.group(3).strip().split("=");
		if (method[1] == "w"):
			receiver.smsmode = "Whatsapp";
		if (method[1] == "t"):
			receiver.smsmode = "Twillio";
		if (method[1] == "c"):
			receiver.smsmode = "Clickatell"
        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 receiver.smsmode =="Email") and user not in receiver.phonefriends and user.access < (Config.getint("Access","SMSer") if "SMSer" in Config.options("Access") else 1000):
            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 = "email"
            phone = receiver.email
            if not phone:
                message.reply("That incompetent retard %s has set their sms mode to email but hasn't provided an address. Super secret message not sent." % (receiver.name,))
                return
        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 (receiver.smsmode == "WhatsApp"):
                if Config.get("WhatsApp", "login"):
                    mode = "whatsapp"
            elif (receiver.smsmode == "Twilio"):
                if Config.get("Twilio", "sid"):
                    mode = "twilio"
            else:
                mode = receiver.smsmode or mode if mode == "combined" else mode
                mode = mode.lower()
        error = ""
        
        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 mode == "email":
            error = self.send_email(user, receiver, public_text, phone, text)
        elif mode == "whatsapp":
		message.reply("SMS via WhatsApp has been disabled as WA fricking blocked us - re-routing to clickatell...");
           	mode = "clickatell"
            	receiver.smsmode = "clickatell"
		error = self.send_clickatell(user, receiver, public_text, phone, text)		
	elif mode == "twilio":
            client = TwilioRestClient(Config.get("Twilio", "sid"), Config.get("Twilio", "auth_token"))
            tw = client.sms.messages.create(body=text, to=phone, from_=Config.get("Twilio", "number"))
            if tw.sid:
                error = None
                self.log_message(user, receiver, phone, public_text, "twilio")
            else:
                error = "Failed to get message ID from Twilio server."

        else:
            if mode == "googlevoice" or mode == "combined":
                if Config.get("googlevoice", "user"):
                    error = self.send_googlevoice(user, receiver, public_text, phone, text)
                else:
                    error = "smsmode set to Google Voice but no Google Voice account is available."
            if mode == "clickatell" or (mode == "combined" and error is not None):
                if Config.get("clickatell", "user"):
                    error = self.send_clickatell(user, receiver, public_text, phone, text)
                else:
                    if mode == "combined":
                        error = "smsmode set to combined but no SMS account is available."
                    else:
                        error = "smsmode set to Clickatell but no Clickatell account is available."
        
        if error is None:
            message.reply("Successfully processed To: %s Message: %s Method: %s" % (receiver.name, decode(text),receiver.smsmode))
        else:
            message.reply(error or "That wasn't supposed to happen. I don't really know what went wrong. Maybe your mother dropped you.")