All Discussions
  • Flip Phones
  • chatGPT texting app

Started by ekjr · Jun 02, 2023

Here's a python script that emails you back BARD answers.
place the question in the subject field of you email.
the script will be checking a label in your emails called bard (so you have to set that up and set a filter)
see here to get a bard token.
for the email password go to https://myaccount.google.com/apppasswords and select mail and generate a password
proper git hub and post coming soon

import email
import imaplib
import smtplib
import time
from bardapi import Bard
from email import message_from_string

user = 'youremail@gmail.com'
password = 'Yourpassword'
token = 'you bard token'

def check(q, to, token, user, password):
    bard = Bard(token=token)
    print(q)
    resp = bard.get_answer(q)['content']
    print(resp)
    send(resp, to, user, password)

def send(body, to, user, password):
    server = smtplib.SMTP('smtp.gmail.com',587)
    server.ehlo()
    server.starttls()
    server.ehlo()
    server.login(user,password)

    subject = 'Yeshvish Bard'

    msg = f'Subject: {subject}\n\n{body}'

    server.sendmail(user,to,msg)
    print('sent')
    server.quit()

def main(user,password):
    mail = imaplib.IMAP4_SSL('imap.gmail.com')
    mail.login(user,password)
    mail.list()
    mail.select("bard")
    result, data = mail.search(None, "ALL")

    ids = data[0]
    id_list = ids.split()
    latest_email_id = id_list[-1]

    result, data = mail.fetch(latest_email_id, "(RFC822)") 

    msg = email.message_from_string(data[0][1].decode('utf-8'))
    
    return msg

global code1
code1 = main(user, password)['Message-ID']

while(True):
    msg = main(user,password)
    ID = msg['Message-ID']
    if ID != code1:
        try:
            msg1 = msg['subject']
            print(msg1)
            to = msg['Return-Path']
            to = str(to)
            to = to.strip('<')
            to = to.strip('>')
            check(msg1, to, token)
            code1 = ID
        except:
            print("err")
        time.sleep(5)

Can you please make one for texting??

you can text a email

ekjr can you explain a little bit more in detail how to set this up?

Hi1 all text messages are a form of email (for example; a Verizon number would be 1234567890@vtext.com). To see what your text address is, send a text your email and see where it's from (sms and MMS are different addresses)

whynot when I tried to send a message to my email it didn't work

Also how do you set it up on a android