def tweet_engine(status):
    global ai_result

    if any(tweet in status.text.lower()
           for tweet in keywords) and status.user.id_str == "44196397":
        send_mail(f"Elon tweeted: {status.text} - on {time.ctime()}", False)
    # If no keywords match, check if there is an image
    elif hasattr(status,
                 "extended_entities") and status.user.id_str == "44196397":
        # Loop through each image
        for media in status.extended_entities["media"]:
            """
            Download and write the tweet image.
            This will overwrite each new tested image to
            reduce the number of files stored.
            """
            urllib.request.urlretrieve(media["media_url_https"],
                                       "image-to-test.jpg")
            # Run the image through ImageAI to detect objects in it
            detections = detector.detectObjectsFromImage(
                input_image=os.path.join(os.getcwd(), "image-to-test.jpg"),
                output_image_path=os.path.join(os.getcwd(),
                                               "image-tested.jpg"),
            )
            # If detection data matches any of the keywords send e-mail
            for detection in detections:
                if any(name in detection["name"] for name in keywords):
                    ai_result = True
        # At this point we know image passed AI validation
        if ai_result is True:
            send_mail(
                f'Picture tweeted - see attachment. Tweet: {status.text}',
                True)
            ai_result = False
Esempio n. 2
0
def tweet_engine(status):

    # if any(tweet in status.text.lower() for tweet in keywords) and status.user.id_str == "44196397":
    #     send_mail(f"Elon tweeted: {status.text} - on {time.ctime()}", False)

    if status.user.id_str == "44196397":
        send_mail(f"Elon tweeted: {status.text} - on {time.ctime()}", False)
Esempio n. 3
0
def main():
    #百度外卖
    startbdurl = ['http://waimai.baidu.com/waimai/shop/1605790211',#快客
                  'http://waimai.baidu.com/waimai/shop/1551965525',#爱尚客
                  'http://waimai.baidu.com/waimai/shop/15138092782538220856', #教头
                  'http://waimai.baidu.com/waimai/shop/1600001786',#熊吐司
                  'http://waimai.baidu.com/waimai/shop/1578842218'#双喜
                 ]

    saleinfo = ""
    for url in startbdurl:
        html = urllib.urlopen(url).read()
        #print url
        info = parsebaidu(html).replace('\n', ' ').replace('(手机app专享)'.decode('utf-8'),'')
        #print type(saleinfo), type(info)
        saleinfo = saleinfo + info + '\n'

    print saleinfo
    send_mail(saleinfo)
Esempio n. 4
0
    def on_post(self, req, resp):
        try:
            event_json = json.load(req.stream, "utf-8")
        except ValueError:
            raise falcon.HTTPError(
                falcon.HTTP_753, "Malformed JSON", "Could not decode the request body. The " "JSON was incorrect."
            )

        stripe.api_key = "XXX"
        if event_json["type"] in (
            "charge.succeeded",
            "charge.failed",
            "charge.refunded",
            "charge.captured",
            "charge.updated",
            "charge.dispute.created",
            "charge.dispute.updated",
            "charge.dispute.closed",
            "customer.created",
            "customer.subscription.created",
            "customer.subscription.updated",
            "invoice.created",
            "invoice.updated",
            "invoice.payment_succeeded",
            "invoice.payment_failed",
            "transfer.failed",
        ):
            try:
                id = event_json["id"]
                event = stripe.Event.retrieve(id)
                send_mail(("*****@*****.**",), event_json["type"], str(event))
            except (
                stripe.error.InvalidRequestError,
                stripe.error.AuthenticationError,
                stripe.error.APIConnectionError,
                stripe.error.StripeError,
            ) as err:
                send_mail(("*****@*****.**",), "Stripe Webhook Error", str(err.json_body["error"]))

        resp.status = falcon.HTTP_200  # This is the default status
Esempio n. 5
0
 def on_status(self, status):
     keywords = ['stock', 'share', '$', 'doge', 'crypto', 'bitcoin']
     # this solution will exclude replies and mentions and only return Elon's tweets
     if any(tweet in status.text.lower() for tweet in keywords) and status.user.id_str == '44196397':
         # send e-mail
         send_mail(f"Elon tweeted: {status.text} - on {time.ctime()}")
Esempio n. 6
0
from qrgenerator import qrgen
from emailsender import send_mail

number = 123321
addr = "*****@*****.**"

qrgen(number, f"당신은 {number}번입니다.")

send_mail(addr, "테스트 제목", "test 입니다")