Skip to content

Instantly share code, notes, and snippets.

Last active Nov 16, 2017
What would you like to do?
Raspberry Pi Twitter Bot Twython Script - Tweet Internal Wi-Fi IP Address
#!/usr/bin/env python
import sys
import os
from twython import Twython
CONSUMER_KEY = 'redacted'
CONSUMER_SECRET = 'redacted'
ACCESS_KEY = 'redacted'
ACCESS_SECRET = 'redacted'
cmd = 'date'
time = os.popen(cmd).readline().strip()
cmd = '/sbin/ifconfig wlan0 | grep -Po \'t addr:\K[\d.]+\''
ip = os.popen(cmd).readline().strip()
tweet = 'The date and time is: ' + time + ' and my current internal Wi-Fi IP address is: ' + ip
#print tweet
api.update_status(status = tweet)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment