This repository has been archived by the owner on Apr 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathimage.py
45 lines (41 loc) · 1.55 KB
/
image.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
import discord
import os
import sqlite3
client = discord.Client()
conn = sqlite3.connect('grass.db')
c = conn.cursor()
async def send(channel,*args, **kwargs): return await channel.send(*args, **kwargs)
@client.event
async def on_message(message):
if message.author.bot:
return
if message.content == "草":
user_name = message.author.id
select_sql = 'select * from grass where username='
username = ('{user_name}').format(user_name=user_name)
select_sql = select_sql + username
print(select_sql)
c.execute(select_sql)
result = c.fetchone()
img_name = result[1]
img_name = "./images/" + img_name
img_name_n = img_name.replace(".png","")
img_name_n = img_name_n.replace("./images/","")
await message.channel.send(img_name_n)
await message.channel.send(file=discord.File(img_name))
if message.content == "grass":
user_name = message.author.id
select_sql = 'select * from grass where username='
username = ('{user_name}').format(user_name=user_name)
select_sql = select_sql + username
print(select_sql)
c.execute(select_sql)
result = c.fetchone()
img_name = result[1]
img_name = "./images/" + img_name
img_name_n = img_name.replace(".png","")
img_name_n = img_name_n.replace("./images/","")
await message.channel.send(img_name_n)
await message.channel.send(file=discord.File(img_name))
if __name__ == "__main__":
client.run(os.environ['LEAF_TOKEN'])