<commit_before>from twilio.rest import TwilioRestClient
import smtplib
from email.mime.text import MIMEText

class Notifier:
    def __init__(self, email, phone):
        self.email = email
        self.phone = phone

        self.phone = "+15132952362"

        # Your Account Sid and Auth Token from twilio.com/user/account
        account_sid = "<KEY>"
        auth_token  = "3b8e4111c3d10fdeffc666fddd65e6a3"
        self.client = TwilioRestClient(account_sid, auth_token)

    def alert(self, message):
        def alert_phone():
            if self.phone != None:
                to_send = self.client.messages.create(body=message,
                    to=self.phone,
                    from_="+15137269006") # Twilio number

        def alert_email():
            pass
            # # me == the sender's email address
            # # you == the recipient's email address
            # msg['Subject'] = "Event Notification"
            # msg['From'] = me
            # msg['To'] = you
            #
            # # Send the message via our own SMTP server, but don't include the
            # # envelope header.
            # s = smtplib.SMTP('localhost')
            # s.sendmail(me, [you], msg.as_string())
            # s.quit()

        alert_phone()
        alert_email()<commit_msg>email mostly done, waiting on sendgrid verification<commit_after>from twilio.rest import TwilioRestClient
import sendgrid

class Notifier:
    """
    Used to notify user of query detection
    """

    #TODO: MOVE THIS STUFF TO A MORE SECURE LOCATION
    phone_test = "+15073385228"
    email_test = "<EMAIL>"
    twilio_number = "+15137269006"
    twilio_account_sid = "<KEY>"
    twilio_auth_token  = "3b8e4111c3d10fdeffc666fddd65e6a3"
    sendgrid_api_user = "event-detection"
    sendgrid_api_key = "<KEY>"

    def __init__(self, email, phone):
        """
        Initializes notification clients.
        :param email: Email address to send to, can be None
        :param phone: Phone # to text to, can be None
        :return: None
        """

        self.email = email
        self.phone = phone
        self.phone_client = TwilioRestClient(self.twilio_account_sid, self.twilio_auth_token)
        self.email_client = sendgrid.SendGridClient(self.sendgrid_api_user, self.sendgrid_api_key)

    def alert(self, message):
        """
        Alerts user
        :param message: the email/text body
        :return: None
        """
        def alert_phone():
            """
            Sends text message
            :return: None
            """
            if self.phone != None:
                self.phone_client.messages.create(body=message, to=self.phone_test, from_=self.twilio_number)
        def alert_email():
            """
            Sends email message
            :return: None
            """
            if self.email != None:
                message = sendgrid.Mail()
                message.add_to(self.email_test)

                #not sure what address goes here-- maybe test email?
                message.set_from()
                message.set_subject("Event Detection")

                #unclear which one to use
                message.set_html(" test1")
                message.set_text("test2")

                status, msg = self.email_client.send(message)

        alert_phone()
        alert_email()
{'fraction_non_alphanumeric': 0.09418116376724656, 'fraction_numerical': 0.023395320935812838, 'mean_word_length': 1.889948006932409, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1111564', 'n_tokens_mistral': 1012, 'n_tokens_neox': 941, 'n_words': 237}