diff --git a/haugebot/consumers.py b/haugebot/consumers.py index ce7c24ec3679cb743f0b9a438703461f8ea9bc0c..d881972dd9425dea8acc0e42d6b3d06f44a55ddc 100644 --- a/haugebot/consumers.py +++ b/haugebot/consumers.py @@ -4,6 +4,9 @@ import os from asgiref.sync import async_to_sync from channels.generic.websocket import WebsocketConsumer from wordcloud import WordCloud +from dotenv import load_dotenv + +load_dotenv() secret = os.getenv("WORDCLOUD_SECRET") words = {} diff --git a/haugebot/settings.py b/haugebot/settings.py index 07a88fef55508d34e95ae9d8492635f0670819b8..1947db986bf4982df87a7606f68638cff82d450a 100644 --- a/haugebot/settings.py +++ b/haugebot/settings.py @@ -31,6 +31,8 @@ DEBUG = os.getenv("DJANGO_DEBUG") == "True" ALLOWED_HOSTS = [os.getenv("DJANGO_ALLOWED_HOST1"), os.getenv("DJANGO_ALLOWED_HOST2"), "127.0.0.1"] +CSRF_TRUSTED_ORIGINS = ["https://" + os.getenv("DJANGO_ALLOWED_HOST2")] + AUTHENTICATION_BACKENDS = [ 'haugebot_web.auth.TwitchAuthenticationBackend', ] diff --git a/haugebot_twitch/haugebot.py b/haugebot_twitch/haugebot.py index a13dd5ee63fd22a612a59d6d6d395877665eaf1c..fb1785bf99be47d084e585715208aed78c4601bd 100644 --- a/haugebot_twitch/haugebot.py +++ b/haugebot_twitch/haugebot.py @@ -27,6 +27,15 @@ class HaugeBot(Bot, ABC): self.add_cog(Wordcloud(self)) self.add_cog(Whispers(self)) + @staticmethod + async def send_announce(ctx, content): + """ Change Text color to color and send content as message """ + + if type(ctx) is Context or type(ctx) is Channel: + await ctx.send(f".announce {content}") + elif type(ctx) is Message: + await ctx.channel.send(f".announce {content}") + @staticmethod async def send_me(ctx, content): """ Change Text color to color and send content as message """ diff --git a/haugebot_twitch/vote_cog.py b/haugebot_twitch/vote_cog.py index 9a3d7ecde8a943a087ed745d02745a0e3022da1b..c420e82ffcdbe93e5f3b7c7efe2e3b7d7daad115 100644 --- a/haugebot_twitch/vote_cog.py +++ b/haugebot_twitch/vote_cog.py @@ -47,7 +47,7 @@ class VoteCog(commands.Cog): output += f'Endergebnis' if final_result else f'Zwischenergebnis' output += f' mit insgesamt {len(self.votes)} abgegebenen Stimmen' - await self.bot.send_me(message, output) + await self.bot.send_announce(message, output) def get_votes(self): """analyzes the votes-dict and counts the votes""" diff --git a/haugebot_twitch/wordcloud.py b/haugebot_twitch/wordcloud.py index c80e67708e8a86f710d9772ef20e3d7e269eb8c1..f0c0f1e7a926e44f3ac20fe4200f2bfc7502007c 100644 --- a/haugebot_twitch/wordcloud.py +++ b/haugebot_twitch/wordcloud.py @@ -57,8 +57,8 @@ class Wordcloud(commands.Cog): else: self.running = False else: - # self.words[ctx.author.name] = phrase - self.words[phrase] = phrase + self.words[ctx.author.name] = phrase + # self.words[phrase] = phrase def sum_words(self): words = {} diff --git a/haugebot_web/views.py b/haugebot_web/views.py index 6befda5588da42ca52e24097badbdec9fd1f224f..c8c99993fa54080af7172a7ae868552413162fa8 100644 --- a/haugebot_web/views.py +++ b/haugebot_web/views.py @@ -21,7 +21,7 @@ def home(request): @login_required(login_url="/login") def wordcloud(request): id = os.getenv("DJANGO_WORDCLOUD_LIVE_ID") - host = os.getenv("DJANGO_ALLOWED_HOST1") + host = os.getenv("DJANGO_ALLOWED_HOST2") embed_link = f"{request.scheme}://{host}{reverse('wordcloud_live', args=(id,))}" if request.user.is_broadcaster else "" return render(request, "wordcloud.html", {'title': 'Wordcloud', "ws_url": os.getenv("WORDCLOUD_WS_URL"), "session_key": request.session.session_key, "embed_link": embed_link})