|
|
|
@ -1,7 +1,17 @@
|
|
|
|
|
from os import environ
|
|
|
|
|
|
|
|
|
|
import requests
|
|
|
|
|
import re
|
|
|
|
|
from bs4 import BeautifulSoup
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_accesstoken_from_file(accesstoken_path):
|
|
|
|
|
accesstoken_file = open(accesstoken_path, 'r')
|
|
|
|
|
single_accesstoken = accesstoken_file.read().strip()
|
|
|
|
|
accesstoken_file.close()
|
|
|
|
|
|
|
|
|
|
return single_accesstoken
|
|
|
|
|
def get_blog():
|
|
|
|
|
url = 'https://news.blizzard.com/en-us/'
|
|
|
|
|
html = requests.get(url).text
|
|
|
|
@ -60,6 +70,17 @@ def get_formatted_body(post):
|
|
|
|
|
'<p>'+post['description']+'</p>'
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
homeserver = environ['HOMESERVER_URL']
|
|
|
|
|
mxid = environ['MXID_PREFIX']
|
|
|
|
|
admin_room = environ['ADMIN_ROOM']
|
|
|
|
|
|
|
|
|
|
accesstoken = {}
|
|
|
|
|
for key in environ:
|
|
|
|
|
if (game := re.match('^ACCESSTOKEN_([A-Z]*)_FILE$', key)) is not None:
|
|
|
|
|
accesstoken[game[1].lower()] = get_accesstoken_from_file(environ[key])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
blog = get_blog()
|
|
|
|
|
for post in blog:
|
|
|
|
|
print(get_body(post))
|
|
|
|
|