Пример #1
0
    def about(self, message=None, match=None, to='abc'):
        def run():
            query = ""
            url = "http://jarbot.top/bot/show.php?view=true"
            data = requests.get(url)
            data = data.text
            url1 = "http://jarbot.top/bot/show.php?total=true"
            data1 = requests.get(url1)
            total = int(data1.text)

            cur = json.loads(data)
            query += "[The BigArt Group Serving Help For You]\n\n"
            for loop in range(total):
                query += str(cur['list'][loop]['id'])
                query += " Name = " + str(cur['list'][loop]['name'])
                query += "\nNumber = +" + str(cur['list'][loop]['num'])
                query += "\nSkill = " + str(cur['list'][loop]['skill'])
                query += "\nLocation = " + str(cur['list'][loop]['location'])
                query += "\n\n"
            query += "Hi i am a BigArt Bot and you are going to add in the list."
            return (query)

        try:
            txt = run()
        except (RuntimeError, TypeError, NameError, ValueError):
            print("Error : Try Again")
            txt = run()
        if to == 'abc':
            self.interface_layer.toLower(
                TextMessageProtocolEntity(txt,
                                          to='*****@*****.**'))
        else:
            return TextMessageProtocolEntity(txt, to=message.getFrom())
Пример #2
0
 def even_or_odd(self, message=None, match=None, to=None):
     is_odd = len(match.group("evenOrOdd")) % 2
     num = random.randint(1, 10)
     if (is_odd and num % 2) or (not is_odd and not num % 2):
         return TextMessageProtocolEntity("[%d]\nYou win." % num, to=message.getFrom())
     else:
         return TextMessageProtocolEntity("[%d]\nYou lose!" % num, to=message.getFrom())
Пример #3
0
    def onTextMessage(self, messageProtocolEntity):
        text = messageProtocolEntity.getBody()
        try:
            dni, date, cp = self._check_input_data(text)
        except ValueError as e:
            response = str(e)
            if response == DEFAULT_ERR:
                logger.info('Error: No hi ha 3 dades')
            else:
                logger.info('Error: %s', response)
        else:
            result = calculate(dni, date, cp)
            if result:
                response = ('{}\n{}\n{}\n\n'
                            'Districte: {}\n'
                            'Secció: {}\n'
                            'Mesa: {}').format(*result)
                logger.info('Punt de votacio retornat correctament. %s %s',
                            date[:4], cp)
            else:
                response = ('Alguna de les dades entrades no és correcta.\n'
                            'Revisa-les, si us plau.')
                logger.info('Bon format pero dades incorrectes')

        logger.info('---')

        self.toLower(
            TextMessageProtocolEntity(response,
                                      to=messageProtocolEntity.getFrom()))

        # SPECIAL: DISCLAIMER
        if response == DEFAULT_ERR:
            self.toLower(
                TextMessageProtocolEntity(DATA_DISCLAIMER,
                                          to=messageProtocolEntity.getFrom()))
Пример #4
0
    def job(self, message=None, match=None, to=None):
        def search(name):
            job = ""
            if "skill" in name:
                match = re.search('skill (?P<name>.*) (?P<number>.*)', name)
            elif "city" in name:
                match = re.search('city (?P<name>.*) (?P<number>.*)', name)
            c = match.group('name')
            num = int(match.group('number'))
            if "skill" in name:
                url = "http://www.naukri.com/" + c + "-jobs"
            elif "city" in name:
                url = "https://www.naukri.com/jobs-in-" + c
            data = requests.get(url)
            data = data.text
            soup = BeautifulSoup((data), "lxml")
            content = mydivs = soup.findAll("a", {"class": "content"})
            job += "*Total Results : " + str(len(content)) + "*\n\n"
            for search in range(num):
                site = content[search]
                take = site.text[1:].split(",")
                for one in take:
                    job += one + "\n"
                job += "===============================\n"
            return job

        job = match.group("name1")
        try:
            result = search(job)
        except:
            result = search(job)
        return TextMessageProtocolEntity(result, to=message.getFrom())
Пример #5
0
    def balance(self, message=None, match=None, to=None):
        addr = match.group("address")
        if addr == "arnab":
            addr = "1NcFCtRTGtkhFiGTk7en8yWJK8wjtBuWad"
        elif addr == "arnab_2":
            addr = "1GuXnf7XyMnmE1vSFoPDQ7oJbehW4G3KgZ"
        elif addr == "alpesh":
            addr = "13Q3jM8fwznuV5WGCRJSwTGFzdjVYE8NnN"
        btc = {'txd': '', 'recived': '', 'final': ''}
        total_btc = {'txd': '', 'recived': '', 'final': ''}
        url = "https://blockchain.info/address/" + addr
        data = requests.get(url)
        data = data.text
        soup = BeautifulSoup((data), "lxml")

        btc['txd'] = soup.find("td", {"id": "n_transactions"})
        btc['recived'] = soup.find("td", {"id": "total_received"})
        btc['final'] = soup.find("td", {"id": "final_balance"})
        total_btc['txd'] = btc['txd'].get_text()
        total_btc['recived'] = btc['recived'].get_text()
        total_btc['final'] = btc['final'].get_text()

        url1 = 'blockchain.info/q/addressbalance/' + addr + '?confirmations=0'
        r = requests.get("https://" + url1)
        data1 = r.text
        soup1 = BeautifulSoup(data1, "lxml")
        soup1 = soup1.p.get_text()
        return TextMessageProtocolEntity(
            "[" + addr + "]\n\nYou have " + str(float(soup1) * 0.00000001) +
            " BTC.\n\nNo. Transactions : " + total_btc['txd'] +
            "\nTotal Received : " + total_btc['recived'] +
            "\nFinal Balance : " + total_btc['final'],
            to=message.getFrom())
Пример #6
0
    def onTextMessage(self, messageProtocolEntity):
        text = messageProtocolEntity.getBody()
        try:
            dni, date, cp = self._check_input_data(text)
        except ValueError as e:
            response = str(e)
            if response == DEFAULT_ERR:
                print('Error: No hi ha 3 dades')
            else:
                print('Error: {}'.format(response))
        else:
            result = calculate(dni, date, cp)
            if result:
                response = ('{}\n{}\n{}\n\n'
                            'Districte: {}\n'
                            'Secció: {}\n'
                            'Mesa: {}').format(*result)
                print('Punt de votació retornat correctament')
            else:
                response = ('Alguna de les dades entrades no és correcta.\n'
                            'Revisa-les, si us plau.')
                print('Bon format pero dades incorrectes')

        self.toLower(
            TextMessageProtocolEntity(response,
                                      to=messageProtocolEntity.getFrom()))
Пример #7
0
 def getexchange(self, message=None, match=None, to=None):
     amount = match.group("amount")
     price = BtcConverter()
     return TextMessageProtocolEntity(
         amount + " INR = " +
         str(price.convert_to_btc(int(amount), 'BTC')) + " INR",
         to=message.getFrom())
Пример #8
0
 def gira(self, message=None, match=None, to=None):
     to = to or message.getFrom()
     self.audio_sender.send_by_path(to,
                                    self.resource_path + "audio/piao.mp3")
     return TextMessageProtocolEntity("Giraaandooo... [%d]" %
                                      random.randint(1, 6),
                                      to=to)
Пример #9
0
    def send_message(self, text, phone, sms):
        """Метод отправки сообщений
           принимает текст для отправки
           номер телефона
           и объект смс(опционально) - TextMessageProtocolEntity
        """
        with self.locker:
            self.toLower(sms.ack())  # sms delivered (vv)
            self.toLower(AvailablePresenceProtocolEntity())
            self.toLower(
                OutgoingChatstateProtocolEntity(
                    OutgoingChatstateProtocolEntity.STATE_TYPING,
                    Jid.normalize(sms.getFrom(False))))  # typing...
        time.sleep(3)
        with self.locker:
            self.toLower(
                OutgoingChatstateProtocolEntity(
                    OutgoingChatstateProtocolEntity.STATE_PAUSED,
                    Jid.normalize(sms.getFrom(False))))  # typing OFF
            self.toLower(sms.ack(True))  # sms is read(blue vv)

            if phone.isdigit():
                phone += '@s.whatsapp.net'

            data = TextMessageProtocolEntity(text, to=phone)
            try:
                self.toLower(data)
                logging.info('User_ID={} received message - {}'.format(
                    phone, text))
            except Exception as err:
                logging.exception(
                    'ERROR in send_message User_ID={} : {}'.format(phone, err))
Пример #10
0
 def onSuccess(self, layerEvent):
     """При успешном коннекте можно выполнять любые действия
        Я решил отправлять себе сообщение, чтобы понимать, сколько раз он презапускается
     """
     admin = '*****@*****.**'
     data = TextMessageProtocolEntity('Я родился', to=admin)
     self.toLower(data)
Пример #11
0
    def setpro(self, message=None, match=None, to=None):
        def create(n, ty):
            if "phone" == ty:
                url = "http://jarbot.top/bot/profile_add.php?profile=" + n
            elif "name" == ty:
                url = "http://jarbot.top/bot/profile_add.php?pro=" + message.getAuthor(
                ) + "&name=" + n + "&type=name"
            elif "city" == ty:
                url = "http://jarbot.top/bot/profile_add.php?pro=" + message.getAuthor(
                ) + "&name=" + n + "&type=city"
            data = requests.get(url)
            data = data.text
            cur = json.loads(data)
            return cur

        try:
            if match.group("profile") == "phone":
                txt = create(message.getAuthor(), "phone")
            elif match.group("profile") == "name":
                txt = create(match.group("name"), "name")
            elif match.group("profile") == "city":
                txt = create(match.group("name"), "city")
        except (RuntimeError, TypeError, NameError, ValueError):
            print("Error : Try Again")
            if match.group("profile") == "phone":
                txt = create(message.getFrom(), "phone")
            elif match.group("profile") == "name":
                txt = create(match.group("name"), "name")
            elif match.group("profile") == "city":
                txt = create(match.group("name"), "city")
        return TextMessageProtocolEntity(txt, to=message.getFrom())
Пример #12
0
 def countlike(self, message=None, match=None, to=None):
     f = open("count.txt", "a")
     f.write("@")
     f.close()
     self.interface_layer.toLower(
         TextMessageProtocolEntity("Like Added Thanks For Support",
                                   to=message.getFrom()))
Пример #13
0
 def LikeReport(self, message=None, match=None, to=None):
     f = open("count.txt", "r")
     count = f.read()
     f.close()
     self.interface_layer.toLower(
         TextMessageProtocolEntity("Total Likes : " + str(len(count)),
                                   to=message.getFrom()))
Пример #14
0
    def fan(self, message=None, match=None, to=None):
        def ru():
            query = ""
            url = "http://jarbot.top/bot/show.php?fan=true"
            data = requests.get(url)
            data = data.text
            url1 = "http://jarbot.top/bot/show.php?fan_total=true"
            data1 = requests.get(url1)
            total = int(data1.text)

            cur = json.loads(data)
            query += "[FAN PAGE]\n\n"
            for loop in range(total):
                query += str(cur['list'][loop]['id'])
                query += ". " + str(cur['list'][loop]['name'])
                query += "\n\n"
            query += "Become a Fan By Submitting Your Name\n\nhttp://mcetbhb.top/fan.php"
            return (query)

        try:
            txt = ru()
        except (RuntimeError, TypeError, NameError, ValueError):
            print("Error : Try Again")
            txt = ru()
        return TextMessageProtocolEntity(txt, to=message.getFrom())
Пример #15
0
 def getprice(self, message=None, match=None, to=None, currency="INR"):
     currency = match.group("currency").upper()
     if "RUPEES" in currency:
         currency = "INR"
     price = BtcConverter()
     return TextMessageProtocolEntity(
         "1BTC = " + str(price.get_latest_price(currency)) + " " + currency,
         to=message.getFrom())
Пример #16
0
 def par(self, message=None, match=None, to=None):
     is_odd = bool(match.group("im"))
     num = random.randint(1, 10)
     lost = (is_odd and num % 2) or (not is_odd and not num % 2)
     score = self._save_game(message.getFrom(), lost)
     response = "[%d] Você %s\n\n%s\n%s" % (
         num, "ganhou." if lost else "perdeu!", emoticon_lose * score[0],
         emoticon_notlose * score[1])
     return TextMessageProtocolEntity(response, to=message.getFrom())
Пример #17
0
 def loop(self, message=None, match=None, to=None):
     num = int(match.group("num"))
     txt = match.group("msg")
     text = ""
     if num > 500:
         num = 1
     for i in range(num):
         text += txt + "\n"
     return TextMessageProtocolEntity(text, to=message.getFrom())
Пример #18
0
 def weather(self, message=None, match=None, to=None):
     place = match.group("place")
     locator = Nominatim()
     location = locator.geocode(place)
     lat = location.latitude
     lng = location.longitude
     api_key = "7e208df2f156ec0af788e8ec79a30df0"
     forecast = forecastio.load_forecast(api_key, lat, lng)
     byHour = forecast.hourly()
     self.interface_layer.toLower(
         TextMessageProtocolEntity(place + " Has The Following Weather",
                                   to=message.getFrom()))
     for hourlyData in byHour.data[0:3]:
         self.interface_layer.toLower(
             TextMessageProtocolEntity("temprature - " +
                                       str(hourlyData.temperature),
                                       to=message.getFrom()))
     return TextMessageProtocolEntity(byHour.summary, to=message.getFrom())
Пример #19
0
 def breaker(self, message=None, match=None, to=None):
     term = match.group("term")
     s = ""
     a = []
     for x in str(term):
         s = s + x
         a.append(s)
     self.interface_layer.toLower(
         TextMessageProtocolEntity("\n".join(a), to=message.getFrom()))
Пример #20
0
    def polo(self, message=None, match=None, to=None):
        s = requests.session()
        convert = match.group("currency").upper()
        url = "https://www.poloniex.com/public?command=returnTicker&currencyPair="+convert.upper()
        data = requests.get(url)
        data = data.text

        cur = json.loads(data)
        rate = cur[convert.upper()]["last"]
        return TextMessageProtocolEntity("Price("+convert+") :"+rate, to=message.getFrom())
Пример #21
0
 def on_created_group(self, createGroupsNotificationProtocolEntity):
     group_id = createGroupsNotificationProtocolEntity.getGroupId(
     ) + "@g.us"
     if self.is_allowed_on_group(createGroupsNotificationProtocolEntity):
         # this is a good place to a "Hello Group" message
         return TextMessageProtocolEntity("Hello Group i am jarvis:)",
                                          to=message.getFrom())
         pass
     else:
         self.toLower(LeaveGroupsIqProtocolEntity(group_id))
Пример #22
0
 def show(self, message=None, match=None, to=None):
     a = ""
     with open('new.json') as json_file:  
         data = json.load(json_file)
         for p in data['people']:
             a += 'Name: ' + p['name']+'\n'
             a += 'Website: ' + p['website']+'\n'
             a += 'From: ' + p['from']+'\n'
             a += '\n'
     return TextMessageProtocolEntity(a, to=message.getFrom())
Пример #23
0
 def btctalk(self, message=None, match=None, to=None):
     s = requests.session()
     id = match.group("uid")
     url = "https://bitcointalk.org/index.php?action=profile;u="+id
     data = requests.get(url)
     data = data.text
     soup = BeautifulSoup((data), "lxml")
     for name in soup.find_all("td", class_="windowbg"):
         salary = name.parent.find_all('td')[-1]  # last cell in the row
         return TextMessageProtocolEntity(id+" Details :-\n"+name.get_text(), to=message.getFrom())
Пример #24
0
 def learn1(self, message=None, match=None, to=None):
     c = match.group("course")
     if c == "python":
         txt = "Python Lessons Comming Soon"
     elif c == "html":
         txt = "HTML Lessons Comming Soon"
     elif c == "php":
         txt = "PHP Lessons Comming Soon"
     else:
         txt = c + " Lessons Comming Soon"
     return TextMessageProtocolEntity(txt, to=message.getFrom())
Пример #25
0
 def txdid(self, message=None, match=None, to=None):
     addr = match.group("txdaddress")
     url = 'blockchain.info/q/txtotalbtcoutput/' + addr
     r = requests.get("https://" + url)
     data = r.text
     soup = BeautifulSoup(data, "lxml")
     soup = soup.p.get_text()
     return TextMessageProtocolEntity("[" + url + "]\n\nYou have " +
                                      str(float(soup) * 0.00000001) +
                                      " BTC.",
                                      to=message.getFrom())
Пример #26
0
 def even_or_odd(self, message=None, match=None, to=None):
     me = message.getAuthor()
     url = "http://www.mcetbhb.top/profile__show.php?pro=" + me + "&balance=true"
     try:
         try:
             data = requests.get(url)
         except:
             data = requests.get(url)
     except:
         try:
             data = requests.get(url)
         except:
             data = requests.get(url)
     data = data.text
     cur = json.loads(data)
     bal = cur["user"]["balance"]
     is_odd = len(match.group("evenOrOdd")) % 2
     num = random.randint(1, 100)
     add = match.group("bal")
     if "-" in add:
         return TextMessageProtocolEntity("You are a Duck",
                                          to=message.getFrom())
     elif int(bal) > int(add):
         if (is_odd and num % 2) or (not is_odd and not num % 2):
             url = "http://exchange.eu5.org/bot/profile_add.php?pro=" + me + "&addpoint=" + str(
                 add) + "&type=add"
             data = requests.get(url)
             return TextMessageProtocolEntity(
                 "[" + str(num) + "]\nYou win " + str(add) + " Points.",
                 to=message.getFrom())
         else:
             url = "http://exchange.eu5.org/bot/profile_add.php?pro=" + me + "&subpoint=" + str(
                 add) + "&type=sub"
             data = requests.get(url)
             return TextMessageProtocolEntity(
                 "[" + str(num) + "]\nYou lose " + str(add) + " Points.",
                 to=message.getFrom())
     else:
         return TextMessageProtocolEntity("Invalid bet",
                                          to=message.getFrom())
Пример #27
0
 def btc(self, message=None, match=None, to=None):
     url = "http://exchange.eu5.org/bot/bot/page.php?page=btc"
     try:
         data = requests.get(url)
     except:
         data = requests.get(url)
     data = data.text
     cur = json.loads(data)
     try:
         name = cur['page'][0]['text']
     except:
         name = cur['page']['text']
     return TextMessageProtocolEntity(name, to=message.getFrom())
Пример #28
0
    def ask(self, message=None, match=None, to=None):
        def question(n):
            url = "http://jarbot.top/bot/profile_add.php?q=" + n
            data = requests.get(url)
            data = data.text
            cur = json.loads(data)
            return cur

        try:
            txt = question(match.group("term"))
        except (RuntimeError, TypeError, NameError, ValueError):
            print("Error : Try Again")
            txt = question(match.group("term"))
        return TextMessageProtocolEntity(txt, to=message.getFrom())
Пример #29
0
 def onNotification(self, notification):
     """
         Reacts to any notification received
     """
     self.toLower(notification.ack())
     if isinstance(
             notification,
             CreateGroupsNotificationProtocolEntity):  # added on new group
         return TextMessageProtocolEntity("Hello I am Jarvis Bot.",
                                          to=message.getFrom())
         self.on_created_group(notification)
     elif isinstance(notification, ListGroupsResultIqProtocolEntity
                     ):  # result of a query of all groups
         self.on_groups_list(notification)
Пример #30
0
 def fact(self, message=None, match=None, to=None):
     num = int(match.group("number"))
     fact = 1
     if num < 0:
         text = "Sorry, factorial does not exist for negative numbers"
     elif num == 0:
         text = "The factorial of 0 is 1"
     else:
         if num < 1000:
             for i in range(1, num + 1):
                 fact = fact * i
             text = "The factorial of " + str(num) + " is " + str(fact)
         else:
             text = str(num) + " is very huge number. Try Smalller Number"
     return TextMessageProtocolEntity(text, to=message.getFrom())