-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdisocrd.py
57 lines (52 loc) · 2.02 KB
/
disocrd.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
import datetime
import discord
import smtplib
import asyncio
import random
import time
from email.mime.text import MIMEText
client = discord.Client()
token = "ODExNDg5MTEzNTY3Nzg5MDU2.YCy8IQ.y3KEZHB-l-wxAb_wFxHa3sVqWsc"
@client.event
async def on_ready():
print("시작")
print(client.user)
print("-------------")
@client.event
async def on_message(message):
if message.content == "내정보":
user = message.author
date = datetime.datetime.utcfromtimestamp(((int(user.id) >> 22)+1420070400000)/1000)
await message.channel.send(f"{message.author.mention}의 가입일 : {date.year}/{date.month}/{date.day}")
if message.content.startswith("!인증"):
msg_1 = message.content.split()
try:
data = msg_1[1]
except:
await message.channel.send("이메일을 입력해주세요")
return
a = random.randint(1000,9999)
print(a)
smtp = smtplib.SMTP('smtp.gmail.com', 587)
smtp.ehlo() # say Hello
smtp.starttls() # TLS 사용시 필요
smtp.login('본인이메일', '본인이메일비밀번호')
msg = MIMEText(str(a))
msg['Subject'] = '메일제목'
msg['To'] = data
smtp.sendmail('본인이메일', data, msg.as_string())
smtp.quit()
await message.channel.send("해당이메일로 인증코드가 전송되었습니다 60초 이내에 인증번호를 보내주세요")
try:
msg2 = await client.wait_for('message', timeout=60)
except asyncio.TimeoutError:
await message.channel.send("30초가 지났어요 다시해주세요")
return
else:
psg = str(msg2.content)
print(psg)
if psg == str(a):
await message.channel.send("인증되었습니다")
role = discord.utils.get(message.guild.roles, name="서버원")
await message.author.add_roles(role)
client.run(token)