2021-11-10 00:29:32 +00:00
|
|
|
import discord
|
|
|
|
import re
|
|
|
|
import yaml
|
2021-11-17 15:36:26 +00:00
|
|
|
import random
|
2021-11-10 00:29:32 +00:00
|
|
|
|
|
|
|
# from discord.ext import commands
|
|
|
|
|
|
|
|
bot = discord.Client()
|
2021-11-17 15:36:26 +00:00
|
|
|
sensitivity = 5
|
|
|
|
counter = random.randrange(0, sensitivity)
|
2021-11-10 00:29:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
@bot.event
|
|
|
|
async def on_ready():
|
|
|
|
print("Logged in as")
|
|
|
|
print(bot.user.name + "#" + bot.user.discriminator)
|
|
|
|
print(bot.user.id)
|
2021-11-17 15:36:26 +00:00
|
|
|
await bot.change_presence(
|
|
|
|
status=discord.Status.online, activity=discord.Game(name="with Godlina")
|
|
|
|
)
|
2021-11-10 00:29:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
@bot.event
|
|
|
|
async def on_message(message):
|
|
|
|
if message.author == bot.user:
|
|
|
|
return
|
|
|
|
else:
|
2021-11-17 15:36:26 +00:00
|
|
|
global counter
|
2021-11-10 00:29:32 +00:00
|
|
|
print("Message from " + message.author.name + ": " + message.content)
|
2021-11-17 15:36:26 +00:00
|
|
|
reply = re.split("I'm |Im |i'm |im |I am |i am ", message.content, 1)
|
|
|
|
if len(reply) > 1:
|
|
|
|
if counter > 0:
|
|
|
|
counter -= 1
|
|
|
|
print("Cooldown: " + str(counter) + " messages")
|
|
|
|
else:
|
|
|
|
counter = random.randrange(0, sensitivity)
|
|
|
|
await message.reply("Hi " + reply[1] + ", I'm Dad")
|
|
|
|
print("Replied to " + message.author.name + " with Dad Joke")
|
|
|
|
else:
|
|
|
|
print("No match, ignoring...")
|
2021-11-10 00:29:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
with open("secrets.yaml") as stream:
|
|
|
|
try:
|
|
|
|
secrets = yaml.safe_load(stream)
|
|
|
|
except yaml.YAMLError as exc:
|
|
|
|
print(exc)
|
|
|
|
print("Secrets.yaml failed to load, exiting...")
|
|
|
|
raise SystemExit
|
|
|
|
|
2021-11-17 15:36:26 +00:00
|
|
|
|
|
|
|
bot.run(secrets["bottoken"])
|