Assorted QoL updates
This commit is contained in:
parent
813ca2eb67
commit
273e622fa7
@ -2,7 +2,6 @@ import asyncio
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
|
|
||||||
from redbot.core import Config, checks
|
from redbot.core import Config, checks
|
||||||
from redbot.core import commands
|
from redbot.core import commands
|
||||||
from redbot.core.utils.chat_formatting import pagify, box
|
from redbot.core.utils.chat_formatting import pagify, box
|
||||||
@ -191,7 +190,7 @@ class CCRole:
|
|||||||
"""Shows custom commands list"""
|
"""Shows custom commands list"""
|
||||||
guild = ctx.guild
|
guild = ctx.guild
|
||||||
cmd_list = await self.config.guild(guild).cmdlist()
|
cmd_list = await self.config.guild(guild).cmdlist()
|
||||||
cmd_list = {k: v for k,v in cmd_list.items() if v}
|
cmd_list = {k: v for k, v in cmd_list.items() if v}
|
||||||
if not cmd_list:
|
if not cmd_list:
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
"There are no custom commands in this server. Use `{}ccrole add` to start adding some.".format(
|
"There are no custom commands in this server. Use `{}ccrole add` to start adding some.".format(
|
||||||
|
@ -2,7 +2,6 @@ import asyncio
|
|||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
|
|
||||||
from redbot.core import Config
|
from redbot.core import Config
|
||||||
from redbot.core import commands
|
from redbot.core import commands
|
||||||
|
|
||||||
@ -10,7 +9,6 @@ from chatter.chatterbot import ChatBot
|
|||||||
from chatter.chatterbot.trainers import ListTrainer
|
from chatter.chatterbot.trainers import ListTrainer
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Chatter:
|
class Chatter:
|
||||||
"""
|
"""
|
||||||
This cog trains a chatbot that will talk like members of your Guild
|
This cog trains a chatbot that will talk like members of your Guild
|
||||||
@ -99,7 +97,8 @@ class Chatter:
|
|||||||
Backup your training data to a json for later use
|
Backup your training data to a json for later use
|
||||||
"""
|
"""
|
||||||
await ctx.send("Backing up data, this may take a while")
|
await ctx.send("Backing up data, this may take a while")
|
||||||
future = await self.loop.run_in_executor(None, self.chatbot.trainer.export_for_training, './{}.json'.format(backupname))
|
future = await self.loop.run_in_executor(None, self.chatbot.trainer.export_for_training,
|
||||||
|
'./{}.json'.format(backupname))
|
||||||
|
|
||||||
if future:
|
if future:
|
||||||
await ctx.send("Backup successful!")
|
await ctx.send("Backup successful!")
|
||||||
@ -142,7 +141,6 @@ class Chatter:
|
|||||||
author = message.author
|
author = message.author
|
||||||
channel = message.channel
|
channel = message.channel
|
||||||
|
|
||||||
|
|
||||||
if message.author.id != self.bot.user.id:
|
if message.author.id != self.bot.user.id:
|
||||||
to_strip = "@" + author.guild.me.display_name + " "
|
to_strip = "@" + author.guild.me.display_name + " "
|
||||||
text = message.clean_content
|
text = message.clean_content
|
||||||
|
@ -158,7 +158,9 @@ class StorageAdapter(object):
|
|||||||
class EmptyDatabaseException(Exception):
|
class EmptyDatabaseException(Exception):
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
value='The database currently contains no entries. At least one entry is expected. You may need to train your chat bot to populate your database.'):
|
value='The database currently contains no entries. '
|
||||||
|
'At least one entry is expected. '
|
||||||
|
'You may need to train your chat bot to populate your database.'):
|
||||||
self.value = value
|
self.value = value
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
import discord
|
import discord
|
||||||
|
|
||||||
from redbot.core import Config, checks
|
|
||||||
|
|
||||||
from redbot.core.bot import Red
|
|
||||||
|
|
||||||
from pylint import epylint as lint
|
from pylint import epylint as lint
|
||||||
|
from redbot.core import Config
|
||||||
from redbot.core import commands
|
from redbot.core import commands
|
||||||
|
from redbot.core.bot import Red
|
||||||
from redbot.core.data_manager import cog_data_path
|
from redbot.core.data_manager import cog_data_path
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,10 +2,9 @@ from collections import defaultdict
|
|||||||
from random import randint
|
from random import randint
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
|
|
||||||
from redbot.core import Config, checks
|
from redbot.core import Config, checks
|
||||||
from redbot.core import commands
|
from redbot.core import commands
|
||||||
from redbot.core.data_manager import cog_data_path, load_basic_configuration
|
from redbot.core.data_manager import cog_data_path
|
||||||
|
|
||||||
|
|
||||||
class Hangman:
|
class Hangman:
|
||||||
@ -26,7 +25,7 @@ class Hangman:
|
|||||||
lambda: {"running": False, "hangman": 0, "guesses": [], "trackmessage": False, "answer": ''})
|
lambda: {"running": False, "hangman": 0, "guesses": [], "trackmessage": False, "answer": ''})
|
||||||
self.path = str(cog_data_path(self)).replace('\\', '/')
|
self.path = str(cog_data_path(self)).replace('\\', '/')
|
||||||
|
|
||||||
self.answer_path = self.path+"/bundled_data/hanganswers.txt"
|
self.answer_path = self.path + "/bundled_data/hanganswers.txt"
|
||||||
|
|
||||||
self.winbool = defaultdict(lambda: False)
|
self.winbool = defaultdict(lambda: False)
|
||||||
|
|
||||||
@ -331,4 +330,3 @@ class Hangman:
|
|||||||
|
|
||||||
await self._reactmessage_menu(message)
|
await self._reactmessage_menu(message)
|
||||||
await self._checkdone(channel)
|
await self._checkdone(channel)
|
||||||
|
|
||||||
|
@ -58,8 +58,6 @@ class LastSeen:
|
|||||||
async def lseen(self, ctx: commands.Context, member: discord.Member):
|
async def lseen(self, ctx: commands.Context, member: discord.Member):
|
||||||
"""
|
"""
|
||||||
Just says the time the user was last seen
|
Just says the time the user was last seen
|
||||||
|
|
||||||
:param member:
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if member.status != self.offline_status:
|
if member.status != self.offline_status:
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
import asyncio
|
|
||||||
from typing import List, Union
|
from typing import List, Union
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
|
|
||||||
|
|
||||||
from redbot.core import Config
|
from redbot.core import Config
|
||||||
from redbot.core.bot import Red
|
|
||||||
from redbot.core import commands
|
from redbot.core import commands
|
||||||
|
from redbot.core.bot import Red
|
||||||
|
|
||||||
|
|
||||||
class ReactRestrictCombo:
|
class ReactRestrictCombo:
|
||||||
@ -16,8 +13,8 @@ class ReactRestrictCombo:
|
|||||||
|
|
||||||
def __eq__(self, other: "ReactRestrictCombo"):
|
def __eq__(self, other: "ReactRestrictCombo"):
|
||||||
return (
|
return (
|
||||||
self.message_id == other.message_id and
|
self.message_id == other.message_id and
|
||||||
self.role_id == other.role_id
|
self.role_id == other.role_id
|
||||||
)
|
)
|
||||||
|
|
||||||
def to_json(self):
|
def to_json(self):
|
||||||
@ -83,7 +80,7 @@ class ReactRestrict:
|
|||||||
"""
|
"""
|
||||||
# is_custom = True
|
# is_custom = True
|
||||||
# if isinstance(emoji, str):
|
# if isinstance(emoji, str):
|
||||||
# is_custom = False
|
# is_custom = False
|
||||||
|
|
||||||
combo = ReactRestrictCombo(message_id, role.id)
|
combo = ReactRestrictCombo(message_id, role.id)
|
||||||
|
|
||||||
@ -95,10 +92,10 @@ class ReactRestrict:
|
|||||||
|
|
||||||
async def remove_react(self, message_id: int, role: discord.Role):
|
async def remove_react(self, message_id: int, role: discord.Role):
|
||||||
"""
|
"""
|
||||||
Removes a given reaction.
|
Removes a given reaction
|
||||||
|
|
||||||
:param int message_id:
|
:param message_id:
|
||||||
:param str or int emoji:
|
:param role:
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
current_combos = await self.combo_list()
|
current_combos = await self.combo_list()
|
||||||
@ -109,14 +106,13 @@ class ReactRestrict:
|
|||||||
if to_keep != current_combos:
|
if to_keep != current_combos:
|
||||||
await self.set_combo_list(to_keep)
|
await self.set_combo_list(to_keep)
|
||||||
|
|
||||||
async def has_reactrestrict_combo(self, message_id: int)\
|
async def has_reactrestrict_combo(self, message_id: int) \
|
||||||
-> (bool, List[ReactRestrictCombo]):
|
-> (bool, List[ReactRestrictCombo]):
|
||||||
"""
|
"""
|
||||||
Determines if there is an existing role combo for a given message
|
Determines if there is an existing role combo for a given message
|
||||||
and emoji ID.
|
and emoji ID.
|
||||||
|
|
||||||
:param int message_id:
|
:param message_id:
|
||||||
:param str or int emoji:
|
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
if not await self.is_registered(message_id):
|
if not await self.is_registered(message_id):
|
||||||
@ -169,8 +165,8 @@ class ReactRestrict:
|
|||||||
raise LookupError("No role found.")
|
raise LookupError("No role found.")
|
||||||
|
|
||||||
return role
|
return role
|
||||||
|
|
||||||
async def _get_message_from_channel(self, channel_id: int, message_id: int)\
|
async def _get_message_from_channel(self, channel_id: int, message_id: int) \
|
||||||
-> Union[discord.Message, None]:
|
-> Union[discord.Message, None]:
|
||||||
"""
|
"""
|
||||||
Tries to find a message by ID in the current guild context.
|
Tries to find a message by ID in the current guild context.
|
||||||
@ -180,12 +176,12 @@ class ReactRestrict:
|
|||||||
return await channel.get_message(message_id)
|
return await channel.get_message(message_id)
|
||||||
except discord.NotFound:
|
except discord.NotFound:
|
||||||
pass
|
pass
|
||||||
except AttributeError: # VoiceChannel object has no attribute 'get_message'
|
except AttributeError: # VoiceChannel object has no attribute 'get_message'
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
async def _get_message(self, ctx: commands.Context, message_id: int)\
|
async def _get_message(self, ctx: commands.Context, message_id: int) \
|
||||||
-> Union[discord.Message, None]:
|
-> Union[discord.Message, None]:
|
||||||
"""
|
"""
|
||||||
Tries to find a message by ID in the current guild context.
|
Tries to find a message by ID in the current guild context.
|
||||||
@ -199,12 +195,10 @@ class ReactRestrict:
|
|||||||
return await channel.get_message(message_id)
|
return await channel.get_message(message_id)
|
||||||
except discord.NotFound:
|
except discord.NotFound:
|
||||||
pass
|
pass
|
||||||
except AttributeError: # VoiceChannel object has no attribute 'get_message'
|
except AttributeError: # VoiceChannel object has no attribute 'get_message'
|
||||||
pass
|
pass
|
||||||
except discord.Forbidden: # No access to channel, skip
|
except discord.Forbidden: # No access to channel, skip
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -228,18 +222,18 @@ class ReactRestrict:
|
|||||||
return
|
return
|
||||||
|
|
||||||
# try:
|
# try:
|
||||||
# emoji, actual_emoji = await self._wait_for_emoji(ctx)
|
# emoji, actual_emoji = await self._wait_for_emoji(ctx)
|
||||||
# except asyncio.TimeoutError:
|
# except asyncio.TimeoutError:
|
||||||
# await ctx.send("You didn't respond in time, please redo this command.")
|
# await ctx.send("You didn't respond in time, please redo this command.")
|
||||||
# return
|
# return
|
||||||
|
#
|
||||||
# try:
|
# try:
|
||||||
# await message.add_reaction(actual_emoji)
|
# await message.add_reaction(actual_emoji)
|
||||||
# except discord.HTTPException:
|
# except discord.HTTPException:
|
||||||
# await ctx.send("I can't add that emoji because I'm not in the guild that"
|
# await ctx.send("I can't add that emoji because I'm not in the guild that"
|
||||||
# " owns it.")
|
# " owns it.")
|
||||||
# return
|
# return
|
||||||
|
#
|
||||||
# noinspection PyTypeChecker
|
# noinspection PyTypeChecker
|
||||||
await self.add_reactrestrict(message_id, role)
|
await self.add_reactrestrict(message_id, role)
|
||||||
|
|
||||||
@ -251,10 +245,10 @@ class ReactRestrict:
|
|||||||
Removes role associated with a given reaction.
|
Removes role associated with a given reaction.
|
||||||
"""
|
"""
|
||||||
# try:
|
# try:
|
||||||
# emoji, actual_emoji = await self._wait_for_emoji(ctx)
|
# emoji, actual_emoji = await self._wait_for_emoji(ctx)
|
||||||
# except asyncio.TimeoutError:
|
# except asyncio.TimeoutError:
|
||||||
# await ctx.send("You didn't respond in time, please redo this command.")
|
# await ctx.send("You didn't respond in time, please redo this command.")
|
||||||
# return
|
# return
|
||||||
|
|
||||||
# noinspection PyTypeChecker
|
# noinspection PyTypeChecker
|
||||||
await self.remove_react(message_id, role)
|
await self.remove_react(message_id, role)
|
||||||
@ -298,50 +292,50 @@ class ReactRestrict:
|
|||||||
for apprrole in roles:
|
for apprrole in roles:
|
||||||
if apprrole in member.roles:
|
if apprrole in member.roles:
|
||||||
return
|
return
|
||||||
|
|
||||||
message = await self._get_message_from_channel(channel_id, message_id)
|
message = await self._get_message_from_channel(channel_id, message_id)
|
||||||
await message.remove_reaction(emoji, member)
|
await message.remove_reaction(emoji, member)
|
||||||
|
|
||||||
# try:
|
|
||||||
# await member.add_roles(*roles)
|
|
||||||
# except discord.Forbidden:
|
|
||||||
# pass
|
|
||||||
|
|
||||||
|
# try:
|
||||||
|
# await member.add_roles(*roles)
|
||||||
|
# except discord.Forbidden:
|
||||||
|
# pass
|
||||||
|
#
|
||||||
# async def on_raw_reaction_remove(self, emoji: discord.PartialReactionEmoji,
|
# async def on_raw_reaction_remove(self, emoji: discord.PartialReactionEmoji,
|
||||||
# message_id: int, channel_id: int, user_id: int):
|
# message_id: int, channel_id: int, user_id: int):
|
||||||
# """
|
# """
|
||||||
# Event handler for long term reaction watching.
|
# Event handler for long term reaction watching.
|
||||||
|
#
|
||||||
# :param discord.PartialReactionEmoji emoji:
|
# :param discord.PartialReactionEmoji emoji:
|
||||||
# :param int message_id:
|
# :param int message_id:
|
||||||
# :param int channel_id:
|
# :param int channel_id:
|
||||||
# :param int user_id:
|
# :param int user_id:
|
||||||
# :return:
|
# :return:
|
||||||
# """
|
# """
|
||||||
# if emoji.is_custom_emoji():
|
# if emoji.is_custom_emoji():
|
||||||
# emoji_id = emoji.id
|
# emoji_id = emoji.id
|
||||||
# else:
|
# else:
|
||||||
# emoji_id = emoji.name
|
# emoji_id = emoji.name
|
||||||
|
#
|
||||||
# has_reactrestrict, combos = await self.has_reactrestrict_combo(message_id, emoji_id)
|
# has_reactrestrict, combos = await self.has_reactrestrict_combo(message_id, emoji_id)
|
||||||
|
#
|
||||||
# if not has_reactrestrict:
|
# if not has_reactrestrict:
|
||||||
# return
|
# return
|
||||||
|
#
|
||||||
# try:
|
# try:
|
||||||
# member = self._get_member(channel_id, user_id)
|
# member = self._get_member(channel_id, user_id)
|
||||||
# except LookupError:
|
# except LookupError:
|
||||||
# return
|
# return
|
||||||
|
#
|
||||||
# if member.bot:
|
# if member.bot:
|
||||||
# return
|
# return
|
||||||
|
#
|
||||||
# try:
|
# try:
|
||||||
# roles = [self._get_role(member.guild, c.role_id) for c in combos]
|
# roles = [self._get_role(member.guild, c.role_id) for c in combos]
|
||||||
# except LookupError:
|
# except LookupError:
|
||||||
# return
|
# return
|
||||||
|
#
|
||||||
# try:
|
# try:
|
||||||
# await member.remove_roles(*roles)
|
# await member.remove_roles(*roles)
|
||||||
# except discord.Forbidden:
|
# except discord.Forbidden:
|
||||||
# pass
|
# pass
|
||||||
|
@ -32,8 +32,7 @@ class SayUrl:
|
|||||||
"""
|
"""
|
||||||
Converts a URL to something readable
|
Converts a URL to something readable
|
||||||
|
|
||||||
:param url:
|
Works better on smaller websites
|
||||||
:return:
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
h = html2text.HTML2Text()
|
h = html2text.HTML2Text()
|
||||||
|
@ -120,8 +120,6 @@ async def parse_code(code, game):
|
|||||||
digits += 1
|
digits += 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
idx = int(built)
|
idx = int(built)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
@ -146,7 +144,6 @@ async def parse_code(code, game):
|
|||||||
|
|
||||||
built = ""
|
built = ""
|
||||||
|
|
||||||
|
|
||||||
return decode
|
return decode
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,4 +30,4 @@ class Player:
|
|||||||
try:
|
try:
|
||||||
await self.member.send(message) # Lets do embeds later
|
await self.member.send(message) # Lets do embeds later
|
||||||
except discord.Forbidden:
|
except discord.Forbidden:
|
||||||
await self.role.game.village_channel.send("Couldn't DM {}, uh oh".format(self.mention))
|
await self.role.game.village_channel.send("Couldn't DM {}, uh oh".format(self.mention))
|
||||||
|
@ -16,7 +16,6 @@ class Seer(Role):
|
|||||||
description = "A mystic in search of answers in a chaotic town.\n" \
|
description = "A mystic in search of answers in a chaotic town.\n" \
|
||||||
"Calls upon the cosmos to discern those of Lycan blood"
|
"Calls upon the cosmos to discern those of Lycan blood"
|
||||||
|
|
||||||
|
|
||||||
def __init__(self, game):
|
def __init__(self, game):
|
||||||
super().__init__(game)
|
super().__init__(game)
|
||||||
# self.game = game
|
# self.game = game
|
||||||
|
Loading…
x
Reference in New Issue
Block a user