async def astro(e): await e.edit("Fetching data...") if not e.pattern_match.group(1): x = ASTRO if not x: await e.edit("Not Found.") return else: x = e.pattern_match.group(1) horoscope = pyaztro.Aztro(sign=x) mood = horoscope.mood lt = horoscope.lucky_time desc = horoscope.description col = horoscope.color com = horoscope.compatibility ln = horoscope.lucky_number result = (f"**Horoscope for `{x}`**:\n" f"**Mood :** `{mood}`\n" f"**Lucky Time :** `{lt}`\n" f"**Lucky Color :** `{col}`\n" f"**Lucky Number :** `{ln}`\n" f"**Compatibility :** `{com}`\n" f"**Description :** `{desc}`\n") await e.edit(result)
async def cyber(e): await e.edit("Məlumatlar hazırlanır..\nBu biraz vaxt apara bilər.") if not e.pattern_match.group(1): x = CYBER if not x: await e.edit("Bağışlayın, heçnə tapa bilmədim.") return else: x = e.pattern_match.group(1) horoscope = pyaztro.Aztro(sign=x) mood = horoscope.mood lt = horoscope.lucky_time desc = horoscope.description col = horoscope.color com = horoscope.compatibility ln = horoscope.lucky_number result = ( f"**`{x}`** üçün məlumat:\n" f"**Mood :** `{mood}`\n" f"**Şanslı vaxt :** `{lt}`\n" f"**Şanslı rəng :** `{col}`\n" f"**Şanslı rəqəm :** `{ln}`\n" f"**Uyğunluq :** `{com}`\n" f"**Haqqında :** `{desc}`\n" ) await e.edit(result)
async def astro(e): msg = await e.reply("Fetching data...") if not e.pattern_match.group(1): x = ASTRO if not x: await msg.edit("Not Found.") return else: x = e.pattern_match.group(1) horoscope = pyaztro.Aztro(sign=x) mood = horoscope.mood lt = horoscope.lucky_time desc = horoscope.description col = horoscope.color com = horoscope.compatibility ln = horoscope.lucky_number result = (f"**Horoscope for `{x}`**:\n" f"**Mood :** `{mood}`\n" f"**Lucky Time :** `{lt}`\n" f"**Lucky Color :** `{col}`\n" f"**Lucky Number :** `{ln}`\n" f"**Compatibility :** `{com}`\n" f"**Description :** `{desc}`\n") await msg.edit(result) if "Kittu" in Credit: pass else: await e.reply( "This Module is made by @A_Viyu you n***a give him credit.")
def return_horoscope(sign, timeframe="today"): if sign == "No sign": content = { 'sign': "No sign", 'mood': "No sign", 'lucky_time': "No sign", 'description': "No sign", 'date_range': "No sign", 'lucky_color': "No sign", 'compatibility': "No sign", 'current_date': "No sign", 'lucky_number': "No sign", 'timeframe': timeframe } return content sign = sign.lower() print(f'aztro sign: {sign}') horoscope = pyaztro.Aztro(sign=sign, day=timeframe) lucky_color = horoscope.color content = { 'sign': sign.capitalize(), 'mood': horoscope.mood, 'lucky_time': horoscope.lucky_time, 'description': horoscope.description, 'date_range': horoscope.date_range, 'lucky_color': lucky_color, 'compatibility': horoscope.compatibility, 'current_date': horoscope.current_date, 'lucky_number': horoscope.lucky_number, 'timeframe': timeframe } content['date_range'] = content['date_range'][0].strftime( "%B %d") + " - " + content['date_range'][1].strftime("%B %d") return content
def test_correct_date(self): for i in range(3): data = pyaztro.Aztro(sign='aries', day=self.days[i]) self.assertTrue(type(data) is pyaztro.aztro.Aztro) self.assertEqual( type(data.current_date), type(datetime.date.today() - datetime.timedelta(days=(i - 1))))
def getHoroscope(theSign): if theSign == "Garbage": dictHoroscope = { "current_date": "IDK!", "compatibility": "other garbage", "lucky_time": "when you learn to type", "lucky_number": "13", "color": "gross", "date_range": "IDK", "mood": "garbage mood", "description": "Well, this is awkward, but it seems like you entered something so wrong that even our sensors couldn't detect what you meant. Did you enter a month as a number? Or just type or sign in instead of a date (why are you using this app)? Either way, you broke something, and we don't know how to fix it. So guess your day is pretty rough, friend!" } else: horoscope = pyaztro.Aztro(sign=theSign) dictHoroscope = { "current_date": horoscope.current_date, "compatibility": horoscope.compatibility, "lucky_time": horoscope.lucky_time, "lucky_number": horoscope.lucky_number, "color": horoscope.color, "date_range": horoscope.date_range, "mood": horoscope.mood, "description": horoscope.description } return dictHoroscope
def get_response(): bday = '' bday = request.args.get('bday') horoscope = pyaztro.Aztro(sign=get_sign_name(bday)) sign = horoscope.sign.capitalize() mood = horoscope.mood description = horoscope.description response = spotiClient().apiRequest(params={"type": "playlist", "q": mood + "&20music"}) id = response['playlists']['items'][0]['id'] src = "https://open.spotify.com/embed/playlist/{}".format(id) return render_template('template2.html', src=src, bday=bday, mood=mood, sign=sign, description=description)
def send_message(message): sign = message.text if message.text == 'Leo' or message.text == '♌️' or message.text == 'лев' or message.text == 'Лев': sign = 'leo' elif message.text == 'Pisces' or message.text == '♓️' or message.text == 'Риба' or message.text == 'риба': sign = 'pisces' elif message.text == 'Aquarius' or message.text == '♒️' or message.text == 'Водолій' or message.text == 'водолій': sign = 'aquarius' elif message.text == 'Capricorn' or message.text == '♑️' or message.text == 'Козеріг' or message.text == 'козеріг': sign = 'capricorn' elif message.text == 'Sagittarius' or message.text == '♐️' or message.text == 'Стрілець' or message.text == 'стрілець': sign = 'sagittarius' elif message.text == 'Scorpio' or message.text == '♏️' or message.text == 'Скорпіон' or message.text == 'скорпіон': sign = 'scorpio' elif message.text == 'Libra' or message.text == '♎️' or message.text == 'Терези' or message.text == 'терези': sign = 'libra' elif message.text == 'Virgo' or message.text == '♍️' or message.text == 'Діва' or message.text == 'діва': sign = 'virgo' elif message.text == 'Cancer' or message.text == '♋️' or message.text == 'рак' or message.text == 'Рак': sign = 'cancer' elif message.text == 'Gemini' or message.text == '♊️' or message.text == 'Близнюки' or message.text == 'близнюки': sign = 'gemini' elif message.text == 'Taurus' or message.text == '♉️' or message.text == 'телець' or message.text == 'Телець': sign = 'taurus' elif message.text == 'Aries' or message.text == '♈️' or message.text == 'овен' or message.text == 'Овен': sign = 'aries' else: sign = 'aries' horoscope = pyaztro.Aztro(sign, day='today') horoscope1 = pyaztro.Aztro(sign, day='tomorrow') h = (sign + "\n" + "horoscope on today: " + str(horoscope.description) + "\n\n" + "horoscope on tomorrow: " + str(horoscope1.description) + "\n\n" + 'you compatibility: ' + str(horoscope.compatibility) + "\n\n" + 'your mood: ' + str(horoscope.mood) + "\n\n" + 'your color: ' + str(horoscope.color) + "\n\n" + 'your lucky number: ' + str(horoscope.lucky_number) + "\n\n") bot.send_message(message.chat.id, h)
def get_compliment(): name = request.args.get('name') horoscope_sign = request.args.get('horoscope_type') horoscope = pyaztro.Aztro(sign=horoscope_sign) horoscope_desc = horoscope.description horoscope_time = horoscope.lucky_time horoscope_mood = horoscope.mood horoscope_color = horoscope.color horoscope_num = horoscope.lucky_number return render_template( 'compliments.html', name=name, horoscope_name = horoscope_sign, horoscope_desc = horoscope_desc, horoscope_time = horoscope_time, horoscope_mood = horoscope_mood, horoscope_color = horoscope_color, horoscope_num = horoscope_num)
def sendhoroscope(ino): signs = dict( ) #creates dictionary for each serial input and corresponding output signs["b'a'"] = 'aries' signs["b'b'"] = 'taurus' signs["b'c'"] = 'gemini' signs["b'd'"] = 'cancer' signs["b'e'"] = 'leo' signs["b'f'"] = 'virgo' signs["b'g'"] = 'libra' signs["b'h'"] = 'scorpio' signs["b'i'"] = 'sagittarius' signs["b'j'"] = 'capricorn' signs["b'k'"] = 'aquarius' signs["b'l'"] = 'pisces' horoscope = pyaztro.Aztro(signs[ino]) #star-sign horoscope set horoln = horoscope.mood + ', ' + str( horoscope.lucky_number) + '\n' #creates full string to send print(horoln) ser.write(str.encode(horoln)) #sends full string to arduino
def astro(update: Update, context: CallbackContext): message = update.effective_message args = message.text.split(" ", 1) if len(args) == 1: message.reply_text( 'Please choose your horoscope sign. List of all signs - aries, taurus, gemini, cancer, leo, virgo, libra, scorpio, sagittarius, capricorn, aquarius and pisces.' ) return else: pass msg = message.reply_text("Fetching data...") try: x = args[1] horoscope = pyaztro.Aztro(sign=x) mood = horoscope.mood lt = horoscope.lucky_time desc = horoscope.description col = horoscope.color com = horoscope.compatibility ln = horoscope.lucky_number result = (f"**Horoscope for `{x}`**:\n" f"**Mood :** `{mood}`\n" f"**Lucky Time :** `{lt}`\n" f"**Lucky Color :** `{col}`\n" f"**Lucky Number :** `{ln}`\n" f"**Compatibility :** `{com}`\n" f"**Description :** `{desc}`\n") msg.edit_text(result, parse_mode=ParseMode.MARKDOWN) except Exception as e: msg.edit_text( f"Sorry i haven't found anything!\nmaybe you have given a wrong sign name please check help of horoscope.\nError - {e}" )
#Testing ability to retrieve daily horoscope #################Currently works only in python 2.7#################### import pyaztro horoscope = pyaztro.Aztro(sign='aries') hor = horoscope.description print(hor)
def test_wrong_sign(self): for i in self.non_signs: data = pyaztro.Aztro(sign=i) self.assertTrue(type(data) is str) self.assertTrue(wrong_param_response in data)
def __horoscope_grab(self, _sign: str) -> str: """Helper method to grab the horoscope data for the given star sign""" return pyaztro.Aztro( sign=_sign) # returns the horoscope object with the data loaded
def test_anycase_input(self): for i in self.any_case_sign: data = pyaztro.Aztro(sign=i) self.assertEqual(type(data), type(self.check))
def test_wrong_date(self): for i in self.wrong_date: data = pyaztro.Aztro(sign='aries', day=i) self.assertTrue(type(data) is str) self.assertTrue(wrong_param_response in data)
def test_correct_sign(self): for i in self.signs: print(i) data = pyaztro.Aztro(i) self.assertTrue(type(data) is pyaztro.aztro.Aztro)
def setUp(self): try: self.check = pyaztro.Aztro(sign='aries', day='today') except Exception as networkerror: print("setUp method failed to execute :", networkerror) sys.exit(1)
def on_status(self, status): # Static variable maks = 10 print('starting prediction') #Dynamic Variabel target_user_id = status.user.id target_user = api.get_user(target_user_id) user = api.me() user_a = user.id user_b = target_user_id #to check apakah dah follow apa belum stats = api.show_friendship(source_id=user_a, source_screen_name=user.screen_name, target_id=user_b, target_screen_name=target_user.screen_name) #ngecek jumlah followers nfolls = status.user.followers_count #horoscope zodiac = status.text zodiac = zodiac.lower() zodiac = zodiac.replace(".", "") zodiac = zodiac.replace(",", "") zodiac = zodiac.split() zodiac = zodiac[1] horoskop = [ 'aries', 'taurus', 'gemini', 'cancer', 'leo', 'virgo', 'libra', 'scorpio', 'sagittarius', 'capricorn', 'aquarius', 'pisces' ] #list kata0 #jika jumlah tweet yang di reply < 5 if StreamListener.tweet_counter < maks: #jika dia follow akun if stats[0].followed_by == True: if status.is_quote_status == True: print("> (is quoted)" + status.user.screen_name + ": " + status.text + " ( skipped )") elif 'RT' in status.text: print("> (is retweeted)" + status.user.screen_name + ": " + status.text + " ( skipped )") elif status.in_reply_to_status_id != None: print("> (is replyied)" + status.user.screen_name + ": " + status.text + " ( skipped )") elif zodiac not in horoskop: time.sleep(10) api.update_status( "@" + status.user.screen_name + " " + 'hi, please do check our format (on pinned) correctly', in_reply_to_status_id=status.id) print("> (wrong format)" + status.user.screen_name + ": " + status.text + " ( skipped )") #kalo followers kurang dari 40 elif nfolls < 1: time.sleep(10) api.update_status( "@" + status.user.screen_name + " " + 'Sorry, your followers must be more than 0.', in_reply_to_status_id=status.id) print( str(StreamListener.tweet_counter) + ". (less than 0 followers)" + status.user.screen_name + ": " + status.text + " ( replied )") else: #get zodiac features horoscope = pyaztro.Aztro(sign=zodiac) username = status.user.screen_name mood = horoscope.mood luckytime = horoscope.lucky_time description = horoscope.description color = horoscope.color jodoh = horoscope.compatibility luckynumber = horoscope.lucky_number kata2 = 'Hello ' + username + "! here's your horoscope daily!" + '\n' + '\n' + "Today's mood: " + mood + '\nYour lucky number: ' + str( luckynumber ) + '\n' + 'Color of the day: ' + color + '\nPerfect companion: ' + jodoh kata3 = '\nSpecial Message: ' + '\n' + description kata4 = 'We post different messages each day! see you tomorrow ' + username + ' :)' time.sleep(10) original_tweet = api.update_status( "@" + status.user.screen_name + " " + kata2, in_reply_to_status_id=status.id) second_tweet = api.update_status( kata3, in_reply_to_status_id=original_tweet.id, auto_populate_reply_metadata=True) third_tweet = api.update_status( kata4, in_reply_to_status_id=second_tweet.id, auto_populate_reply_metadata=True) StreamListener.tweet_counter += 1 StreamListener.total_predict += 1 #logs print( str(StreamListener.tweet_counter) + ". " + status.user.screen_name + ": " + status.text + " ( replied )") #Jika dia belom follow akun else: if status.is_quote_status == True: print("> (is quoted)" + status.user.screen_name + ": " + status.text + " ( skipped )") elif 'RT' in status.text: print("> (is retweeted)" + status.user.screen_name + ": " + status.text + " ( skipped )") elif status.in_reply_to_status_id != None: print("> (is replyied)" + status.user.screen_name + ": " + status.text + " ( skipped )") #reply suruh follow dulu else: time.sleep(10) api.update_status("@" + status.user.screen_name + " " + 'Please follow us first, then try again', in_reply_to_status_id=status.id) print(">" + status.user.screen_name + ": must follow first" + " ( replied )") #jika jumlah tweet yang di reply > 5 else: #get zodiac features horoscope = pyaztro.Aztro(sign=zodiac) username = status.user.screen_name mood = horoscope.mood luckytime = horoscope.lucky_time description = horoscope.description color = horoscope.color jodoh = horoscope.compatibility luckynumber = horoscope.lucky_number kata2 = 'Hello ' + username + "! here's your horoscope daily!" + '\n' + '\n' + "Today's mood: " + mood + '\nYour lucky number: ' + str( luckynumber ) + '\n' + 'Color of the day: ' + color + '\nPerfect companion: ' + jodoh kata3 = '\nSpecial Message: ' + '\n' + description kata4 = 'We post different messages each day! see you tomorrow ' + username + ' :)' time.sleep(10) original_tweet = api.update_status("@" + status.user.screen_name + " " + kata2, in_reply_to_status_id=status.id) second_tweet = api.update_status( "@" + status.user.screen_name + " " + kata3, in_reply_to_status_id=original_tweet.id, auto_populate_reply_metadata=True) third_tweet = api.update_status( "@" + status.user.screen_name + " " + kata4, in_reply_to_status_id=second_tweet.id, auto_populate_reply_metadata=True) print('Max num reached = ' + str(StreamListener.tweet_counter)) StreamListener.tweet_counter = 0 print('Istirahat 1 Menit') time.sleep(60 * 1) print("starting prediction again") print('============================') print('max number: ' + str(StreamListener.tweet_counter)) print('total zodiac today: ' + str(StreamListener.total_predict)) print('============================')