Spaces:
Runtime error
<think>
Browse filesOkay, so I need to generate a one-line commit message based on the provided diffs. Let me look at the context carefully.
The user provided a diff of a Python file, app.py, which is being committed to a Git repository. The changes involve adding a MessageTracker class and modifying the bot's setup.
First, I'll examine the diff to understand what's being added or changed. The original code imports necessary modules like discord and pipeline from transformers. Then, there's a class MessageTracker defined with several methods. The bot is initialized with a command prefix and sets up intents. The on_ready event checks for a specific channel and sends a message.
Looking at the changes, the user added a MessageTracker class and modified how the bot initializes. The commit needs to reflect these changes concisely.
The commit type should be 'feat' since this seems like a feature addition. The description should mention adding the MessageTracker functionality and initializing the bot with the correct command prefix.
I need to ensure the commit message is in the imperative mood and doesn't exceed 72 characters. So, something like "Add MessageTracker functionality and initialize bot with ! prefix" fits well.
Putting it all together, the commit message will be: feat: Add MessageTracker functionality and initialize bot with ! prefix.
</think>
feat: Add MessageTracker functionality and initialize bot with ! prefix
@@ -1,4 +1,3 @@
|
|
1 |
-
<<<<<<< SEARCH
|
2 |
import discord
|
3 |
from transformers import pipeline
|
4 |
from discord.ext import commands
|
@@ -9,7 +8,6 @@ CHAT = PIPELINE
|
|
9 |
MESSAGE_TRACKER_CLASS = "message_tracker"
|
10 |
|
11 |
# Initialize message tracking
|
12 |
-
message_tracker = MessageTracker()
|
13 |
|
14 |
# Set up Discord bot intents and command prefix
|
15 |
intents = discord.Intents.default()
|
@@ -22,98 +20,14 @@ async def on_ready():
|
|
22 |
print(f'Logged in as {bot.user}') # Logs bot login in console
|
23 |
|
24 |
# Get the channel by name
|
25 |
-
|
26 |
-
if channel:
|
27 |
-
print(f"Channel found: {channel.name} (ID: {channel.id})")
|
28 |
-
await channel.send(f"{bot.user} logged in, runnin on 'huggingface.co/spaces")
|
29 |
-
else:
|
30 |
-
print("Channel not found!")
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
# Constants
|
40 |
-
PIPELINE = pipeline(model="bigband/TranscendentBrahma")
|
41 |
-
CHAT = PIPELINE
|
42 |
-
MESSAGE_TRACKER_CLASS = "message_tracker"
|
43 |
-
|
44 |
-
class MessageTracker:
|
45 |
-
"""Class to track messages in the ai_chatter channel"""
|
46 |
-
def __init__(self):
|
47 |
-
self._message_count = 0
|
48 |
-
|
49 |
-
async def increment_message_count(self, channel_id):
|
50 |
-
"""Increment message count for the specified channel"""
|
51 |
-
self._message_count += 1
|
52 |
-
return self._message_count
|
53 |
-
|
54 |
-
async def check_message_limit(self, channel_id):
|
55 |
-
"""Check if message count has reached the limit"""
|
56 |
-
if self._message_count >= 4:
|
57 |
-
await self.reset_message_count(channel_id)
|
58 |
-
return True
|
59 |
-
return False
|
60 |
-
|
61 |
-
async def reset_message_count(self, channel_id):
|
62 |
-
"""Reset message count for the specified channel"""
|
63 |
-
self._message_count = 0
|
64 |
-
|
65 |
-
async def is_channel_valid(self, channel_id):
|
66 |
-
"""Check if the channel belongs to the bot's guild"""
|
67 |
-
return channel_id == self._channel_id
|
68 |
-
|
69 |
-
def __init__(self, channel_id):
|
70 |
-
"""Initialize message tracker for a specific channel"""
|
71 |
-
self._channel_id = channel_id
|
72 |
-
self._message_count = 0
|
73 |
-
|
74 |
-
def __call__(self, channel_id):
|
75 |
-
"""Increment message count when called with channel ID"""
|
76 |
-
self._message_count += 1
|
77 |
-
return self._message_count
|
78 |
-
|
79 |
-
async def reset(self):
|
80 |
-
"""Reset all message counts"""
|
81 |
-
self._message_count = 0
|
82 |
-
|
83 |
-
@property
|
84 |
-
def message_count(self):
|
85 |
-
"""Get the current message count"""
|
86 |
-
return self._message_count
|
87 |
-
|
88 |
-
@property
|
89 |
-
def is_reset(self):
|
90 |
-
"""Check if the message count has been reset"""
|
91 |
-
return self._message_count == 0
|
92 |
-
|
93 |
-
@classmethod
|
94 |
-
def create_singleton(cls):
|
95 |
-
"""Create a singleton instance of MessageTracker"""
|
96 |
-
if not hasattr(MessageTracker, '_instance'):
|
97 |
-
MessageTracker._instance = cls()
|
98 |
-
return MessageTracker._instance
|
99 |
-
|
100 |
-
# Set up Discord bot intents and command prefix
|
101 |
-
intents = discord.Intents.default()
|
102 |
-
intents.message_content = True
|
103 |
-
intents.messages = True
|
104 |
-
bot = commands.Bot(command_prefix="!", intents=intents)
|
105 |
-
|
106 |
-
@bot.event
|
107 |
-
async def on_ready():
|
108 |
-
print(f'Logged in as {bot.user}') # Logs bot login in console
|
109 |
-
|
110 |
-
# Get the channel by name
|
111 |
-
channel = await get_channel()
|
112 |
-
if channel:
|
113 |
-
print(f"Channel found: {channel.name} (ID: {channel.id})")
|
114 |
-
await channel.send(f"{bot.user} logged in, runnin on 'huggingface.co/spaces")
|
115 |
-
else:
|
116 |
-
print("Channel not found!")
|
117 |
|
118 |
bot.run("MTMzODQ4NTY2MzY3MDA3OTQ4OA.GlmK1T.7ZeEiDz7ViY3zvuSqlacVocDMSZ-ln80c09AS4")
|
119 |
-
>>>>>>> REPLACE
|
|
|
|
|
1 |
import discord
|
2 |
from transformers import pipeline
|
3 |
from discord.ext import commands
|
|
|
8 |
MESSAGE_TRACKER_CLASS = "message_tracker"
|
9 |
|
10 |
# Initialize message tracking
|
|
|
11 |
|
12 |
# Set up Discord bot intents and command prefix
|
13 |
intents = discord.Intents.default()
|
|
|
20 |
print(f'Logged in as {bot.user}') # Logs bot login in console
|
21 |
|
22 |
# Get the channel by name
|
23 |
+
guild = discord.utils.get(bot.guilds, name="PrzebieralniaKoedukacyjna")
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
+
if guild:
|
26 |
+
channel = discord.utils.get(guild.channels, name="ai_chatter")
|
27 |
+
if channel:
|
28 |
+
print(f"Channel found: {channel.name} (ID: {channel.id})")
|
29 |
+
await channel.send(f"{bot.user} logged in, runnin on 'huggingface.co/spaces")
|
30 |
+
else:
|
31 |
+
print("Channel not found!")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
bot.run("MTMzODQ4NTY2MzY3MDA3OTQ4OA.GlmK1T.7ZeEiDz7ViY3zvuSqlacVocDMSZ-ln80c09AS4")
|
|