Skip to content

Commit b89dac4

Browse files
committed
fix false dad joke detection
1 parent 3f0fa68 commit b89dac4

File tree

1 file changed

+25
-29
lines changed

1 file changed

+25
-29
lines changed

protobot.py

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#
2020
bot = commands.Bot(command_prefix='!') #
2121
TOKEN = os.getenv('DISCORD_TOKEN') #
22-
VERSION = "a0.1" #
22+
VERSION = "v0.1-alpha" #
2323
ACTIVITY = discord.Game("!help") #
2424
#
2525
#########################################
@@ -80,45 +80,41 @@ async def on_message(message):
8080

8181
return
8282

83+
84+
elif 'happy birthday' in message.content.lower():
85+
"""
86+
Lets the bot say happy birthday whenever a user says it
87+
"""
88+
89+
print("Wishing someone a happy birthday!")
90+
await message.channel.send('Happy Birthday! 🎈🎉🎂')
91+
92+
await bot.process_commands(message)
93+
94+
8395
if 'im' in message.content.lower() or 'i\'m' in message.content.lower() or 'i am' in message.content.lower():
8496
"""
8597
Lets the bot tell the famous "Hi x! I'm dad!" joke
8698
"""
8799

88100
user_message = message.content.split()
89-
ways_to_say_i_am = ["im", "i'm", "i am"]
90-
print("Dad joke incoming!")
101+
102+
ways_to_say_i_am = [' im', ' i\'m']
91103

92104
for i in range(len(user_message)):
93-
if len(user_message) - i < 2:
94-
print("False alarm, user message too short!")
95-
break
96-
97-
elif user_message[i].lower() in ways_to_say_i_am:
98-
response = "Hi " + " ".join(user_message[i + 1:]) + "! I'm dad!"
99-
print(response)
100-
await message.channel.send(response)
101-
break
102-
103-
elif len(user_message) - i < 3:
104-
print("False alarm, user message too short!")
105-
break
106-
107-
elif user_message[i].lower() + " " + user_message[i + 1].lower() in ways_to_say_i_am:
108-
response = "Hi " + " ".join(user_message[i + 2:]) + "! I'm dad!"
109-
print(response)
110-
await message.channel.send(response)
111-
break
105+
if (' ' + user_message[i].lower() in ways_to_say_i_am):
112106

113-
elif 'happy birthday' in message.content.lower():
114-
"""
115-
Lets the bot say happy birthday whenever a user says it
116-
"""
107+
print("Dad joke incoming!")
117108

118-
print("Wishing someone a happy birthday!")
119-
await message.channel.send('Happy Birthday! 🎈🎉🎂')
109+
if len(user_message) - i < 2:
110+
print("False alarm, user message too short!")
111+
break
120112

121-
await bot.process_commands(message)
113+
else:
114+
response = "Hi " + " ".join(user_message[i + 1:]) + "! I'm dad!"
115+
print(response)
116+
await message.channel.send(response)
117+
break
122118

123119

124120
@bot.command(name = '99', help = 'Responds with a random Brooklyn 99 quote.')

0 commit comments

Comments
 (0)