디스코드 봇 코딩
학교에서 진행한 프로젝트의 일환이었습니다.
그냥 친구들과 재미있게 쓰려고 만들었습니다.
import discord, asyncio, os
from discord.ext import commands
import random
from bs4.element import NavigableString
from bs4 import BeautifulSoup
import requests
game = discord.Game("개발")
bot = commands.Bot(command_prefix='!', status=discord.Status.online, activity=game)
@bot.event
async def on_ready():
print("We have loggedd in as {0.user}".format(bot))
@bot.command(aliases=['안녕','hi','하잉','하이'])
async def hello(ctx):
await ctx.send(f"{ctx.author.mention}죽여벌랑")
@bot.command(aliases=['주사위','굴려'])
async def roll(ctx,number:int):
await ctx.send(f"{ctx.author.mention}는 {random.randint(1,int(number))}이 나왔습니다 (1~{number})")
@bot.event
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandNotFound):
await ctx.send("명령어를 찾지 못했습니다")
@bot.command(aliases=['**불러])
async def ssyeon(ctx):
for i in range(0,5):
await ctx.send('<@아이디코드>\n')
@bot.command(aliases=['너누구야','누구세요'])
async def 소개(ctx):
embed = discord.Embed(title='제 소개를 해볼게요!',
description='궁금해하실 것 같은 항목들을 미리 준비해놨어요!',
colour=0xff7676)
embed.add_field(name='> 취미', value='코파기')
embed.add_field(name='> 좋아하는 것', value='<@아이디코드>')
embed.add_field(name='> 싫어하는 것', value='개강\r\n공부\r\n시험')
embed.set_footer(text='더 알려고하지마세요! 다칠 수 있어요.')
embed.set_thumbnail(url='https://blog.kakaocdn.net/dn/Fkmpe/btqDQuv6ebW/sqNnY8Mu7S76EiAeKgq1Ok/img.gif')
await ctx.channel.send(embed=embed)
login_url = 'https://ecampus.smu.ac.kr/login/index.php'
class2021_url = 'https://ecampus.smu.ac.kr/local/ubion/user/?year=2021&semester=20'
user_info = {
'username':'비공개',
'password':'비공개!'
}
with requests.Session() as s:
request = s.post(login_url, data = user_info)
request2 = s.post(class2021_url, data = user_info)
if(request.status_code == 200):
bs = BeautifulSoup(request2.text, 'html.parser')
rates = bs.find_all("td", {"class", "text-center"})
rate_list = []
f_rate = []
for rate in rates:
rate_list.append(str(rate.text))
for word in rate_list:
if '%' in word:
f_rate.append(word)
lectures = bs.select('#region-main > div > div > div.course_lists > div > table > tbody > tr > td > div >a')
lecture_list = []
for lecture in lectures:
lecture_list.append(lecture.text)
@bot.command(aliases=['강의','내강의'])
async def mlecture(ctx):
embed = discord.Embed(title='얘 너의 강의란다',
description='얘는 지가 공부좀 하는줄 알아!',
colour=0xff7676)
for lecture in lectures:
embed.add_field(name='>강의 ', value = lecture.text)
embed.set_footer(text='알았으면 공부나해!')
embed.set_thumbnail(url='https://clips-media-assets2.twitch.tv/AT-cm%7C715944196-preview-480x272.jpg')
await ctx.channel.send(embed=embed)
bot.run('비공개')
Author And Source
이 문제에 관하여(디스코드 봇 코딩), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://velog.io/@honmonoooooooooo/디스코드-봇-코딩저자 귀속: 원작자 정보가 원작자 URL에 포함되어 있으며 저작권은 원작자 소유입니다.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)