티스토리 뷰

개발

디스코드 봇 개발

KWG07(joseph0528) 2021. 1. 25. 19:21

 

 

 

문제 제출 여부랑 맞았는지 틀렸는지가 나오게 해 줬고 24시간 봇이 아니고

그냥 틀고 싶을 때 트는 봇이라 db는 안 쓰고 메모장이랑 엑셀을 사용해서 이 봇에서 boj연동을 하는 거를 넣어줬다

한 사람당 한 계정만 추가할 수 있고 다른 사람이 ~add 백준 닉네임 이렇게 치면 계정이 추가된다. 만약 닉네임을 잘못 칠경 우 없는 닉네임으로 뜨게 해 줬다. 그리고 모든 404 에러 날 곳에 다 except 해줬다.

게임을 넣어달라는 분들이 있는데 게임은 나중에 추가해볼 생각이다.

근데 파이썬이라 느리다

근데 잡봇이라 이상한 게 많다 어떤 분들이 넣어달라고 하셔서 넣긴 했다

코드 설명은 안 넣겠다 어차피 속도가 너무 느려서 사용 안 하는 게 더 좋다

이봇이 어디까지 발전할지 궁금하다

import discord
import requests
import urllib.request as req
from bs4 import BeautifulSoup
import emoji
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import openpyxl
import bi
from tkinter import *
from tkinter import messagebox
from urllib.error import URLError,HTTPError
import asyncio
client=discord.Client()
def codeup(ex):
    if len(ex)==1:
        return "https://codeup.kr"
    else:
        if ex[1]=="profile"or ex[1]=="프로필":
            if len(ex)==3:
                q="https://codeup.kr/userinfo.php?user="+ex[2]
                return q
        elif ex[1]=="rank"or ex[1]=="랭크"or ex[1]=="순위":
            if len(ex)==2:
               return "https://codeup.kr/ranklist.php"
            else:
                page="https://codeup.kr/ranklist.php?start="+str((int(ex[2])-1)*50)
                return page
        else:
            q="https://codeup.kr/problem.php?id="+ex[1]
            return q

def boj(ex):
    if len(ex)==1:return ["https://www.acmicpc.net/",-9]
    else:
        if ex[1]=="profile"or ex[1]=="프로필":
            if len(ex)==3:
                q="https://www.acmicpc.net/user/"+ex[2]
                return [q,1]
        elif ex[1]=="rank"or ex[1]=="랭크"or ex[1]=="순위":
            return [0,2]
            #if len(ex)==2:
            #    return ["https://www.acmicpc.net/ranklist",2]
            #else:
            #    page="https://www.acmicpc.net/ranklist/"+ex[2]
            #    return [page,2]
        elif ex[1]=="search"or ex[1]=="검색":
            page="https://www.acmicpc.net/problemset?search="
            searchname=""
            for i in range(2,len(ex)):
                searchname+=ex[i]+"+"
            page+=searchname
            #print(page)
            return [page,4]
        else:
            q="https://www.acmicpc.net/problem/"+ex[1]
            return [q,3]

def link(x,soup):
    return soup.select_one(x).string

def solved(ex):
    if len(ex)==1:return "https://solved.ac"
    else:
        if ex[1]=="profile"or ex[1]=="프로필":
            if len(ex)==3:
                q="https://solved.ac/profile/"+ex[2]
                return q
        else:
            if(len(ex)==3 or len(ex)==4)and (ex[1]=="rank"or ex[1]=="랭크"or ex[1]=="순위"):
                if ex[2]=="ti"or ex[2]=="티어":
                    if len(ex)==3:page="https://solved.ac/ranking/tier"
                    else:page="https://solved.ac/ranking/tier?page="+ex[3]
                if ex[2]=="cl"or ex[2]=="클래스":
                    if len(ex)==3:page="https://solved.ac/ranking/class"
                    else:page="https://solved.ac/ranking/class?page="+ex[3]
                if ex[2]=="co"or ex[2]=="기여도":
                    if len(ex)==3:page="https://solved.ac/ranking/contribution"
                    else:page="https://solved.ac/ranking/contribution?page="+ex[3]
                return page
            
def deln(ip):
    for i in range(len(ip)):
        if ip[i]=="건"or ip[i]=="충"or ip[i]=="gun"or ip[i]=="고"or ip[i]=="원"or ip[i]=="규"or ip[i]=="추ᇰ"or ip[i]=="ㄱㅓㄴ"or ip[i]=="거ᇈ":return False
    return True
def gymanst(ip):
    if ip.find("바보")>=0:return True
    if ip.find("못하")>=0:return True
    if ip.find("기만")>=0 and ip.find("아닌")>=0:return True
    return False
qh=0
def ac(usern,val):
    url="https://www.acmicpc.net/user/"+usern
    res=req.urlopen(url)
    res=res.read()
    soup=BeautifulSoup(res,'html.parser')
    AC="#u-solved"
    ACvalue=soup.select_one(AC).string
    Ab="body > div.wrapper > div.container.content > div.row > div:nth-child(2) > div > div.col-md-9 > div:nth-child(1) > div.panel-body > a:nth-child("
    start=1
    end=int(ACvalue)+59
    val=int(val)
    while start<=end:
        mid=(start+end)//2
        h=soup.select_one(Ab+str(mid)+")")
        if h==None:end=mid-1;continue
        h=int(h.string)
        if h==val:return 1
        if h<val:start=mid+1
        else:end=mid-1
    UAC="#u-failed"
    UACvalue=soup.select_one(UAC).string
    Ac="body > div.wrapper > div.container.content > div.row > div:nth-child(2) > div > div.col-md-9 > div:nth-child(3) > div.panel-body > a:nth-child("
    start=1
    end=int(UACvalue)+59
    while start<=end:
        mid=(start+end)//2
        h=soup.select_one(Ac+str(mid)+")")
        if h==None:end=mid-1;continue
        h=int(h.string)
        if h==val:return 2
        if h<val:start=mid+1
        else:end=mid-1
    UAC="#u-psolved"
    UACvalue=soup.select_one(UAC).string
    Ac="body > div.wrapper > div.container.content > div.row > div:nth-child(2) > div > div.col-md-9 > div:nth-child(2) > div.panel-body > a:nth-child("
    start=1
    end=int(UACvalue)+59
    while start<=end:
        mid=(start+end)//2
        h=soup.select_one(Ac+str(mid)+")")
        if h==None:end=mid-1;continue
        h=int(h.string)
        if h==val:return 3
        if h<val:start=mid+1
        else:end=mid-1
    return 4
def chan(qh):
    global soup
    #print("qh",qh)
    tp=qh
    tp=max(tp,1)
    pagenumber=(tp-1)//10+1
    url="https://www.acmicpc.net/ranklist/"+str(pagenumber)
    try:             
        res=req.urlopen(url).read()
        soup=BeautifulSoup(res,'html.parser')
        qr=""
        co=(tp*10-9)%100
        for i in range(co,co+10):
            qr+=str(link("#ranklist > tbody > tr:nth-child("+str(i)+") > td:nth-child(1)",soup))+". "
            name12=str(soup.select_one("#ranklist > tbody > tr:nth-child("+str(i)+") > td:nth-child(2) > a"))
            qty=15
            name1=""
            while 1:
                if name12[qty]!="\"":name1+=name12[qty]
                else:break
                qty+=1
            qr+=name1+" ("
            qr+=str(link("#ranklist > tbody > tr:nth-child("+str(i)+") > td:nth-child(4) > a",soup))+"문제)\n"
        return [qr,0]
        #msg=await message.channel.send(message.channel,embed=discord.Embed(title="",description=qr,color=0x62c1cc))
        #await msg.add_reaction("\U00002B05")
        #await msg.add_reaction("\U000027A1")
    except HTTPError as e:
        return ["잘못 입력하셨습니다.",1]
        #await message.channel.send("잘못 입력하셨습니다.")

@client.event
async def on_ready():
    print("Start {0.user}".format(client))
system=0
msg1=""
@client.event
async def on_message(message):
    global system,qh,msg1
    #await message.channel.send("누군가 때문에 완전히 페쇠함(뚫는 방법은 있으니 뚫어보셈)")
    if message.author==client.user:return

    if message.content.startswith("~hello"):
        iop="```css\nhello\n```"
        await message.channel.send(iop)
    if message.content.startswith("~add"):
        try:
            ex=message.content[5:].split()
            url="https://www.acmicpc.net/user/"+ex[0]
            res=req.urlopen(url)
            res=res.read()
            soup=BeautifulSoup(res,'html.parser')
            userip=str(message.author).split("#")
            nm=bi.add(ex[0],"#"+userip[1])
            if nm==0:
                await message.channel.send("한사람당 한 계정만 추가 가능합니다.")
            else:
                await message.channel.send("추가 완료되었습니다.")
        except HTTPError as e:
                await message.channel.send("아이디가 잘못되었습니다.")
    
    
    if message.content.startswith("~gyman +"):
        userip=str(message.author).split("#")
        if not deln(userip[0]):
            ex=message.content[8:].split()
            val=int(ex[0])
            username=ex[len(ex)-1]
            excel=openpyxl.load_workbook("gymanstack.xlsx")
            workseet=excel.active
            g=1
            score=[]
            while 1:
                if workseet.cell(row=g,column=1).value==None:
                    break
                if str(workseet.cell(row=g,column=1).value)[:10]==str(message.guild.id)[:10]:
                    i=2
                    while 1:
                        if workseet.cell(row=g,column=i).value==None:
                            workseet.cell(row=g,column=i).value=username
                            workseet.cell(row=g,column=i+1).value=val
                            break
                        if workseet.cell(row=g,column=i).value==username:
                            workseet.cell(row=g,column=i+1).value+=val
                            break
                        i+=2
                    break
                g+=1
            excel.save("gymanstack.xlsx")
            excel.close()
            await message.channel.send("추가했습니다")
        else:await message.channel.send("당신은 관리자가 아닙니다.")

    if message.content.startswith("~gyman -"):
        userip=str(message.author).split("#")
        if not deln(userip[0]):
            ex=message.content[8:].split()
            val=int(ex[0])
            username=ex[len(ex)-1]
            excel=openpyxl.load_workbook("gymanstack.xlsx")
            workseet=excel.active
            g=1
            score=[]
            while 1:
                if workseet.cell(row=g,column=1).value==None:
                    break
                if str(workseet.cell(row=g,column=1).value)[:10]==str(message.guild.id)[:10]:
                    i=2
                    while 1:
                        if workseet.cell(row=g,column=i).value==None:break
                        if workseet.cell(row=g,column=i).value==username:
                            workseet.cell(row=g,column=i+1).value-=val
                            workseet.cell(row=g,column=i+1).value=max(0,workseet.cell(row=g,column=i+1).value)
                            break
                        i+=2
                    break
                g+=1
            excel.save("gymanstack.xlsx")
            excel.close()
            await message.channel.send("추가했습니다")
        else:await message.channel.send("당신은 관리자가 아닙니다.")
    
    if message.content.startswith("~gyman ranking"):
        #q="``\nhello\n``";await message.channel.send(q)
        excel=openpyxl.load_workbook("gymanstack.xlsx")
        workseet=excel.active
        g=1
        score=[]
        while 1:
            if workseet.cell(row=g,column=1).value==None:
                break
            if str(workseet.cell(row=g,column=1).value)[:10]==str(message.guild.id)[:10]:
                i=2
                while 1:
                    if workseet.cell(row=g,column=i).value==None:
                        break
                    score.append([workseet.cell(row=g,column=i+1).value,workseet.cell(row=g,column=i).value])
                    i+=2
                break
            g+=1
        score.sort()
        q="``\n"
        if len(score)==0:
            q+="아무도 없습니다.\n"
        else:
            rank=0
            for i in range(len(score)-1,-1,-1):
                rank+=1
                q+=str(rank)+". ID : "+str(score[i][1])+" ("+str(score[i][0])+"회)\n"
        q+="``\n"
        await message.channel.send(q)
        excel.close()

    if gymanst(message.content):
        userip=str(message.author).split("#")
        username="#"+userip[1]
        excel=openpyxl.load_workbook("gymanstack.xlsx")
        workseet=excel.active
        g=1
        wi=[0,0]
        while 1:
            if workseet.cell(row=g,column=1).value==None:
                workseet.cell(row=g,column=1).value=str(message.guild.id)[:10]
                workseet.cell(row=g,column=2).value=username
                workseet.cell(row=g,column=3).value=1
                wi=[g,3]
                break
            #print(workseet.cell(row=g,column=1).value,message.guild.id)
            if str(workseet.cell(row=g,column=1).value)[:10]==str(message.guild.id)[:10]:
                i=2
                while 1:
                    if workseet.cell(row=g,column=i).value==None:
                        workseet1.cell(row=g,column=i).value=username
                        workseet1.cell(row=g,column=i+1).value=1
                        wi=[g,i+1]
                        break
                    if workseet.cell(row=g,column=i).value==username:
                        workseet.cell(row=g,column=i+1).value+=1
                        wi=[g,i+1]
                        break
                    i+=2
                break
            g+=1
        excel.save("gymanstack.xlsx")
        counted=str(userip[0])+"님의 지금까지 기만한 횟수는 "+str(workseet.cell(row=wi[0],column=wi[1]).value)+"번입니다"
        await message.channel.send(counted)
        excel.close()
        
    if message.content.startswith("~good"):q="good";await message.channel.send("\U0001F44D")

    if message.content.startswith("서버 이름"):await message.channel.send(message.guild.id)
    
    if message.content.startswith("갓"):
        e=emoji.emojize(":arrow_up:")
        await message.channel.send(e)
    
    if message.content.startswith("마자효"):q="마자효\n1104";await message.channel.send(q)

    if message.content.startswith("~gymanstack me"):
        userip=str(message.author).split("#")
        username="#"+userip[1]
        excel=openpyxl.load_workbook("gymanstack.xlsx")
        workseet=excel.active
        g=1
        wi=[0,0]
        while 1:
            if workseet.cell(row=g,column=1).value==None:wi=[False,0];break
            #print(workseet.cell(row=g,column=1).value,message.guild.id)
            if str(workseet.cell(row=g,column=1).value)[:10]==str(message.guild.id)[:10]:
                i=2
                while 1:
                    if workseet.cell(row=g,column=i).value==None:
                        wi=[False,0]
                        break
                    if workseet.cell(row=g,column=i).value==username:
                        wi=[g,i+1]
                        break
                    i+=2
                break
            g+=1
        excel.save("gymanstack.xlsx")
        if not wi[0]:
            await message.channel.send("아직까지 이서버에서 기만한 적이 없습니다")
        else:
            counted=str(userip[0])+"님의 지금까지 기만한 횟수는 "+str(workseet.cell(row=wi[0],column=wi[1]).value)+"번입니다"
            await message.channel.send(counted)
        excel.close()
    
    if message.content.startswith("~system"):
        userip=str(message.author).split("#")
        if not deln(userip[0]):
            msg=message.content[8:].split()
            if len(msg)==1:
                if msg[0]=="on":system=1
                elif msg[0]=="off":system=0
                else:await message.channel.send("please say on or off")
                if msg[0]=="on"or msg[0]=="off":await message.channel.send("on" if system==1 else "off")
        else:
            await message.channel.send("당신은 관리자가 아닙니다")

    if message.content.startswith("~fan"):
        msg=message.content[5:];msg+="님 팬이에요";await message.channel.send(msg)

    if message.content.startswith("~cute"):
        #await message.channel.send("누군가 때문에 지움 ㅅㄱ")
        msg=str(message.content[6:])
        if system==0:
            if deln(msg):msg+="님 귀여워요~";await message.channel.send(msg)
            else:await message.channel.send("그 이름은 금지 되어있습니다")
        else:
            msg+="님 귀여워요~";await message.channel.send(msg)

    if message.content.startswith("~help"):
        ms=""
        ms+="팬이에요 : ~fan nickname\n\n"
        ms+="귀여워요:~cute nickname\n\ngood:~good\n\ngyman:~gyman nickname(정지)\n\ngod:~god nickname\n\n"
        ms+="지원하는 사이트:baekjoon(boj)(백준),codeup(코드업),solved.ac(고치는중),koistudy(코이스터디),codeforces(코포,코드포스)\n\n"
        ms+="ps site:~ps sitename\n\npssite number:~ps sitename number\n\n"
        ms+="ps site profile:~ps sitename profile name\n\n"
        ms+="ps site rank:~ps sitename rank pagenumber\n\n"
        ms+="solved.ac rank tier:~ps solved.ac rank (ti or 티어) pagenumber\n\n"
        ms+="solved.ac rank class:~ps solved.ac rank (cl or 클래스) pagenumber\n\n"
        ms+="solved.ac rank contribution(기여도):~ps solved.ac rank (co or 기여도) pagenumber\n\n"
        ms+="ps codeforces rank korea:~ps codeforces rank korea pagenumber\n\n"
        ms+="ps sitename search:~ps sitename search sitenamename(검색할 단어)\n\n"
        ms+="기만 랭킹:~gyman ranking\n\n"
        ms+="자신의 기만 횟수:~gymanstack me\n\n"
        ms+="백준 해당 문제 제출기록:~ps boj stat 문제번호\n\n"
        msg=await message.channel.send(message.channel,embed=discord.Embed(title="test bot help",description=ms,color=0x62c1cc))
        await msg.edit(content="")
        
    #if message.content.startswith("~gyman"):
    #    #await message.channel.send("별게 다 뚫리네ㅡㅡ")
    #    msg=str(message.content[7:])
    #    if system==0 and not deln(msg):
    #        await message.channel.send("기만이 아닙니다")
    #    else:
    #        msg+="님 기만";await message.channel.send(msg)
        
    if message.content.startswith("~god"):
        msg=str(message.content[5:])
        if system==0:
            if deln(msg):msg+="님 갓";await message.channel.send(msg)
            else:await message.channel.send("갓이 아닙니다")
        else:
            msg+="님 갓";await message.channel.send(msg)
        
    if message.content.startswith("~ps"):
        ex=message.content[4:].split()
        if len(ex)!=0:
            if ex[0]=="codeup"or ex[0]=="코드업":
                await message.channel.send(codeup(ex))
            elif ex[0]=="boj"or ex[0]=="baekjoon"or ex[0]=="백준":
                File=open("boj.txt","r")
                line=File.readlines()
                qa=line[0][:len(line[0])-1].split(",")
                userip=str(message.author).split("#")
                if "#"+userip[1] in qa:
                    index=qa.index("#"+userip[1])
                    usern=line[index+1][:len(line[index+1])-1]
                    qy=boj(ex)
                    if qy[1]==3:
                        try:
                            res=requests.get(qy[0])
                            url=qy[0]
                            soup=BeautifulSoup(res.content,'html.parser')
                            psname=list(str(soup.html.head.title))
                            nm=str("".join(psname[psname.index(">")+1:psname.index("/")-1]))
                            nm+="\n"
                            nm+=url+"\n\n"
                            vle=ac(usern,ex[1])
                            if vle==1:
                                nm="```diff\n+맞은문제+\n```\n"+nm
                            elif vle==2:
                                nm="```diff\n-틀린문제-\n```\n"+nm
                            elif vle==3:
                                nm="```cs\n#만점을 받지 못한 문제#\n```\n"+nm
                            elif vle==4:
                                nm="```\n제출한적이 없습니다\n```\n"+nm
                            url="https://www.acmicpc.net/problem/status/"+ex[1]
                            res=req.urlopen(url)
                            res=res.read()
                            soup=BeautifulSoup(res,'html.parser')
                            pr=0
                            pt=[]
                            pq=""
                            for i in range(1,15):
                                statvalue=0
                                statname=str(link("#statics > tbody > tr:nth-child("+str(i)+") > th",soup))
                                if statname!="평균 시도"and statname!="정답 비율"and statname!="제출한 사람"and statname!="맞은 사람":statvalue=str(link("#statics > tbody > tr:nth-child("+str(i)+") > td > a",soup))
                                if statname=="제출":pt.append(["제출 횟수:"+statvalue+"번\n\n",statvalue])
                                if statname=="맞았습니다":pt.append(["맞았습니다:"+statvalue+"번",statvalue]);pr+=int(statvalue)
                                if statname=="틀렸습니다":pt.append(["틀렸습니다:"+statvalue+"번",statvalue]);pr+=int(statvalue)
                                if statname=="시간 초과":pt.append(["시간 초과:"+statvalue+"번",statvalue]);pr+=int(statvalue)
                                if statname=="메모리 초과":pt.append(["메모리 초과:"+statvalue+"번",statvalue]);pr+=int(statvalue)
                                if statname=="출력 초과":pt.append(["출력 초과:"+statvalue+"번",statvalue]);pr+=int(statvalue)
                                if statname=="런타임 에러":pt.append(["런타임 에러:"+statvalue+"번",statvalue]);pr+=int(statvalue)
                                if statname=="컴파일 에러":pt.append(["컴파일 에러:"+statvalue+"번",statvalue]);pr+=int(statvalue)
                                if statname=="컴파일 에러":break

                            pr/=100
                                
                            for i in range(len(pt)):
                                if i!=0:pq+=pt[i][0]+"\n"+format(int(pt[i][1])/pr,".2f")+"%\n\n"
                                else:pq+=pt[i][0]
                            msg=await message.channel.send(message.channel,embed=discord.Embed(title="statistics",description=nm+pq,color=0x62c1cc))
                            await msg.edit(content="")
                        except HTTPError as e:
                            await message.channel.send("문제 번호가 잘못되었습니다")
                        
                    elif qy[1]==1:
                        try:
                            qr=""
                            url=qy[0]
                            res=req.urlopen(url)
                            res=res.read()
                            soup=BeautifulSoup(res,'html.parser')
                            psname=str(soup.html.head.title)
                            print(psname)
                            qr+="**"+ex[2]+"**\n\n"
                            qr+="랭킹:"+str(link("#statics > tbody > tr:nth-child(1) > td",soup))+"위\n\n"
                            qr+=qy[0]
                            msg=await message.channel.send(message.channel,embed=discord.Embed(title="",description=qr,color=0x62c1cc))
                            await msg.edit(content="")
                        except HTTPError as e:
                            await message.channel.send("유저 이름이 잘못되었습니다")
                    elif qy[1]==2:
                        qh=0
                        if len(ex)>=3:
                            qh=int(ex[2])
                            uy=chan(qh)
                            if uy[1]:
                                qh=1
                                await message.channel.send(uy[0])
                            else:
                                msg1=await message.channel.send(message.channel,embed=discord.Embed(title="",description=uy[0],color=0x62c1cc))
                                await msg1.edit(content="")
                                await msg1.add_reaction("\U00002B05")
                                await msg1.add_reaction("\U000027A1")
                        else:
                            qh=1
                            uy=chan(qh)
                            if uy[1]:
                                await message.channel.send(uy[0])
                            else:
                                msg1=await message.channel.send(message.channel,embed=discord.Embed(title="",description=uy[0],color=0x62c1cc))
                                await msg1.edit(content="")
                                await msg1.add_reaction("\U00002B05")
                                await msg1.add_reaction("\U000027A1")
                    else:
                        await message.channel.send(qy[0])
                else:
                    yu="이 기능을 사용하려면 아이디 추가를 해줘야합니다 아이디 추가하는 방법은 ~add 백준 닉네임 이렇게 치시면 됩니다."
                    await message.channel.send(yu)
                File.close()
            elif ex[0]=="solved.ac":
                await message.channel.send("고치는 중")
                #await message.channel.send(solved(ex))
            elif ex[0]=="koistudy"or ex[0]=="코이스터디":
                if len(ex)==1:await message.channel.send("http://koistudy.net/")
                else:
                    if ex[1]=="rank"or ex[1]=="랭크"or ex[1]=="순위":
                        if len(ex)==2:await message.channel.send("http://koistudy.net/?mid=rank")
                        else:
                            page="http://koistudy.net/?mid=rank&TH=&SEARCH=&pg="+str(int(ex[2])-1)+"&WORD="
                            await message.channel.send(page)
                    elif ex[1]=="profile"or ex[1]=="프로필":
                        if len(ex)==3:
                            q="http://koistudy.net/?mid=view_prob&id="+ex[2]
                            await message.channel.send(q)
            elif ex[0]=="codeforces"or ex[0]=="코포"or ex[0]=="코드포스":
                if len(ex)==1:await message.channel.send("https://codeforces.com/")
                else:
                    if ex[1]=="profile"or ex[1]=="프로필":
                        if len(ex)==3:
                            q="https://codeforces.com/profile/"+ex[2]
                            await message.channel.send(q)
                    if ex[1]=="rank"or ex[1]=="랭크"or ex[1]=="순위":
                        if len(ex)>=3 and (ex[2]=="korea"or ex[2]=="한국"):
                            if len(ex)==3:await message.channel.send("https://codeforces.com/ratings/country/South%20Korea")
                            elif len(ex)==4:
                                page="https://codeforces.com/ratings/country/South%20Korea/page/"+ex[3]
                                await message.channel.send(page)
                        elif len(ex)==2:await message.channel.send("https://codeforces.com/ratings")
                        else:
                            page="https://codeforces.com/ratings/page/"+ex[2]
                            await message.channel.send(page)

@client.event
async def on_reaction_add(reaction,user):
    global qh,system,msg1
    if user.bot==1:
        return None
    if str(reaction.emoji)=="\U000027A1":
        qh+=1
        uy=chan(qh)
        if uy[1]:
            qh-=1
            await reaction.message.channel.send(uy[0])
        else:
            await msg1.delete()
            msg1=await reaction.message.channel.send(reaction.message.channel,embed=discord.Embed(title="",description=uy[0],color=0x62c1cc))
            await msg1.edit(content="")
            await msg1.add_reaction("\U00002B05")
            await msg1.add_reaction("\U000027A1")
    if str(reaction.emoji)=="\U00002B05":
        qh-=1
        qh=max(1,qh)
        uy=chan(qh)
        if uy[1]:
            qh+=1
            await reaction.message.channel.send(uy[0])
        else:
            await msg1.delete()
            msg1=await reaction.message.channel.send(reaction.message.channel,embed=discord.Embed(title="",description=uy[0],color=0x62c1cc))
            await msg1.edit(content="")
            await msg1.add_reaction("\U00002B05")
            await msg1.add_reaction("\U000027A1")
                
client.run("이건 알려주면 안되지~")

'개발' 카테고리의 다른 글

2048게임 제작  (5) 2021.02.28
디스코드 봇 업데이트  (0) 2021.02.08
tile게임 만들기  (0) 2021.01.15
오목 게임 만들기  (0) 2021.01.13
얼불춤 만들기(A Dance of Fire and Ice)  (3) 2021.01.09
댓글