-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsearchkey.py
More file actions
47 lines (38 loc) · 1.25 KB
/
searchkey.py
File metadata and controls
47 lines (38 loc) · 1.25 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
import discord
import os
import asyncio
import requests
from urllib.parse import urljoin
client = discord.Client()
@client.event
async def on_message(message):
if message.author.bot:
return
if message.content == "*gpg":
await message.channel.send("GitHubに登録されているユーザーのGPG公開鍵を取得します ユーザー名を続けて入力して下さい")
def check(command):
return command.author == message.author
c = await client.wait_for("message", check=check)
# c = await client.wait_for("message")
search = c.content
count = 0
print(search)
search = str(search)
search = search.lower()
baseurl = "https://github.com/"
# username = search + ".gpg"
url = urljoin("https://github.com/", search)
url = url + ".gpg"
print(url)
res = requests.get(url)
if res.status_code == requests.codes.ok:
print(res.text)
name = search + ".gpg"
f = open(name, "w")
f.write(res.text)
f.close()
await message.channel.send(file=discord.File(name))
os.remove(name)
else:
await message.channel.send("ユーザーが存在しませんでした\nもう一度やり直してください")
client.run("")