-
Notifications
You must be signed in to change notification settings - Fork 0
/
youtube_video_reply.py
58 lines (42 loc) · 1.71 KB
/
youtube_video_reply.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
#!/usr/bin/env python3
import discord
import asyncio
import random
import os
BOT_TOKEN = os.environ['DISCORDBOT']
client = discord.Client()
async def presence_set():
await client.wait_until_ready()
await client.change_presence(game=discord.Game
(name="with the Discord API"))
@client.event
async def on_ready():
print('Logged in as')
print(client.user.name)
print(client.user.id)
print('------')
async def youtube_video_link_give(check_words, video_link, message):
if any(s in message.content.lower() for s in check_words):
msg = ("Were you looking for this? " + video_link)
await client.send_message(message.channel, msg)
@client.event
async def on_message(message):
# we do not want the bot to reply to itself
if message.author == client.user:
return
# Send a link to the "Click Noice" video when the word 'noice' is mentioned
youtube_link = "https://www.youtube.com/watch?v=3WAOxKOmR90"
await youtube_video_link_give(('noice', 'nice', 'noiice', 'noicce'),
youtube_link, message)
# Send a link to the "Yeah Boi" video when the word 'yeah' or 'boi'/'boy'
# is mentioned
youtube_link = "https://www.youtube.com/watch?v=fvtQYsckLxk&t=1m5s"
await youtube_video_link_give(('yeah', 'yeh', 'boi', 'boy'), youtube_link,
message)
# Send a link to the "Time to Stop" video when the word 'stop' or 'time' is
# mentioned
youtube_link = "https://www.youtube.com/watch?v=2k0SmqbBIpQ"
await youtube_video_link_give(('stop',), youtube_link,
message)
client.loop.create_task(presence_set())
client.run(BOT_TOKEN)