Skip to content
This repository has been archived by the owner on Feb 14, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2 from fellipec/Scarlett-Tweet
Browse files Browse the repository at this point in the history
Scarlett tweet
  • Loading branch information
fellipec authored Sep 11, 2022
2 parents f1b9d8f + 0ec18fa commit 79b92bc
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions tweetrndrss.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import sqlite3
import ssl
import requests
import datetime

#Contorno para erros do SSL com o feedparser
#Workarround to SSL errors with feedparser
Expand All @@ -22,10 +23,26 @@
#Global definitions
FeedURL = "https://www.reddit.com/r/ScarlettJohansson/.rss"
TweetMessage = 'Scarlett! \n'
useToD = True
TweetMorning = 'Scarlett passando para desejar um bom dia\n\n'
TweetAfternoon = 'Scarlett passando para desejar uma boa tarde\n\n'
TweetEvening = 'Scarlett passando para desejar uma boa noite\n\n'
TweetSize = 200
useImage = True
imageFile = 'scarlett.jpg'

#Mensagem variável conforme a hora do dia
#Message changing with time of day
if useToD:
currentTime = datetime.datetime.now()
if currentTime.hour < 12:
TweetMessage = TweetMorning
elif 12 <= currentTime.hour < 18:
TweetMessage = TweetAfternoon
else:
TweetMessage = TweetEvening


#Inicialização do Banco de Dados
#Database init
conn = sqlite3.connect('rss.db')
Expand Down Expand Up @@ -68,7 +85,7 @@

#Gera um Tuite com o título e URL do artigo
#Generates the Tweet
TweetText = TweetMessage + article[1]
TweetText = TweetMessage # + article[1]
TweetText = TweetText[0:TweetSize-len(article[0])] + " " + article[0]
print(TweetText)

Expand All @@ -93,4 +110,4 @@

#Fecha o banco de dados
conn.commit()
conn.close()
conn.close()

0 comments on commit 79b92bc

Please sign in to comment.