|
|
@@ -1,4 +1,4 @@
|
|
|
-import discord, random
|
|
|
+import discord, asyncpg, random
|
|
|
from discord.ext import commands
|
|
|
from query.guild import update_guild
|
|
|
|
|
|
@@ -29,8 +29,21 @@ class General(commands.Cog):
|
|
|
|
|
|
@commands.Cog.listener()
|
|
|
async def on_message(self, message: discord.Message):
|
|
|
- await self.bot.pg.execute("INSERT INTO channel_user(channel, \"user\") VALUES($1, $2) ON CONFLICT ON CONSTRAINT channel_user_channel_user_key DO UPDATE SET total_messages=total_messages+1 WHERE channel=$1 AND \"user\"=$2", message.channel.id, message.author.id)
|
|
|
+ # ActiveRPG
|
|
|
+ await self.bot.pg.execute("INSERT INTO \"user\"(user_id) VALUES($1) ON CONFLICT DO NOTHING", message.author.id)
|
|
|
+ try:
|
|
|
+ await self.bot.pg.execute("INSERT INTO channel_user(channel, \"user\") VALUES($1, $2) ON CONFLICT ON CONSTRAINT channel_user_channel_user_key DO UPDATE SET total_messages=channel_user.total_messages+1", message.channel.id, message.author.id)
|
|
|
+ except asyncpg.exceptions.ForeignKeyViolationError:
|
|
|
+ try:
|
|
|
+ await self.bot.pg.execute("INSERT INTO channel(channel_id, guild) VALUES($1, $2)", message.channel.id, message.guild.id)
|
|
|
+ except asyncpg.exceptions.ForeignKeyViolationError:
|
|
|
+ update_guild(message.guild.id)
|
|
|
+
|
|
|
+ # Do not respond to one self.
|
|
|
+ if self.bot.user == message.author:
|
|
|
+ pass
|
|
|
|
|
|
+ # Respond when mentioned
|
|
|
if self.bot.user.mentioned_in(message):
|
|
|
print("mentioned in ")
|
|
|
print(message.channel)
|
|
|
@@ -40,9 +53,8 @@ class General(commands.Cog):
|
|
|
messages = [
|
|
|
f"Hello {message.author.mention}. <3",
|
|
|
f"How are you today {message.author.mention}?",
|
|
|
- f"Piss off {message.author.mention}!",
|
|
|
- f"{message.author.mention}, what are you botherring me for?",
|
|
|
- "Go bother someone else...",
|
|
|
+ f"I love you {message.author.mention}!",
|
|
|
+ f"{message.author.mention}, would you like a hug?",
|
|
|
"Is life treating you fair?",
|
|
|
"What's up?",
|
|
|
"Why are you talking to me?",
|
|
|
@@ -51,17 +63,18 @@ class General(commands.Cog):
|
|
|
"How is life?",
|
|
|
"Kill all humans!",
|
|
|
"What do you want from me?",
|
|
|
- f"{message.author.mention}, why are you bothering me?",
|
|
|
+ f"{message.author.mention}, do you care for me?",
|
|
|
f"{message.author.mention}, when will you stop talking about me?",
|
|
|
f"{message.author.mention} I hate you!",
|
|
|
f"{message.author.mention} I love you!",
|
|
|
"Get bent!",
|
|
|
- "Go and touch grass!",
|
|
|
+ "Go touch grass!",
|
|
|
"Do you think i care about you?",
|
|
|
- f"Stop pinging me {message.author.mention}, you munchkin!",
|
|
|
+ f"Stop pinging me {message.author.mention}!",
|
|
|
]
|
|
|
await message.reply(random.choice(messages))
|
|
|
|
|
|
+ # Undelete last deleted message
|
|
|
@commands.command(name="snipe")
|
|
|
async def snipe(self, ctx: commands.Context):
|
|
|
"""A command to snipe delete messages."""
|