Added Main Message to Response handler

master
blackfur 2021-01-19 19:57:54 +01:00
parent 92c7bfcf9b
commit 5d0be77584
1 changed files with 29 additions and 0 deletions

29
run.py
View File

@ -22,6 +22,13 @@ def printversion():
print("Somer Version")
def remove_mention(m, s, i):
if m == "s":
return s[0:i] + s[i+21:]
elif m == "l":
return s[:i] + s[i+22:]
async def download():
await bot.change_presence(activity=discord.Game(name=" downloading Message History"))
os.system("rm chatlogs/*.tmp.yml")
@ -83,4 +90,26 @@ async def on_ready():
else:
chatbot = ChatBot(config["botname"])
@bot.event
async def on_message(message):
if message.author != bot.user:
if message.channel.id in config["usechannels"]:
if message.content.startswith(config["exclutionprefix"]):
return
else:
response = chatbot.get_response(message.content)
response = response.__str__()
if config["filterpings"]:
position = response.find("<@!")
while position != -1:
response = remove_mention("l", response, position)
position = response.find("<@!")
position = response.find("<@")
while position != -1:
response = remove_mention("s", response, position)
position = response.find("<@")
await message.channel.send(response)
print(f"Input was given: '{message.content}', this output was found: '{response}'")
bot.run(config["token"])