File size: 2,202 Bytes
f5e2b6b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import discord
from discord.ext import commands
from ChatAI.chat_ai import pipe as ai

# Set up Discord bot intents and command prefix
intents = discord.Intents.default()
intents.message_content = True
intents.messages = True
bot = commands.Bot(command_prefix="!", intents=intents)

# Dictionary to track message count per channel
message_counts = {}

@bot.event
async def on_message(message):
    guild = message.guild  # Get the guild (server) the message is from
    channel = message.channel
    if message.channel != discord.utils.get(guild.text_channels, name="ai_chatter"):
        print("not ai_chatter channel"); return;
    print("channel: ai_chatter")

    if message.author.bot:
        print("not taking own messages into count"); return;

    if message.author.name!="sandra_n": pass;
    print("I can see its you, sis"); await message.channel.send("I can see its you, sis")

    if message.channel.id not in message_counts: # Ensure tracking exists for this channel
        message_counts[message.channel.id] = 0

    message_counts[message.channel.id] += 1 # Increment message count
    print(message_counts[message.channel.id])

    messages = []
    if message_counts[message.channel.id] >= 4: # Check if the count reaches 10
        async for message in channel.history(limit=4):
            messages.append(message.content)

            await message.channel.send("\n".join(messages))


        message_counts[message.channel.id] = 0 # Reset the counter


    await bot.process_commands(message) # Ensure commands still work

@bot.event
async def on_ready():
    print(f'Logged in as {bot.user}')  # Logs bot login in console

    guild = discord.utils.get(bot.guilds, name="PrzebieralniaKoedukacyjna")
    if guild:
        # Get the channel by name
        channel = discord.utils.get(guild.channels, name="ai_chatter")  # Replace "general" with your channel name
        if channel:
            print(f"Channel found: {channel.name} (ID: {channel.id})")
        else:
            print("Channel not found!")

        await channel.send(f"{bot.user} logged in, runnin on 'huggingface.co/spaces")

bot.run("MTMzODQ4NTY2MzY3MDA3OTQ4OA.GlmK1T.7ZeEiDz7ViY3zvuSqlacVocDMSZ-ln80c09AS4")