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

Log whispers for Haugebot

parent 54f3cea6
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,7 @@ from twitchio.ext.commands import Context, Bot
from vote_cog import VoteCog
from wusstest_du_schon import WusstestDuSchon
from wordcloud import Wordcloud
from whispers import Whispers
class HaugeBot(Bot, ABC):
......@@ -24,6 +25,7 @@ class HaugeBot(Bot, ABC):
self.add_cog(VoteCog(self))
self.add_cog(WusstestDuSchon(self))
self.add_cog(Wordcloud(self))
self.add_cog(Whispers(self))
@staticmethod
async def send_me(ctx, content):
......
import sqlite3
from datetime import datetime
from twitchio.ext import commands
class Whispers(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.Cog.event()
async def event_message(self, message):
# make sure the bot ignores itself and nightbot
if not message.author or message.author.name.lower() in [self.bot.NICK.lower(),
'nightbot'] or message.channel is not None:
return
conn = sqlite3.connect("db.sqlite3")
c = conn.cursor()
c.execute(
"INSERT INTO haugebot_web_whisper(author, content, received_at) VALUES (?, ?, ?)",
(message.author.name, message.content, datetime.now()))
conn.commit()
conn.close()
# Generated by Django 3.2.10 on 2021-12-22 09:49
import datetime
from django.db import migrations, models
import django
class Migration(migrations.Migration):
dependencies = [
('haugebot_web', '0006_auto_20211220_0048'),
]
operations = [
migrations.CreateModel(
name='Whisper',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('author', models.TextField(max_length=50)),
('content', models.TextField(max_length=500)),
('received_at', models.DateTimeField(default=django.utils.timezone.now)),
],
),
]
import os
from django.db import models
from django.utils import timezone
from haugebot_web import twitch_api
from .managers import TwitchUserManager
......@@ -62,3 +63,9 @@ class TwitchUser(models.Model):
return twitch_api.is_mod(self, broadcaster)
except TwitchUser.DoesNotExist:
return False
class Whisper(models.Model):
author = models.TextField(max_length=50)
content = models.TextField(max_length=500)
received_at = models.DateTimeField(default=timezone.now)
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