def welcome_message(): new_message = Message() new_message \ .add("👋 Welcome to the Grade Notifier 🚨") \ .newline() \ .newline() \ .add("You're all set up. You should recieve a message soon with your current grades.") \ .newline() \ .add("After that first message, the notifier will message you whenever a grade changes (or is added)!") \ .newline() return new_message.sign().message()
def welcome_message(): new_message = Message() new_message \ .add("👋 Welcome to the Grade Notifier 🚨") \ .newline() \ .newline() \ .add("You're all set up. You should see your current grades below!") \ .newline() \ .add("The notifier will message you whenever a grade changes (or is added)!") \ .newline() return new_message
def welcome_message(): new_message = Message() new_message \ .add("👋 Welcome to the Grade Notifier 🚨") \ .newline() \ .newline() \ .add("Your UID is: {0}".format(custom_hash(user.get_username()))) \ .newline() \ .add("You're all set up. You should see your current grades below!") \ .newline() \ .add("The notifier will message you whenever a grade changes (or is added)!") \ .newline() return new_message
def create_text_message(change_log, is_welcome=False): # Message header new_message = None if is_welcome: new_message = welcome_message() else: new_message = Message() new_message \ .add("New Grades have been posted for the following classes") \ .newline() \ .add("-------------") \ .newline() class_num = 1 gpa = change_log.gpa for elm in change_log.classes: if len(elm['grade']) != 0: new_message \ .add("{0}. {1}".format(class_num, elm['name'])) \ .newline() class_num += 1 new_message \ .newline() \ .add("Grade for those classes are:") \ .newline() \ .add("----------------------------") \ .newline() for elm in change_log.classes: if len(elm['grade']) != 0: new_message \ .add("{0}: {1} (Grade) -- {2} (Grade Points)".format( elm['name'], elm['grade'], elm['gradepts'])) \ .newline() if gpa.get_term_gpa() >= 0: new_message.add("----------------------------").newline().add( "Your term GPA is: {0}".format(gpa.get_term_gpa())).newline().add( "Your cumulative GPA is: {0}".format( gpa.get_cumulative_gpa())).newline() # Sign the message new_message.sign() return new_message.message()
def test_construction(self): message = Message() self.assertEqual(message.message(), 'Grade Alert 🚨 from Grade Notifier\n\n') message \ .add("Foo") \ .add("Bar") \ .add("Baz") message.newline() message.add("foo") self.assertEqual( message.message(), 'Grade Alert 🚨 from Grade Notifier\n\n' + 'FooBarBaz\nfoo') message.sign() self.assertEqual( message.message(), 'Grade Alert 🚨 from Grade Notifier\n\n' + 'FooBarBaz\nfoo\nHope you did well! -- Ehud & Akiva')