-
Notifications
You must be signed in to change notification settings - Fork 1
/
minimal.py
169 lines (133 loc) · 4.15 KB
/
minimal.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
import os
import requests
import discord
from dotenv import load_dotenv
from discord.ext import commands
load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')
GUILD = os.getenv('DISCORD_GUILD')
USERNAME = os.getenv('IMGFLIP_USERNAME')
PASS = os.getenv('IMGFLIP_PASSWORD')
bot = commands.Bot(command_prefix='..')
def get_crypto(coin):
URL = 'https://api.coinmarketcap.com/v1/ticker/'+coin
response = requests.get(URL)
data = response.json()
return float(data[0]['price_usd'])
def get_memes():
URL = 'https://api.imgflip.com/get_memes'
r = requests.get(URL)
data = r.json()
for meme in data['data']['memes']:
print(meme['id'] + ' | ' + meme['name'] + ' | ' + meme['url'])
def create_meme(t1, t2, t_id):
URL = 'https://api.imgflip.com/caption_image'
data = {'template_id': t_id,
'username': USERNAME,
'password': PASS,
'text0': t1,
'text1': t2,
}
r = requests.post(url=URL, data=data)
data = r.json()
return data['data']['url']
@bot.event
async def on_ready():
print(f'{bot.user.name} has connected to Discord!')
@bot.command(name='coin', help='Shows price of crypto coin')
async def coin(ctx, coin):
try:
response = get_crypto(coin)
await ctx.send(response)
except Exception as e:
print(str(e))
@coin.error
async def coin_error(ctx, error):
if isinstance(error, commands.MissingRequiredArgument):
await ctx.send('..coin "Name of coin"')
@bot.command(name='batman', help='Batman slapping Robin')
async def batman_meme(ctx, t1, t2):
yazi1 = ''
yazi2 = ''
try:
if t1 is not None:
yazi1 = t1
if t2 is not None:
yazi2 = t2
response = create_meme(yazi1, yazi2, 438680)
await ctx.send(response)
except Exception as e:
print(str(e))
@batman_meme.error
async def batman_meme_error(ctx, error):
if isinstance(error, commands.MissingRequiredArgument):
await ctx.send('..batman "text1" "text2"')
@bot.command(name='isthis', help='Is this a butterfly')
async def isthis_meme(ctx, t1, t2):
yazi1 = ''
yazi2 = ''
try:
if t1 is not None:
yazi1 = t1
if t2 is not None:
yazi2 = t2
response = create_meme(yazi1, yazi2, 100777631)
await ctx.send(response)
except Exception as e:
print(str(e))
@isthis_meme.error
async def isthis_meme_error(ctx, error):
if isinstance(error, commands.MissingRequiredArgument):
await ctx.send('..isthis "text1" "text2"')
@bot.command(name='matrix', help='Matrix Morpheus')
async def matrix_meme(ctx, t1, t2):
yazi1 = ''
yazi2 = ''
try:
if t1 is not None:
yazi1 = t1
if t2 is not None:
yazi2 = t2
response = create_meme(yazi1, yazi2, 100947)
await ctx.send(response)
except Exception as e:
print(str(e))
@matrix_meme.error
async def matrix_meme_error(ctx, error):
if isinstance(error, commands.MissingRequiredArgument):
await ctx.send('..matrix "text1" "text2"')
@bot.command(name='mind', help='Change my mind')
async def mind_meme(ctx, t1, t2):
yazi1 = ''
yazi2 = ''
try:
if t1 is not None:
yazi1 = t1
if t2 is not None:
yazi2 = t2
response = create_meme(yazi1, yazi2, 129242436)
await ctx.send(response)
except Exception as e:
print(str(e))
@mind_meme.error
async def mind_meme_error(ctx, error):
if isinstance(error, commands.MissingRequiredArgument):
await ctx.send('..mind "text1" "text2"')
@bot.command(name='imagine', help='Sponge Bob imagination, rainbow')
async def imagine_meme(ctx, t1, t2):
yazi1 = ''
yazi2 = ''
try:
if t1 is not None:
yazi1 = t1
if t2 is not None:
yazi2 = t2
response = create_meme(yazi1, yazi2, 163573)
await ctx.send(response)
except Exception as e:
print(str(e))
@imagine_meme.error
async def imagine_meme_error(ctx, error):
if isinstance(error, commands.MissingRequiredArgument):
await ctx.send('..imagine "text1" "text2"')
bot.run(TOKEN)