Skip to content
Snippets Groups Projects
whispers.py 804 B
Newer Older
  • Learn to ignore specific revisions
  • dnns01's avatar
    dnns01 committed
    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()