Assorted QoL updates
This commit is contained in:
parent
813ca2eb67
commit
273e622fa7
@ -2,7 +2,6 @@ import asyncio
|
||||
import re
|
||||
|
||||
import discord
|
||||
|
||||
from redbot.core import Config, checks
|
||||
from redbot.core import commands
|
||||
from redbot.core.utils.chat_formatting import pagify, box
|
||||
@ -191,7 +190,7 @@ class CCRole:
|
||||
"""Shows custom commands list"""
|
||||
guild = ctx.guild
|
||||
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:
|
||||
await ctx.send(
|
||||
"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
|
||||
|
||||
import discord
|
||||
|
||||
from redbot.core import Config
|
||||
from redbot.core import commands
|
||||
|
||||
@ -10,7 +9,6 @@ from chatter.chatterbot import ChatBot
|
||||
from chatter.chatterbot.trainers import ListTrainer
|
||||
|
||||
|
||||
|
||||
class Chatter:
|
||||
"""
|
||||
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
|
||||
"""
|
||||
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:
|
||||
await ctx.send("Backup successful!")
|
||||
@ -142,7 +141,6 @@ class Chatter:
|
||||
author = message.author
|
||||
channel = message.channel
|
||||
|
||||
|
||||
if message.author.id != self.bot.user.id:
|
||||
to_strip = "@" + author.guild.me.display_name + " "
|
||||
text = message.clean_content
|
||||
|
@ -158,7 +158,9 @@ class StorageAdapter(object):
|
||||
class EmptyDatabaseException(Exception):
|
||||
|
||||
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
|
||||
|
||||
def __str__(self):
|
||||
|
@ -1,11 +1,8 @@
|
||||
import discord
|
||||
|
||||
from redbot.core import Config, checks
|
||||
|
||||
from redbot.core.bot import Red
|
||||
|
||||
from pylint import epylint as lint
|
||||
from redbot.core import Config
|
||||
from redbot.core import commands
|
||||
from redbot.core.bot import Red
|
||||
from redbot.core.data_manager import cog_data_path
|
||||
|
||||
|
||||
|
@ -2,10 +2,9 @@ from collections import defaultdict
|
||||
from random import randint
|
||||
|
||||
import discord
|
||||
|
||||
from redbot.core import Config, checks
|
||||
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:
|
||||
@ -26,7 +25,7 @@ class Hangman:
|
||||
lambda: {"running": False, "hangman": 0, "guesses": [], "trackmessage": False, "answer": ''})
|
||||
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)
|
||||
|
||||
@ -331,4 +330,3 @@ class Hangman:
|
||||
|
||||
await self._reactmessage_menu(message)
|
||||
await self._checkdone(channel)
|
||||
|
||||
|
@ -58,8 +58,6 @@ class LastSeen:
|
||||
async def lseen(self, ctx: commands.Context, member: discord.Member):
|
||||
"""
|
||||
Just says the time the user was last seen
|
||||
|
||||
:param member:
|
||||
"""
|
||||
|
||||
if member.status != self.offline_status:
|
||||
|
@ -1,12 +1,9 @@
|
||||
import asyncio
|
||||
from typing import List, Union
|
||||
|
||||
import discord
|
||||
|
||||
|
||||
from redbot.core import Config
|
||||
from redbot.core.bot import Red
|
||||
from redbot.core import commands
|
||||
from redbot.core.bot import Red
|
||||
|
||||
|
||||
class ReactRestrictCombo:
|
||||
@ -16,8 +13,8 @@ class ReactRestrictCombo:
|
||||
|
||||
def __eq__(self, other: "ReactRestrictCombo"):
|
||||
return (
|
||||
self.message_id == other.message_id and
|
||||
self.role_id == other.role_id
|
||||
self.message_id == other.message_id and
|
||||
self.role_id == other.role_id
|
||||
)
|
||||
|
||||
def to_json(self):
|
||||
@ -83,7 +80,7 @@ class ReactRestrict:
|
||||
"""
|
||||
# is_custom = True
|
||||
# if isinstance(emoji, str):
|
||||
# is_custom = False
|
||||
# is_custom = False
|
||||
|
||||
combo = ReactRestrictCombo(message_id, role.id)
|
||||
|
||||
@ -95,10 +92,10 @@ class ReactRestrict:
|
||||
|
||||
async def remove_react(self, message_id: int, role: discord.Role):
|
||||
"""
|
||||
Removes a given reaction.
|
||||
Removes a given reaction
|
||||
|
||||
:param int message_id:
|
||||
:param str or int emoji:
|
||||
:param message_id:
|
||||
:param role:
|
||||
:return:
|
||||
"""
|
||||
current_combos = await self.combo_list()
|
||||
@ -109,14 +106,13 @@ class ReactRestrict:
|
||||
if to_keep != current_combos:
|
||||
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]):
|
||||
"""
|
||||
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.
|
||||
|
||||
:param int message_id:
|
||||
:param str or int emoji:
|
||||
:param message_id:
|
||||
:return:
|
||||
"""
|
||||
if not await self.is_registered(message_id):
|
||||
@ -169,8 +165,8 @@ class ReactRestrict:
|
||||
raise LookupError("No role found.")
|
||||
|
||||
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]:
|
||||
"""
|
||||
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)
|
||||
except discord.NotFound:
|
||||
pass
|
||||
except AttributeError: # VoiceChannel object has no attribute 'get_message'
|
||||
except AttributeError: # VoiceChannel object has no attribute 'get_message'
|
||||
pass
|
||||
|
||||
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]:
|
||||
"""
|
||||
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)
|
||||
except discord.NotFound:
|
||||
pass
|
||||
except AttributeError: # VoiceChannel object has no attribute 'get_message'
|
||||
except AttributeError: # VoiceChannel object has no attribute 'get_message'
|
||||
pass
|
||||
except discord.Forbidden: # No access to channel, skip
|
||||
pass
|
||||
|
||||
|
||||
|
||||
return None
|
||||
|
||||
@ -228,18 +222,18 @@ class ReactRestrict:
|
||||
return
|
||||
|
||||
# try:
|
||||
# emoji, actual_emoji = await self._wait_for_emoji(ctx)
|
||||
# emoji, actual_emoji = await self._wait_for_emoji(ctx)
|
||||
# except asyncio.TimeoutError:
|
||||
# await ctx.send("You didn't respond in time, please redo this command.")
|
||||
# return
|
||||
|
||||
# await ctx.send("You didn't respond in time, please redo this command.")
|
||||
# return
|
||||
#
|
||||
# try:
|
||||
# await message.add_reaction(actual_emoji)
|
||||
# await message.add_reaction(actual_emoji)
|
||||
# except discord.HTTPException:
|
||||
# await ctx.send("I can't add that emoji because I'm not in the guild that"
|
||||
# " owns it.")
|
||||
# return
|
||||
|
||||
# await ctx.send("I can't add that emoji because I'm not in the guild that"
|
||||
# " owns it.")
|
||||
# return
|
||||
#
|
||||
# noinspection PyTypeChecker
|
||||
await self.add_reactrestrict(message_id, role)
|
||||
|
||||
@ -251,10 +245,10 @@ class ReactRestrict:
|
||||
Removes role associated with a given reaction.
|
||||
"""
|
||||
# try:
|
||||
# emoji, actual_emoji = await self._wait_for_emoji(ctx)
|
||||
# emoji, actual_emoji = await self._wait_for_emoji(ctx)
|
||||
# except asyncio.TimeoutError:
|
||||
# await ctx.send("You didn't respond in time, please redo this command.")
|
||||
# return
|
||||
# await ctx.send("You didn't respond in time, please redo this command.")
|
||||
# return
|
||||
|
||||
# noinspection PyTypeChecker
|
||||
await self.remove_react(message_id, role)
|
||||
@ -298,50 +292,50 @@ class ReactRestrict:
|
||||
for apprrole in roles:
|
||||
if apprrole in member.roles:
|
||||
return
|
||||
|
||||
|
||||
message = await self._get_message_from_channel(channel_id, message_id)
|
||||
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,
|
||||
# message_id: int, channel_id: int, user_id: int):
|
||||
# """
|
||||
# Event handler for long term reaction watching.
|
||||
|
||||
# :param discord.PartialReactionEmoji emoji:
|
||||
# :param int message_id:
|
||||
# :param int channel_id:
|
||||
# :param int user_id:
|
||||
# :return:
|
||||
# """
|
||||
# if emoji.is_custom_emoji():
|
||||
# emoji_id = emoji.id
|
||||
# else:
|
||||
# emoji_id = emoji.name
|
||||
|
||||
# has_reactrestrict, combos = await self.has_reactrestrict_combo(message_id, emoji_id)
|
||||
|
||||
# if not has_reactrestrict:
|
||||
# return
|
||||
|
||||
# try:
|
||||
# member = self._get_member(channel_id, user_id)
|
||||
# except LookupError:
|
||||
# return
|
||||
|
||||
# if member.bot:
|
||||
# return
|
||||
|
||||
# try:
|
||||
# roles = [self._get_role(member.guild, c.role_id) for c in combos]
|
||||
# except LookupError:
|
||||
# return
|
||||
|
||||
# try:
|
||||
# await member.remove_roles(*roles)
|
||||
# except discord.Forbidden:
|
||||
# pass
|
||||
# message_id: int, channel_id: int, user_id: int):
|
||||
# """
|
||||
# Event handler for long term reaction watching.
|
||||
#
|
||||
# :param discord.PartialReactionEmoji emoji:
|
||||
# :param int message_id:
|
||||
# :param int channel_id:
|
||||
# :param int user_id:
|
||||
# :return:
|
||||
# """
|
||||
# if emoji.is_custom_emoji():
|
||||
# emoji_id = emoji.id
|
||||
# else:
|
||||
# emoji_id = emoji.name
|
||||
#
|
||||
# has_reactrestrict, combos = await self.has_reactrestrict_combo(message_id, emoji_id)
|
||||
#
|
||||
# if not has_reactrestrict:
|
||||
# return
|
||||
#
|
||||
# try:
|
||||
# member = self._get_member(channel_id, user_id)
|
||||
# except LookupError:
|
||||
# return
|
||||
#
|
||||
# if member.bot:
|
||||
# return
|
||||
#
|
||||
# try:
|
||||
# roles = [self._get_role(member.guild, c.role_id) for c in combos]
|
||||
# except LookupError:
|
||||
# return
|
||||
#
|
||||
# try:
|
||||
# await member.remove_roles(*roles)
|
||||
# except discord.Forbidden:
|
||||
# pass
|
||||
|
@ -32,8 +32,7 @@ class SayUrl:
|
||||
"""
|
||||
Converts a URL to something readable
|
||||
|
||||
:param url:
|
||||
:return:
|
||||
Works better on smaller websites
|
||||
"""
|
||||
|
||||
h = html2text.HTML2Text()
|
||||
|
@ -120,8 +120,6 @@ async def parse_code(code, game):
|
||||
digits += 1
|
||||
continue
|
||||
|
||||
|
||||
|
||||
try:
|
||||
idx = int(built)
|
||||
except ValueError:
|
||||
@ -146,7 +144,6 @@ async def parse_code(code, game):
|
||||
|
||||
built = ""
|
||||
|
||||
|
||||
return decode
|
||||
|
||||
|
||||
|
@ -30,4 +30,4 @@ class Player:
|
||||
try:
|
||||
await self.member.send(message) # Lets do embeds later
|
||||
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" \
|
||||
"Calls upon the cosmos to discern those of Lycan blood"
|
||||
|
||||
|
||||
def __init__(self, game):
|
||||
super().__init__(game)
|
||||
# self.game = game
|
||||
|
Loading…
x
Reference in New Issue
Block a user