from functools import wraps
from pyfiglet import figlet_format
from dateutil import parser
+from tzlocal import get_localzone
from .c_image import *
from .colors import *
from .config import *
retweet_count = t['retweet_count']
favorite_count = t['favorite_count']
date = parser.parse(created_at)
- date = date - datetime.timedelta(seconds=time.timezone)
+ date = date.astimezone(get_localzone())
clock_format = '%Y/%m/%d %H:%M:%S'
try:
clock_format = c['FORMAT']['TWEET']['CLOCK_FORMAT']
tweet = text.split()
# Replace url
if expanded_url:
- for index in range(len(expanded_url)):
+ for index in xrange(len(expanded_url)):
tweet = lmap(
lambda x: expanded_url[index]
if x == url[index]
formater = ''
try:
formater = c['FORMAT']['TWEET']['DISPLAY']
- formater = name.join(formater.split("#name"))
- formater = nick.join(formater.split("#nick"))
- formater = fav.join(formater.split("#fav"))
- formater = tweet.join(formater.split("#tweet"))
+ formater = name.join(formater.split('#name'))
+ formater = nick.join(formater.split('#nick'))
+ formater = fav.join(formater.split('#fav'))
+ formater = tweet.join(formater.split('#tweet'))
# Change clock word
word = [w for w in formater.split() if '#clock' in w][0]
delimiter = color_func(c['TWEET']['clock'])(
recipient_name = m['recipient']['name']
mid = m['id']
date = parser.parse(m['created_at'])
- date = date - datetime.timedelta(seconds=time.timezone)
+ date = date.astimezone(get_localzone())
clock_format = '%Y/%m/%d %H:%M:%S'
try:
clock_format = c['FORMAT']['MESSAGE']['CLOCK_FORMAT']
location = 'Location : ' + color_func(c['PROFILE']['location'])(location)
url = 'URL : ' + (color_func(c['PROFILE']['url'])(url) if url else '')
date = parser.parse(created_at)
- date = date - datetime.timedelta(seconds=time.timezone)
+ date = date.astimezone(get_localzone())
clock = date.strftime('%Y/%m/%d %H:%M:%S')
clock = 'Join at ' + color_func(c['PROFILE']['clock'])(clock)
mode = color_func(c['GROUP']['mode'])('Type: ' + mode)
created_at = grp['created_at']
date = parser.parse(created_at)
- date = date - datetime.timedelta(seconds=time.timezone)
+ date = date.astimezone(get_localzone())
clock = date.strftime('%Y/%m/%d %H:%M:%S')
clock = 'Created at ' + color_func(c['GROUP']['clock'])(clock)
printNicely(' '.join(ary))
+def format_quote(tweet):
+ """
+ Quoting format
+ """
+ # Retrieve info
+ screen_name = '@' + tweet['user']['screen_name']
+ text = tweet['text']
+ # Validate quote format
+ if '#owner' not in c['QUOTE_FORMAT']:
+ printNicely(light_magenta('Quote should contains #owner'))
+ return False
+ if '#comment' not in c['QUOTE_FORMAT']:
+ printNicely(light_magenta('Quote format should have #comment'))
+ return False
+ # Build formater
+ formater = ''
+ try:
+ formater = c['QUOTE_FORMAT']
+ formater = screen_name.join(formater.split('#owner'))
+ formater = text.join(formater.split('#tweet'))
+ formater = u2str(formater)
+ except:
+ pass
+ # Highlight like a tweet
+ formater = formater.split()
+ formater = lmap(
+ lambda x: light_green(x)
+ if x == '#comment'
+ else x,
+ formater)
+ formater = lmap(
+ lambda x: color_func(c['TWEET']['rt'])(x)
+ if x == 'RT'
+ else x,
+ formater)
+ formater = lmap(lambda x: cycle_color(x) if x[0] == '@' else x, formater)
+ formater = lmap(
+ lambda x: color_func(c['TWEET']['link'])(x)
+ if x[0:4] == 'http'
+ else x,
+ formater)
+ formater = lmap(
+ lambda x: color_func(c['TWEET']['hashtag'])(x)
+ if x.startswith('#')
+ else x,
+ formater)
+ formater = ' '.join(formater)
+ # Notice
+ notice = light_magenta('Quoting: "') + formater + light_magenta('"')
+ printNicely(notice)
+ return formater
+
+
# Start the color cycle
start_cycle()