forked from Hannah-Ashna/Discord-Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.py
117 lines (94 loc) · 4.16 KB
/
bot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# Work with Python 3.6
import discord
import os
import asyncio
import random
from datetime import datetime
from imdb import IMDb
TOKEN = os.getenv('DISCORD_TOKEN')
CHANNEL = os.getenv('CHANNEL_ID')
bot = discord.Client()
watchList = []
async def stay_awake():
await bot.wait_until_ready()
while not bot.is_closed():
now = datetime.now()
current_time = now.strftime("%H:%M:%S")
start_time = "13:00:00"
end_time = "14:00:00"
channel = bot.get_channel(CHANNEL)
# Setup the watchParty list
if (current_time > start_time and current_time < end_time):
await channel.send("Current watch party list is empty!\nDo .Join to join...")
# Reset the watchParty list for the next day
elif (current_time < start_time):
watchList = []
print('Im awake!')
await asyncio.sleep(1680) #runs every 28mins
@bot.event
async def on_message(message):
if message.author == bot.user:
return
# Greet the user and show them their tasks for the day
if (message.content.lower().startswith("morning") or message.content.lower().startswith("mrnin") or
message.content.lower().startswith("mornin") or message.content.lower().startswith("g'day")):
UserName = (str(message.author)).split("#")
if (UserName[0] == "Jad"):
await message.channel.send("**Hello** " + UserName[0] + ", send pet pics now :aaaa:")
else:
await message.channel.send("**Hello** " + UserName[0])
# Call them out for sleeping too much!
if (message.content.lower().startswith("afternoon")):
await message.channel.send("Damn ... took you long enough...")
# Add a server member to the watch party list
if (message.content.lower().startswith(".join")):
UserName = (str(message.author)).split("#")
if UserName[0] not in watchList:
watchList.append(UserName[0])
await message.channel.send("... Adding you to the **VIP** list")
else:
await message.channel.send("You're already on the list! Use `.Bail` to leave.")
# Remove a server member from the watch party list
if (message.content.lower().startswith(".bail")):
UserName = (str(message.author)).split("#")
if UserName[0] in watchList:
watchList.remove(UserName[0])
await message.channel.send("... damn, the **audacity**")
else:
await message.channel.send("You're not on the list! Use `.Me` to join.")
# Display current watch party list attendees
if (message.content.lower().startswith(".partylist")):
usersList = "**Joining us Tonight:**\n"
for x in range (0, len(watchList)):
usersList += "- " + watchList[x] + "\n"
await message.channel.send(usersList)
# Some other easter eggs
if (message.content.lower().startswith("danny")):
await message.channel.send("hee hoo")
#Jad busy command
if (message.content.lower().startswith(".jadbusy?")):
now = datetime.now()
if(now.hour > 9 & now.hour < 17 & (now.weekday() != 5 & now.weekday() != 6)):
await message.channel.send("He's probably at work but might still respond.")
elif(now.hour > 9 & now.hour < 23):
await message.channel.send("I mean he's probably free?")
else:
await message.channel.send("Jad's dead. F.")
# Find random movie
if (message.content.lower().startswith(".findmovie")):
ia = IMDb()
search = message.content[11::]
search.replace(' ', '_')
movies = ia.get_keyword(search)
print(len(movies))
if(len(movies) == 0):
await message.channel.send("No Movies Found")
else:
# print random movie from movies found
movie = movies[random.randint(0, len(movies))]
print(movie)
await message.channel.send(movie)
async def on_ready():
print('Logged in as: ',bot.user.name)
bot.loop.create_task(stay_awake())
bot.run(TOKEN)