Instantly share code, notes, and snippets.

Embed
What would you like to do?
Python script to send a Direct message when motion is detected by MotionEyeOS
#!/usr/bin/env python
##########################################################################
### Python Script to send a Direct Message to your official Twitter handle
### run 'sudo pip install python-twitter' before execution
### Author: Sid
### https://zone13.io
### Version 1.0
##########################################################################
import twitter, time
# Populate your official Twitter handle below
twitter_handle = ''
# Populate the Twitter API keys below
consumer_key = ''
consumer_secret = ''
access_token_key = ''
access_token_secret = ''
api = twitter.Api(
consumer_key=consumer_key,
consumer_secret=consumer_secret,
access_token_key=access_token_key,
access_token_secret=access_token_secret)
# Get current time
t = time.strftime("%d-%m-%Y %H:%M:%S", time.gmtime())
msg = "Alert !! Motion detected at " + t
# Send Direct Message to official Twitter handle
send_msg = api.PostDirectMessage(msg, user_id=None, screen_name=twitter_handle)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment