I am kind of new to Python and the Twython module. The tweets that my program is reading/printing out, are still limited to 140 characters rather than the newer 280 standard. I've read that you could possibly use tweet_mode=extended, however, I'm not sure where to apply this in my code, below:
Code: Select all
import cups
from twython import TwythonStreamer
#set up the printer
conn = cups.Connection()
printers = conn.getPrinters()
prin = conn.getDefault()
from auth import (
consumer_key,
consumer_secret,
access_token,
access_token_secret
)
class MyStreamer(TwythonStreamer):
def on_success(self, data):
if 'text' in data:
username = data['user']['screen_name']
tweet = data['text']
#Creates a text file and writes the tweet to that file
fout = open ("twitter.txt","w")
fout.write("@{}:\n".format(username))
fout.write("{}".format(tweet))
fout.close()
#Prints the text file
conn.printFile(prin, "/home/pi/twitter.txt"," ", {})
stream = MyStreamer(
consumer_key,
consumer_secret,
access_token,
access_token_secret
)
stream.statuses.filter(track='#overheard')