rainbowstream icon indicating copy to clipboard operation
rainbowstream copied to clipboard

Running "home" shows "10 minutes ago", "1 hour ago" instead of time and date.

Open eivber opened this issue 7 years ago • 1 comments

I've done so that on login, an expect-script starts rainbowstream and runs the "home" command to display the latest tweets.

Its installed on an raspberry pi and connected to a monitor, and when rainbowstream is up and running, the tweets that is showed by the "home"-command is displayed with "10 minutes ago", "1 hour ago" instead of time and date.

The funny thing is that if I SSH into the raspberry, it will also run the expect script and then rainbowstream, but there it shows the whole time and date of the tweet.

Any explanation?

raspberry is set to auto-login

Code in .bashrc to run at login:

echo Starting FireWatch...
sleep 15
source venv/bin/activate
expect -f rainbowstream.exp

Code for expect script:

#!/usr/bin/expect -f

#The value of timeout must be an integral number of seconds. Normally timeouts $
set timeout 7200

# Now we start rainbowstream $
spawn rainbowstream

# Now we expect the twitter prompt to appear
expect "*Venter...*"

# And we write our home command to display latest tweets:
send -- "home 20"

# send blank line (\r) send command
send -- "\r"

#If twitter resets the connection
expect "*onnection reset*"

#Reconnect
spawn rainbowstream

#We have gave our "program" and now we expect that the remote server close the $
expect eof

.rainbow_config:

{
    // Turn to 'true' in order to disable extended tweets display (legacy mode)
    "DISABLE_EXTENDED_TWEETS" : false,
// After 120 minutes, the stream will automatically hangup
    "HEARTBEAT_TIMEOUT" : 500000,
    // Image on term
    "IMAGE_ON_TERM" : false,
    // Resize image to fit on terminal view
    "IMAGE_RESIZE_TO_FIT" : false,
    // Themes
    "THEME" : "monokai",
    // Ascii Art
    "ASCII_ART" : false,
    // Hide promt when receive a tweet
    "HIDE_PROMPT" : true,
    // Prefix
    "PREFIX" : "Venter...",
    // 'search': search type ('mixed','recent','popular')
    "SEARCH_TYPE" : "mixed",
    // 'search': search max result, number over 100 will fallback to 100
    "SEARCH_MAX_RECORD" : 5,
    // 'home': default number of home's tweets
    "HOME_TWEET_NUM" : 20,
    // 'allrt': default number of retweets
    "RETWEETS_SHOW_NUM" : 5,
    // 'conversation': max tweet in a thread
    "CONVERSATION_MAX" : 30,
    // 'quote' format
    "QUOTE_FORMAT" : "#comment https://twitter.com/#owner/status/#tid",
    // 'thread' meta format
    "THREAD_META_LEFT" : "(#id) #clock",
    "THREAD_META_RIGHT" : "#clock (#id)",
    // 'thread' frame's minimum width
    "THREAD_MIN_WIDTH" : 20,
    // 'Notification' format
    "NOTIFY_FORMAT" : "  #source_user #notify #clock",
    // 'inbox','sent': default number of direct message
    "MESSAGES_DISPLAY" : 5,
    // 'trend': max trending topics
    "TREND_MAX" : 10,
    // List home timeline max
    "LIST_MAX" : 5,
    // 'switch': Filter and Ignore list ex: ['@fat','@mdo']
    "ONLY_LIST" : [],
    "IGNORE_LIST" : [],
    // Autocomplete history file name
    "HISTORY_FILENAME" : "completer.hist",
    // Image margin
    "IMAGE_SHIFT" : 2,
    // Image max height
    "IMAGE_MAX_HEIGHT" : 90,
    // Seconds to wait before displaying another tweet, will drop all tweets while waiting.
    "STREAM_DELAY" : 0,
    // Stream config
    "USER_DOMAIN" : "userstream.twitter.com",
    "PUBLIC_DOMAIN" : "stream.twitter.com",
    "SITE_DOMAIN" : "sitestream.twitter.com",
    // Format
    "FORMAT": {
        "TWEET": {
            "CLOCK_FORMAT" : "%d/%m/%Y %H:%M:%S",
            "DISPLAY" : "\n  #name #clock \n  #fav\n  #tweet"
        },
        "MESSAGE": {
            "CLOCK_FORMAT" : "%Y/%m/%d %H:%M:%S",
            "DISPLAY" : "\n  #sender_name #sender_nick #to #recipient_name #recipient_nick :\n  #clock message_id:#id\n  #message"
        }
    },
    "POCKET_SUPPORT": false
}

eivber avatar Jun 22 '18 23:06 eivber

Looks like a bug to me. I change draw() in draw.py to have the default Parameter humanize be False:

def draw(t, keyword=None, humanize=False, noti=False, fil=[], ig=[]):

That did the trick for me. Seems that the parameter humanize is a bit misleading here. It is used inside as

clock = fallback_humanize(date, clock_format, not humanize)

which renames the parameter to use_fallback:

def fallback_humanize(date, fallback_format=None, use_fallback=False):

The usage of use_fallback now is straight forward:

    if not fallback_format:
        fallback_format = '%Y/%m/%d %H:%M:%S'
    # Determine using fallback format or not by a variable
    if use_fallback:
        return date.datetime.strftime(fallback_format)

Since I don't have the time to fix it, I did the hack above, which solves my problem: don't show any relative date-time.

RandomCore

RandomCore avatar May 07 '20 06:05 RandomCore