diff --git a/README.md b/README.md index 4f1e786..2418077 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Cog Function | forcemention | **Alpha** |
Mentions unmentionable rolesVery simple cog, mention doesn't persist
| | hangman | **Alpha** |
Play a game of hangmanSome visual glitches and needs more customization
| | howdoi | **Incomplete** |
Create temporary marks on users that expire after specified timeNot yet ported to v3
| -| leaver | **Incomplete** |
Send a message in a channel when a user leaves the serverNot yet ported to v3
| +| leaver | **Alpha** |
Send a message in a channel when a user leaves the serverJust released, please report bugs
| | lseen | **Alpha** |
Track when a member was last onlineAlpha release, please report bugs
| | reactrestrict | **Alpha** |
Removes reactions by role per channelA bit clunky, but functional
| | sayurl | **Alpha** |
Convert any URL into text and post to discordNo error checking and pretty spammy
| diff --git a/leaver/__init__.py b/leaver/__init__.py new file mode 100644 index 0000000..ed6689b --- /dev/null +++ b/leaver/__init__.py @@ -0,0 +1,5 @@ +from .leaver import Leaver + + +def setup(bot): + bot.add_cog(Leaver(bot)) diff --git a/leaver/info.json b/leaver/info.json index a1a44c3..08bef6f 100644 --- a/leaver/info.json +++ b/leaver/info.json @@ -1,9 +1,20 @@ { - "AUTHOR": "Bobloy", - "INSTALL_MSG": "Thank you for installing leaver", - "NAME": "Leaver", - "SHORT": "Sends message on leave", - "DESCRIPTION": "Keeps track of when people leave the server, and posts a message notifying", - "TAGS": ["fox", "bobloy", "utilities", "tools", "tool"], - "HIDDEN": false + "author": [ + "Bobloy" + ], + "bot_version": [ + 3, + 0, + 0 + ], + "description": "Keeps track of when people leave the server, and posts a message notifying", + "hidden": false, + "install_msg": "Thank you for installing Leaver. Get started with `[p]help Leaver`", + "requirements": [], + "short": "Send message on leave", + "tags": [ + "bobloy", + "utils", + "tools" + ] } \ No newline at end of file diff --git a/leaver/leaver.py b/leaver/leaver.py index 2aff2ac..6684a4a 100644 --- a/leaver/leaver.py +++ b/leaver/leaver.py @@ -1,10 +1,7 @@ import discord -import os -from datetime import datetime - -from .utils.dataIO import dataIO -from .utils import checks +from redbot.core import Config, checks, commands +from redbot.core.commands import Context class Leaver: @@ -12,67 +9,32 @@ class Leaver: def __init__(self, bot): self.bot = bot - self.path = "data/Fox-Cogs/leaver" - self.file_path = "data/Fox-Cogs/leaver/leaver.json" - self.the_data = dataIO.load_json(self.file_path) + self.config = Config.get_conf(self, identifier=9811198108111121, force_registration=True) + default_guild = { + "channel": '' + } - def save_data(self): - """Saves the json""" - dataIO.save_json(self.file_path, self.the_data) + self.config.register_guild(**default_guild) - @commands.group(aliases=['setleaver'], pass_context=True, no_pm=True) + @commands.group(aliases=['setleaver']) @checks.mod_or_permissions(administrator=True) async def leaverset(self, ctx): """Adjust leaver settings""" - - server = ctx.message.server - if server.id not in self.the_data: - self.the_data[server.id] = {} - self.save_data() - - if ctx.invoked_subcommand is None: - await self.bot.send_cmd_help(ctx) + await ctx.send_help() - @leaverset.command(pass_context=True, no_pm=True) - async def channel(self, ctx): - server = ctx.message.server - if 'CHANNEL' not in self.the_data[server.id]: - self.the_data[server.id]['CHANNEL'] = '' - + @leaverset.command() + async def channel(self, ctx: Context): + guild = ctx.guild + await self.config.guild(guild).channel.set(ctx.channel.id) + await ctx.send("Channel set to " + ctx.channel.name) - self.the_data[server.id]['CHANNEL'] = ctx.message.channel.id - self.save_data() - await self.bot.say("Channel set to "+ctx.message.channel.name) + async def when_leave(self, member: discord.Member): + server = member.guild + channel = await self.config.guild(server).channel() - async def when_leave(self, member): - server = member.server - if server.id in self.the_data: - await self.bot.send_message(server.get_channel(self.the_data[server.id]['CHANNEL']), - str(member) + "(*" + str(member.nick) +"*) has left the server!") + if channel != '': + channel = server.get_channel(channel) + await channel.send(str(member) + "(*" + str(member.nick) + "*) has left the server!") else: - await self.bot.send_message(server.default_channel.id, str(member) + " (*" + str(member.nick) +"*) has left the server!") - - -def check_folders(): - if not os.path.exists("data/Fox-Cogs"): - print("Creating data/Fox-Cogs folder...") - os.makedirs("data/Fox-Cogs") - - if not os.path.exists("data/Fox-Cogs/leaver"): - print("Creating data/Fox-Cogs/leaver folder...") - os.makedirs("data/Fox-Cogs/leaver") - - -def check_files(): - if not dataIO.is_valid_json("data/Fox-Cogs/leaver/leaver.json"): - dataIO.save_json("data/Fox-Cogs/leaver/leaver.json", {}) - - -def setup(bot): - check_folders() - check_files() - q = Leaver(bot) - bot.add_listener(q.when_leave, "on_member_remove") - bot.add_cog(q) - \ No newline at end of file + pass diff --git a/lseen/lseen.py b/lseen/lseen.py index 6cdf666..baf4133 100644 --- a/lseen/lseen.py +++ b/lseen/lseen.py @@ -10,7 +10,7 @@ from redbot.core import commands class LastSeen: """ - V3 Cog Template + Report when a user was last seen online """ online_status = discord.Status.online diff --git a/nudity/__init__.py b/nudity/__init__.py new file mode 100644 index 0000000..7d32df6 --- /dev/null +++ b/nudity/__init__.py @@ -0,0 +1,5 @@ +from .nudity import Nudity + + +def setup(bot): + bot.add_cog(Nudity(bot)) diff --git a/nudity/info..json b/nudity/info..json new file mode 100644 index 0000000..9f69325 --- /dev/null +++ b/nudity/info..json @@ -0,0 +1,20 @@ +{ + "author": [ + "Bobloy" + ], + "bot_version": [ + 3, + 0, + 0 + ], + "description": "Keep track of when users were last seen online", + "hidden": true, + "install_msg": "Thank you for installing LastSeen. Get started with `[p]help LastSeen`", + "requirements": [], + "short": "Last seen tracker", + "tags": [ + "bobloy", + "utils", + "tools" + ] +} \ No newline at end of file diff --git a/nudity/nudity.py b/nudity/nudity.py new file mode 100644 index 0000000..7df64f1 --- /dev/null +++ b/nudity/nudity.py @@ -0,0 +1,90 @@ +from datetime import datetime + +import dateutil.parser +import discord +from redbot.core import Config +from redbot.core import commands +from redbot.core.bot import Red + + +class Nudity: + """ + V3 Cog Template + """ + + online_status = discord.Status.online + + offline_status = discord.Status.offline + + def __init__(self, bot: Red): + self.bot = bot + self.config = Config.get_conf(self, identifier=9811198108111121, force_registration=True) + default_global = {} + default_guild = { + "enabled": True + } + default_member = { + "seen": None + } + + self.config.register_global(**default_global) + self.config.register_guild(**default_guild) + self.config.register_member(**default_member) + + @staticmethod + def get_date_time(s): + d = dateutil.parser.parse(s) + return d + + @commands.group(aliases=['setlseen'], name='lseenset') + async def lset(self, ctx: commands.Context): + """Change settings for lseen""" + if ctx.invoked_subcommand is None: + await ctx.send_help() + + @lset.command(name="toggle") + async def lset_toggle(self, ctx: commands.Context): + """Toggles tracking seen for this server""" + enabled = not await self.config.guild(ctx.guild).enabled() + await self.config.guild(ctx.guild).enabled.set( + enabled) + + await ctx.send( + "Seen for this server is now {}".format( + "Enabled" if enabled else "Disabled")) + + @commands.command(aliases=['lastseen']) + async def lseen(self, ctx: commands.Context, member: discord.Member): + """ + Just says the time the user was last seen + """ + + if member.status != self.offline_status: + last_seen = datetime.utcnow() + else: + last_seen = await self.config.member(member).seen() + if last_seen is None: + await ctx.send(embed=discord.Embed(description="I've never seen this user")) + return + last_seen = self.get_date_time(last_seen) + + # embed = discord.Embed( + # description="{} was last seen at this date and time".format(member.display_name), + # timestamp=self.get_date_time(last_seen)) + + embed = discord.Embed(timestamp=last_seen) + await ctx.send(embed=embed) + + # async def on_socket_raw_receive(self, data): + # try: + # if type(data) == str: + # raw = json.loads(data) + # print(data) + # except: + # print(data) + + async def on_member_update(self, before: discord.Member, after: discord.Member): + if before.status != self.offline_status and after.status == self.offline_status: + if not await self.config.guild(before.guild).enabled(): + return + await self.config.member(before).seen.set(datetime.utcnow().isoformat())