-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.py
More file actions
48 lines (41 loc) · 1.5 KB
/
bot.py
File metadata and controls
48 lines (41 loc) · 1.5 KB
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
import discord
import asyncio
import imguralbum
import os
import random
import shutil
client = discord.Client()
@client.event
async def on_ready():
print("Bot online")
@client.event
async def on_message(message):
if message.content.startswith('!randgur'):
if not os.path.exists('test'):
os.makedirs('test')
while os.listdir('test') == []:
try:
keys = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
key = ''
j = 0
while j == 0:
try:
for i in range(0,5):
k = random.randrange(0,61)
key += keys[k]
newurl = 'https://imgur.com/gallery/' + key
downloader = imguralbum.ImgurAlbumDownloader(newurl)
j = 1
except:
key = ''
continue
cwd = os.getcwd()
downloader.save_images()
except:
continue
i = random.choice(os.listdir('test'))
await client.send_file(message.channel, "test\\" + i)
shutil.rmtree('test')
if message.content.startswith('!rhelp'):
await client.send_message(message.channel, 'Created by Jackson Hurst\n\nTo generate a random image from imgur, simply type !randgur, wait a few seconds, and an image should send!')
client.run('ENTER TOKEN HERE')