Skip to content
Snippets Groups Projects
Commit b077bd1d authored by dnns01's avatar dnns01
Browse files

Fix wordcloud and change vote results to use twitch announcements

parent b724f67f
No related branches found
No related tags found
No related merge requests found
......@@ -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 = {}
......
......@@ -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',
]
......
......@@ -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 """
......
......@@ -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"""
......
......@@ -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 = {}
......
......@@ -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})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment