示例#1
0
def sendPostRequest(phoneNo, fname):

    encrypt.decrypt(dir_path + '/credentials/se')
    with open(dir_path + '/credentials/se', mode='rb') as f:
        content = f.read()
        content = base64.b64decode(content).decode('utf-8')

    ApiKey = str(content.split()[0])

    message = "Birthdays are a new start; fresh beginnings, a time to start new endeavours with new goals. Move forward with fresh confidence and courage. You are a special person, may you have an amazing today and year. Happy birthday " + fname
    url = "https://www.fast2sms.com/dev/bulk"

    payload = "sender_id=FSTSMS" + "&message=" + message + "&language=english&route=p&numbers=" + phoneNo
    headers = {
        'authorization': ApiKey,
        'Content-Type': "application/x-www-form-urlencoded",
        'Cache-Control': "no-cache",
    }
    encrypt.encrypt(dir_path + '/credentials/se')
    return requests.request("POST", url, data=payload, headers=headers)
def Sms_save():

    SmsApiKey = SmsApi.get()

    SmsApiKey_en = base64.b64encode(SmsApiKey.encode('utf-8'))

    file = open(dir_path + '/Data/credentials/se', "w")

    file.write(SmsApiKey_en.decode('utf-8'))
    file.close()

    encrypt.encrypt(dir_path + '/Data/credentials/se')

    SmsApi_entry.delete(0, END)

    Label(Sms_details_screen,
          text="Details Saved. You can close window",
          fg="green",
          font=("calibri", 13)).pack()
    Sms_details_screen.destroy()
def FB_save():
    # get username and password
    username_info = fbusername.get()
    password_info = fbpassword.get()
    confirm_pass_info = fbconfirm_pass.get()

    successfull = False
    if password_info == confirm_pass_info:
        username_n_pass = username_info + " " + password_info
        username_n_pass_en = base64.b64encode(username_n_pass.encode('utf-8'))

        # Open file in write mode
        file = open(dir_path + '/Data/credentials/fbe', "w")

        # write username and password information into file
        file.write(username_n_pass_en.decode('utf-8'))
        file.close()

        encrypt.encrypt(dir_path + '/Data/credentials/fbe')  #encryot the file

        fbusername_entry.delete(0, END)
        fbpassword_entry.delete(0, END)
        fbconfirm_password_entry.delete(0, END)

        # set a label for showing success information on screen

        successfull = True
    if successfull:
        Label(FB_login_screen,
              text="Details Saved Successfully. You can close Window",
              fg="green",
              font=("calibri", 13)).pack()
        FB_login_screen.destroy()
    else:
        Label(FB_login_screen,
              text="Password Do Not Match",
              fg="red",
              font=("calibri", 13)).pack()
def Gmail_save():

    username_info = Gmailusername.get()
    password_info = Gmailpassword.get()
    confirm_pass_info = Gmailconfirm_pass.get()

    successfull = False
    if password_info == confirm_pass_info:

        username_n_pass = username_info + " " + password_info
        username_n_pass_en = base64.b64encode(username_n_pass.encode('utf-8'))

        file = open(dir_path + '/Data/credentials/gme', "w")

        file.write(username_n_pass_en.decode('utf-8'))
        file.close()

        encrypt.encrypt(dir_path + '/Data/credentials/gme')

        Gmailusername_entry.delete(0, END)
        Gmailpassword_entry.delete(0, END)
        Gmailconfirm_password_entry.delete(0, END)

        successfull = True
    if successfull:
        Label(Gmail_login_screen,
              text="Details Saved Successfully. You can close window.",
              fg="green",
              font=("calibri", 13)).pack()

        Gmail_login_screen.destroy()
    else:
        Label(Gmail_login_screen,
              text="Password Do Not Match",
              fg="red",
              font=("calibri", 13)).pack()
示例#5
0
def mail(receiver_mail, fname):
    encrypt.decrypt(dir_path + '/credentials/gme')
    with open(dir_path + '/credentials/gme', mode='rb') as f:
        content = f.read()
        content = base64.b64decode(content).decode('utf-8')

    sender_email = str(content.split()[0])
    password = str(content.split()[1])

    port = 587  # port for .starttls()
    smtp_server = "smtp.gmail.com"  # server to send mail with

    receiver_email = receiver_mail

    context = ssl.create_default_context()

    message = MIMEMultipart("alternative")
    message["Subject"] = "Happy Birthday"
    message["From"] = sender_email
    message["To"] = receiver_mail

    html = """\
    <html>
    <head>
    <link href="https://fonts.googleapis.com/css?family=Yeon+Sung&display=swap" rel="stylesheet">
        <style>
            h4{
            font-size:22px;
            font-family: 'Yeon Sung', cursive;
            }
        </style>
    </head>
        <body>
        <center>
        <h4 >Birthdays are a new start; <br> fresh beginnings, a time to start new endeavours with new goals.<br> Move forward with fresh 
    confidence and courage.<br> You are a special person,<br>
    may you have an amazing today and year. <br> Happy birthday <strong><big>""" + fname + """</big></strong>
            <br><br><img src="https://res.cloudinary.com/vikesh/image/upload/v1573208937/birthdaypic.jpg" width="100%" height="auto">
        </center>
        </body>    
    </html>
    """

    message.attach(MIMEText(html, 'html'))

    # ---------------Sending image-------------
    img_open = open(dir_path + '/birthdaypic.jpg', 'rb')
    img = MIMEImage(img_open.read())
    img_open.close()
    message.attach(img)

    #------------------------Attaching Video------------------
    part = MIMEBase('application', "octet-stream")
    fo = open(dir_path + '/birthday_vid.mp4', "rb")
    part.set_payload(fo.read())
    encoders.encode_base64(part)
    part.add_header(
        'Content-Disposition',
        'attachment; filename="%s"' % os.path.basename("birthday_vid.mp4"))
    message.attach(part)

    #login to server and send email
    try:
        server = smtplib.SMTP(smtp_server, port)
        server.ehlo(
        )  # To identify yourself to the server, .helo() (SMTP) or .ehlo() (ESMTP) should be called
        server.starttls(context=context)  # Secure the connection
        server.ehlo()
        server.login(sender_email, password)

        # Send email here
        server.sendmail(sender_email, receiver_email, message.as_string())
    except Exception as e:
        # print errors
        print(e)
    finally:
        server.quit()

    encrypt.encrypt(dir_path + '/credentials/gme')
示例#6
0
def send_msg(FirstName, Last_Name, GroupNames):

    encrypt.decrypt(dir_path + '/credentials/fbe')
    with open(dir_path + '/credentials/fbe', mode='rb') as f:
        content = f.read()
        content = base64.b64decode(content).decode('utf-8')

    username = str(content.split()[0])
    password = str(content.split()[1])

    client = Client(username, password)

    if client.isLoggedIn():

        # ---------------Person------------------
        name = FirstName + " " + Last_Name
        friends = client.searchForUsers(name)  # return a list of names
        friend = friends[0]
        msg = "Birthdays are a new start; fresh beginnings, a time to start new endeavours with new goals. Move forward with fresh confidence and courage. You are a special person, may you have an amazing today and year. Happy birthday " + FirstName

        # Will send the image located at `<image path>`
        client.sendRemoteImage(
            "https://images.unsplash.com/photo-1558636508-e0db3814bd1d?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1950&q=80",
            thread_id=friend.uid,
            thread_type=ThreadType.USER,
        )
        client.send(Message(text=msg), thread_id=str(friend.uid), thread_type=ThreadType.USER)

        # -------------------------Group----------------------
        for GroupName in GroupNames:
            try:
                gname = GroupName
                groups = client.searchForGroups(gname)

                group = groups[0]
                client.sendRemoteImage(
                    "https://images.unsplash.com/photo-1558636508-e0db3814bd1d?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1950&q=80",
                    thread_id=group.uid,
                    thread_type=ThreadType.GROUP,
                )
                client.send(Message(text=msg), thread_id=group.uid, thread_type=ThreadType.GROUP)
            except:
                continue

        client.logout()

    else:
        print('not logged in')



    #------------------------Automation using browser--------------------

    chrome_options = webdriver.ChromeOptions()

    prefs = {"profile.default_content_setting_values.notifications": 2}
    chrome_options.add_experimental_option("prefs", prefs)
    browser = webdriver.Chrome(dir_path + "/chromedriver")

    # open facebook.com using get() method
    browser.get('https://www.facebook.com/')

    # user_name or e-mail id
    username = username
    password = password


    element = browser.find_elements_by_xpath('//*[@id ="email"]')
    element[0].send_keys(username)


    element = browser.find_element_by_xpath('//*[@id ="pass"]')
    element.send_keys(password)


    # logging in
    log_in = browser.find_elements_by_id('loginbutton')
    log_in[0].click()


    browser.get('https://www.facebook.com/events/birthdays/')

    feed = 'Happy Birthday '

    element = browser.find_elements_by_xpath("//*[@class ='enter_submit\
    uiTextareaNoResize uiTextareaAutogrow uiStreamInlineTextarea \
        inlineReplyTextArea mentionsTextarea textInput']")

    cnt = 0

    for el in element:
        cnt += 1
        element_id = str(el.get_attribute('id'))
        XPATH = '//*[@id ="' + element_id + '"]'
        post_field = browser.find_element_by_xpath(XPATH)
        post_field.send_keys(feed)
        post_field.send_keys(Keys.RETURN)
        print("Birthday Wish posted for friend" + str(cnt))

    # Close the browser
    browser.close()

    encrypt.encrypt(dir_path + '/credentials/fbe')