-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
38 lines (27 loc) · 1023 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import sys
import core
from BotAuth import DataBot
if __name__ == '__main__':
# verificar versao do python
if sys.version_info[0] < 3 or sys.version_info[1] < 6:
sys.exit('Este algoritmo requer uma versao do python 3.6 ou superior!')
print('[CORE] Iniciando algoritmo ...')
URLS = [
'http://portal.uern.br/blog/category/noticias/feed/',
'https://aduern.org.br/category/noticias/feed/'
]
token, chatId = DataBot.readJson()
database = core.Database(sizeHistory=len(URLS)*100)
files = core.downloadXML(URLS)
if len(files) > 0:
analyze = core.AnalyzeRSS(filenames=files)
datas = analyze.getData()
database.add(datas)
messages = database.getWaitingMessages()
bot = core.BotTelegram(token, chatId)
for message in messages:
messageToSend = message['title'] + '\n' + message['link']
if bot.sendMessage(messageToSend):
database.removeFromWaitList(message)
else:
print('Error')