def reply(activity, bot, data): state = State() result = state.getStudent(activity["sender"]["id"]) scraper = Scraper() if result: rollno = str(result['RollNumber']) wak = str(result['wak']) #Find the exam Code. #BT3R15NOV17 current = "BT" + convert(str(result["Semester"])) + "R15" + "NOV18" print(current) try: subjects, cred, gpa = scraper.getResults(rollno, wak) except Exception: bot.send_text_activity(activity, "Not Yet! Hold your horses.") return response = "" for i in subjects: for j in i: response += j response += "\t" response += "\n" bot.send_text_activity(activity, response) bot.send_text_activity(activity, "Total Credits: " + str(cred)) bot.send_text_activity(activity, "Gpa: " + str(gpa)) else: bot.send_text_activity( activity, "Authentication failed. Please message your rollno and web access key again." ) bot.send_text_activity( activity, "Enter roll no. and web access key seperated by a single space.")
def reply(activity, bot, data): print(data.get_entities()) credentials = activity["message"]["text"].split(" ") rollno = credentials[0] wak = credentials[1] if len(wak) > 5: bot.send_text_activity( activity, "Please check your roll no. and web access key again.") bot.send_text_activity( activity, "Enter roll no. and web access key seperated by a single space.") return scraper = Scraper() scraper.authenticate(rollno, wak) if scraper.authenticated: student = Student() student_data = {} student_data["user_id"] = activity["sender"]["id"] student_data["wak"] = wak student_data["student_id"] = rollno student.insert_or_update_data(student_data) bot.send_text_activity(activity, "Authentication Successful!") else: bot.send_text_activity( activity, "Please check your roll no. and web access key again.") bot.send_text_activity( activity, "Enter roll no. and web access key seperated by a single space.")
def reply(activity, bot, data): student = Student() result = student.get_data(activity["sender"]["id"]) scraper = Scraper() if result: rollno = str(result['student_id']) wak = str(result['wak']) scraper.authenticate(rollno, wak) attendance = scraper.get_attendance() reply = "Your attendance % is " + str(attendance) bot.send_text_activity(activity, reply) if attendance == 100: responses = [ "Are you insane?! ๐ฎ Take a break dude!", "Someone needs to take a day off. ๐" ] elif attendance > 95: responses = [ "Your parents must be so proud of you. ๐ค", "You do love your college a bit too much, Don't you think? ๐ค", "What are you? A book worm? ๐", "Ghar me rahne nahi dete kya?" ] elif attendance > 85: responses = [ "Perfectly balanced. As all things should be. ๐", "Good Going! ๐" ] elif attendance > 80: responses = [ "You're certainly someone who can balance work and life. ๐", "Making the best of both worlds huh? ๐" ] elif attendance > 75: responses = [ "Phew! Someone likes to live on the edge. ๐ณ", "I see you've been bunking a lot of classes lately. ๐คจ Be cautious and attend your classes.", "The kind of balance you have stricken, seems to me as if you are a part time tightrope walker at a circus" ] elif attendance > 65: responses = [ "Keep the condonation money handy mate. ๐ฌ", "You should go to your classes if you don't want to burn a hole in your pocket. ๐", "Ghar me rahne nahi dete kya?" ] else: responses = [ "Looks like you've been too lazy for your own good. ๐ด", "I hope your okay with sitting amongst your juniors next year. ๐คญ" ] reply = random.choice(responses) bot.send_text_activity(activity, reply) else: bot.send_text_activity( activity, "Authentication failed. Please message your roll no. and web access key again." ) bot.send_text_activity( activity, "Enter roll no. and web access key seperated by a single space.")
async def reply(activity, bot, data): query = Query() db = TinyDB('./db.json') result = db.search(query.userid == activity.from_property.id) scraper = Scraper() if len(result) > 0: result = result[0] rollno = str(result['rollno']) wak = str(result['wak']) scraper.authenticate(rollno, wak) attendance = scraper.get_attendance() reply = "Your attendance % is " + str(attendance) await bot.send_text_activity(activity, reply) if attendance == 100: responses = [ "Are you insane?! ๐ฎ Take a break dude!", "Someone needs to take a day off. ๐" ] elif attendance > 95: responses = [ "Your parents must be so proud of you. ๐ค", "You do love your college a bit too much, Don't you think? ๐ค", "What are you? A book worm? ๐" ] elif attendance > 85: responses = [ "Perfectly balanced. As all things should be. ๐", "Good Going! ๐" ] elif attendance > 80: responses = [ "You're certainly someone who can balance work and life. ๐", "Making the best of both worlds huh? ๐" ] elif attendance > 75: responses = [ "Phew! Someone likes to live on the edge. ๐ณ", "I see you've been bunking a lot of classes lately. ๐คจ Be cautious and attend your classes." ] elif attendance > 65: responses = [ "Keep the condonation money handy mate. ๐ฌ", "You should go to your classes if you don't want to burn a hole in your pocket. ๐" ] else: responses = [ "Looks like you've been too lazy for your own good. ๐ด", "I hope your okay with sitting amongst your juniors next year. ๐คญ" ] reply = random.choice(responses) await bot.send_text_activity(activity, reply) else: await bot.send_text_activity( activity, "Authentication failed. Please message your roll no. and web access key again." ) await bot.send_text_activity( activity, "Enter roll no. and web access key seperated by a single space.")
def reply(activity, bot, data): student = Student() result = student.get_data(activity["sender"]["id"]) scraper = Scraper() if result: rollno = str(result['student_id']) wak = str(result['wak']) scraper.authenticate(rollno, wak) conducted, attended = scraper.getPeriods() percentageifpresent = round(((attended+7)/(conducted + 7) * 100), 2) percentageifabsent = round(((attended)/(conducted + 7) * 100), 2) response = "Your attendance will be %.2f if present, otherwise %.2f" % (percentageifpresent, percentageifabsent) bot.send_text_activity(activity, response) if percentageifabsent > 95: responses = [ "Go ahead and take a break, You deserve it. ๐ค", "Seriously, take a day off. ๐", "You've been regular to the college. You've earned a day for yourselves. ๐" ] elif percentageifabsent > 90: responses = [ "Well, your attendance % will still be quite good. But it's upto you. ๐", "You are very much eligible to skip college tomorrow. ๐", "You can skip college without any guilt. ๐" ] elif percentageifabsent > 85: responses = [ "It is probably okay to skip college tomorrow. Exercise some caution though. ๐", "You've been doing great. Try to keep it up... or just stay back for once. ๐ ", "Aaj Jaane Ki Zidd Naa Karo.. ๐" ] elif percentageifabsent > 80: responses = [ "I'd tell you to go to the class par meri kaun sunta hai? ๐", "If you think you can manage 75%, you are more than welcome to try. ๐ฌ", "\"Laziness may seem attractive, but work gives satisfaction.\" - Anne Frank ๐" ] elif percentageifabsent > 75: responses = [ "I see you like to live dangerously โ ... But give a little thought to it.", "You can probably get away with this one. ๐", "You've been skipping college way too much but you just might get another day." ] elif percentageifabsent > 65: responses = [ "Please just get off your butt and go to the class. ๐", "I know the bed looks very cozy right now but you should definitely go. ๐", "Your laziness is really not worth paying that extra money to the college. ๐" ] else: responses = [ "Beta tumse naa ho paayega ๐", "I'm sorry but you probably can't afford to take even a single day off. ๐ค", "Uhmm.. No way you can skip college right now. ๐" ] reply = random.choice(responses) bot.send_text_activity(activity, reply)
def parse_inner_page(html): """ Parser para paginas interiores :param html: :return: """ s1 = Scraper(html) parsed_dict = { 'titulo': s1.soup.find('title').text.encode("utf-8"), 'zona': s1.scrape_tags_with_class('p', 'zona-nombre'), 'precio': s1.scrape_tags_with_class('p', 'precio-final'), 'telefono': s1.scrape_tags_with_class('span', 'lineInmo'), 'info': s1.scrape_tags_with_class('div', 'dotInfo'), 'referencia': s1.find_tag_or_empty('div', 'class', 'referencia-slider'), 'descripcion': s1.find_tag_and_strip_html('div', 'id', 'descripcion'), 'anunciante': s1.find_tag_or_empty('p', 'id', 'nombre-inmobiliaria'), } # Intenta recuperar valores del string info = parsed_dict['info'] parsed_dict['garajes'] = find_in_separated_string(info, '|', ['garaje']) parsed_dict['banos'] = find_in_separated_string(info, '|', ['baรฑo']) parsed_dict['recamaras'] = find_in_separated_string(info, '|', ['Amb', 'recamara']) parsed_dict['metros'] = find_in_separated_string(info, '|', ['mยฒ']) return parsed_dict
def parse_main_page(html): """ Parser para la pagina principal :param html: :return: """ s2 = Scraper(html) parsed_dict = { 'target_urls': s2.get_attr_from_tag_with_class('a', 'class', 'holder-link') } return parsed_dict
def reply(activity, bot, data): student = Student() result = student.get_data(activity["sender"]["id"]) scraper = Scraper() if result: print(result) rollno = str(result['student_id']) wak = str(result['wak']) #Find the exam Code. #BT3R15NOV17 current = "BT" + get_semester_from_id(result['student_id']) + "R15" + "NOV18" print(current) try: subjects, cred, gpa = scraper.getResults(rollno,wak,current) except Exception: bot.send_text_activity(activity, "Not Yet! Hold your horses.") return response = "" for i in subjects: for j in i: response += j response += "\t" response += "\n" bot.send_text_activity(activity, response) bot.send_text_activity(activity, "Total Credits: " + str(cred)) bot.send_text_activity(activity, "Gpa: " + str(gpa)) if gpa >= 9.5: responses = ["iamgonnacry", "really", "hurtmyfeelings", "Clapping", "telugu1"] elif gpa >= 9.0: responses = ["Winner", "genius", "mindblown", "youaretheman", "awesomesauce", "minions", "badass", "proud", "meeru", "mahesh"] elif gpa >= 8.0: responses = ["Woah", "whosawesome", "WOW", "fantastic", "Mogambo", "superabba", "intelli"] elif gpa >= 7.0: responses = ["goodjob", "groot", "betterluck", "deserve", "control"] elif gpa >= 6.0: responses = ["barelysurviving", "sarsarle", "apnatimeaayega"] elif gpa >= 5.0: responses = ["iknowthatfeel", "iknowtfeel", "baymax", "nextsem", "rightinthefeels"] elif gpa >= 4.0: responses = ["doyouthink", "laughing", "howamisupposedtolive", "tearsineyes", "doomed", "feels", "subject"] elif gpa < 4.0: responses = ["ohdear", "mkalaadla", "gfather", "hug", "crying", "ritf", "balayya"] reply = random.choice(responses) bot.send_rich_activity(activity, "https://www.utorai.com/assets/gifs/" + reply + ".gif") else: bot.send_text_activity(activity, "Authentication failed. Please message your rollno and web access key again.") bot.send_text_activity(activity, "Enter roll no. and web access key seperated by a single space.")
def reply(activity, bot, data): query = Query() db = TinyDB('./db.json') result = db.search(query.userid == activity["sender"]["id"]) scraper = Scraper() if len(result) > 0: result = result[0] rollno = str(result['rollno']) wak = str(result['wak']) scraper.authenticate(rollno, wak) entities = data.get_entities() if 'semester' in entities: gpa = scraper.get_gpa(entities['semester']) reply = "Your SGPA is " + str(gpa) else: gpa = scraper.get_cgpa() reply = "Your CGPA is " + str(gpa) bot.send_text_activity(activity, reply) if gpa > 9.5: responses = [ "Woah! Look at you going all out on your tests! Awesome! ๐ฏ", "Watch out! We've got a badass over here. ๐" ] elif gpa > 9.0: responses = [ "Are you sure you aren't Einstein? ๐ง Keep up the good work! ๐", "If maintaining your grades up was an art, You'd be the Picasso of it. ๐" ] elif gpa > 8.0: responses = [ "We've got a champ here! You are doing great! ๐", "Seems like youโve got what it takes to make it to the top. ๐" ] elif gpa > 7.0: responses = [ "Hang in there bud! You're on the right track! โ", "You'd probably think it's enough but hey, a little hard work never killed anyone. ๐" ] elif gpa > 6.0: responses = [ "Who needs a good CGPA when you're cool no? ๐ JK, you still need it.. ๐ ", "You are hanging by a thread here bud. But it's never too late though. ๐" ] else: responses = [ "It's okay, you don't have to be a topper! The only one you have to beat is the one you were last semester. Work harder this time! ๐", "Don't get disheartened yet. There's a lot to look forward to, if you make sure you study harder. ๐", "\"If at first you don't succeed, then skydiving isn't for you.\" - Steven Wright ๐" ] reply = random.choice(responses) bot.send_text_activity(activity, reply) else: bot.send_text_activity( activity, "Authentication failed. Please message your rollno and web access key again." ) bot.send_text_activity( activity, "Enter roll no. and web access key seperated by a single space.")
async def reply(activity, bot, data): print(data.get_entities()) credentials = activity.text.split(" ") rollno = credentials[0] wak = credentials[1] if len(wak) > 5: await bot.send_text_activity( activity, "Please check your roll no. and web access key again.") await bot.send_text_activity( activity, "Enter roll no. and web access key seperated by a single space.") return scraper = Scraper() scraper.authenticate(rollno, wak) if scraper.authenticated: query = Query() db = TinyDB('./db.json') result = db.search(query.userid == activity.from_property.id) if len(result) > 0: db.update({ 'rollno': rollno, 'wak': wak }, query.userid == activity.from_property.id) await bot.send_text_activity(activity, "Authentication Successful!") else: db.insert({ 'userid': activity.from_property.id, 'rollno': rollno, 'wak': wak }) await bot.send_text_activity(activity, "Authentication Successful!") else: await bot.send_text_activity( activity, "Please check your roll no. and web access key again.") await bot.send_text_activity( activity, "Enter roll no. and web access key seperated by a single space.")