Ruff
This commit is contained in:
parent
59b7f4e392
commit
fafb64d57d
|
@ -1,7 +1,6 @@
|
||||||
|
import feedparser
|
||||||
import requests
|
import requests
|
||||||
import secret_loader
|
import secret_loader
|
||||||
import feedparser
|
|
||||||
from markdownify import markdownify
|
|
||||||
|
|
||||||
SESSION = requests.Session()
|
SESSION = requests.Session()
|
||||||
|
|
||||||
|
@ -9,23 +8,27 @@ secrets = secret_loader.SecretLoader()
|
||||||
WEBHOOK_URL = secrets.load_or_fail('WEBHOOK_URL')
|
WEBHOOK_URL = secrets.load_or_fail('WEBHOOK_URL')
|
||||||
FEED_URL = secrets.load_or_fail('FEED_URL')
|
FEED_URL = secrets.load_or_fail('FEED_URL')
|
||||||
|
|
||||||
|
|
||||||
def send_feed_notice(text: str):
|
def send_feed_notice(text: str):
|
||||||
app_message = {"text": text}
|
app_message = {'text': text}
|
||||||
message_headers = {"Content-Type": "application/json; charset=UTF-8"}
|
message_headers = {'Content-Type': 'application/json; charset=UTF-8'}
|
||||||
response = requests.post(
|
response = requests.post(
|
||||||
WEBHOOK_URL,
|
WEBHOOK_URL,
|
||||||
headers=message_headers,
|
headers=message_headers,
|
||||||
json=app_message,
|
json=app_message,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_feed():
|
def get_feed():
|
||||||
response = SESSION.get(FEED_URL)
|
response = SESSION.get(FEED_URL)
|
||||||
return feedparser.parse(response.text)
|
return feedparser.parse(response.text)
|
||||||
|
|
||||||
|
|
||||||
def get_seen_entry_ids() -> set[str]:
|
def get_seen_entry_ids() -> set[str]:
|
||||||
with open('output/entries_db.txt') as f:
|
with open('output/entries_db.txt') as f:
|
||||||
return f.read().split('\n')
|
return f.read().split('\n')
|
||||||
|
|
||||||
|
|
||||||
def mark_as_sent(entry_id: str):
|
def mark_as_sent(entry_id: str):
|
||||||
with open('output/entries_db.txt', 'a') as f:
|
with open('output/entries_db.txt', 'a') as f:
|
||||||
f.write(entry_id)
|
f.write(entry_id)
|
||||||
|
@ -47,5 +50,6 @@ def check_for_new_updates():
|
||||||
def main():
|
def main():
|
||||||
check_for_new_updates()
|
check_for_new_updates()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user