jstacy00
Posts: 6
Joined: Wed Dec 12, 2018 9:51 pm
Location: Indiana, US

Extended Tweets in Twython

Mon Apr 29, 2019 6:09 pm

Hi,

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')
Could I get a little help with this. Thanks!

User avatar
DougieLawson
Posts: 39304
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Extended Tweets in Twython

Mon Apr 29, 2019 6:24 pm

Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

jstacy00
Posts: 6
Joined: Wed Dec 12, 2018 9:51 pm
Location: Indiana, US

Re: Extended Tweets in Twython

Mon Apr 29, 2019 7:12 pm

Thanks! I went ahead and added it to the last line. However I'm still only getting 140 characters. Did I put it in the wrong place?

Code: Select all

stream.statuses.filter(track='#overheard', tweet_mode='extended')
thanks again.

User avatar
DougieLawson
Posts: 39304
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Extended Tweets in Twython

Mon Apr 29, 2019 9:01 pm

I don't know. Post a new issue on GitHub and the code author(s) can help.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

jstacy00
Posts: 6
Joined: Wed Dec 12, 2018 9:51 pm
Location: Indiana, US

Re: Extended Tweets in Twython

Tue Apr 30, 2019 1:07 pm

will do. Thanks!

Return to “Python”