@ -53,7 +53,13 @@ class Chatter(Cog):
self . bot = bot
self . config = Config . get_conf ( self , identifier = 6710497116116101114 )
default_global = { }
default_guild = { " whitelist " : None , " days " : 1 , " convo_delta " : 15 , " chatchannel " : None }
default_guild = {
" whitelist " : None ,
" days " : 1 ,
" convo_delta " : 15 ,
" chatchannel " : None ,
" reply " : True ,
}
path : pathlib . Path = cog_data_path ( self )
self . data_path = path / " database.sqlite3 "
@ -213,6 +219,25 @@ class Chatter(Cog):
await self . config . guild ( ctx . guild ) . chatchannel . set ( channel . id )
await ctx . maybe_send_embed ( f " Chat channel is now { channel . mention } " )
@checks.admin ( )
@chatter.command ( name = " reply " )
async def chatter_reply ( self , ctx : commands . Context , toggle : Optional [ bool ] = None ) :
"""
Toggle bot reply to messages if conversation continuity is not present
"""
reply = await self . config . guild ( ctx . guild ) . reply ( )
if toggle is None :
toggle = not reply
await self . config . guild ( ctx . guild ) . reply . set ( toggle )
if toggle :
await ctx . send ( " I will now respond to you if conversation continuity is not present " )
else :
await ctx . send (
" I will not reply to your message if conversation continuity is not present, anymore "
)
@checks.is_owner ( )
@chatter.command ( name = " cleardata " )
async def chatter_cleardata ( self , ctx : commands . Context , confirm : bool = False ) :
@ -475,7 +500,15 @@ class Chatter(Cog):
# Thank you Cog-Creators
channel : discord . TextChannel = message . channel
if guild is not None and channel . id == await self . config . guild ( guild ) . chatchannel ( ) :
# is_reply = False # this is only useful with in_response_to
if (
message . reference is not None
and isinstance ( message . reference . resolved , discord . Message )
and message . reference . resolved . author . id == self . bot . user . id
) :
# is_reply = True # this is only useful with in_response_to
pass # this is a reply to the bot, good to go
elif guild is not None and channel . id == await self . config . guild ( guild ) . chatchannel ( ) :
pass # good to go
else :
when_mentionables = commands . when_mentioned ( self . bot , message )
@ -493,7 +526,12 @@ class Chatter(Cog):
async with channel . typing ( ) :
future = await self . loop . run_in_executor ( None , self . chatbot . get_response , text )
replying = None
if await self . config . guild ( guild ) . reply ( ) :
if message != ctx . channel . last_message :
replying = message
if future and str ( future ) :
await channel . send ( str ( future ) )
await channel . send ( str ( future ) , reference = replying )
else :
await channel . send ( " :thinking: " )