discord rebot
1.0.0
Discordrebot เป็นกรอบการทำแผนที่คำสั่ง Regex Discord Bot Bot พร้อม การอนุญาต
Discordrebot ใช้งานง่ายน้อยที่สุดและ Async Ready Framework โดยใช้ discord.py
บอทส่วนใหญ่ใช้คำนำหน้าเดียวสตริงเพื่อจับคู่คำสั่งและ args แยกตามช่องว่างตัวอย่าง !cmd arg1 arg2
แต่ Discordrebot ใช้ Regex สำหรับทั้งคู่ที่ตรงกับคำสั่งและการจับอาร์กิวเมนต์ มันให้การควบคุมมากขึ้นทั้งการจับคู่คำสั่งและการแยกวิเคราะห์อาร์กิวเมนต์
นอกจากนี้ยังมีการอนุญาตให้อนุญาตผู้เขียนข้อความก่อนที่จะดำเนินการคำสั่ง
บอทขั้นต่ำพร้อมคำสั่ง Echo
from discordRebot import *
client = discord . Client ()
key = Mapper ()
@ key ( re . compile ( r"^!echo (.*)$" )) # Eg: '!echo hello' -> 'hello'
def echo ( msg , string ):
return string
echo . auth = None
client . event ( Manager ( key ). on_message )
import os ; client . run ( os . environ [ "DBToken" ])คุณสามารถค้นหาตัวอย่างเพิ่มเติมในไดเรกทอรีตัวอย่าง
นอกจากนี้ยังรองรับ
@ key ( re . compile ( r"^!ticker (d*) (d*)$" ))
async def ticker ( msg , delay , to ):
delay , to = int ( delay ), int ( to )
for i in range ( to ):
yield i
await asyncio . sleep ( delay ) อนุญาตให้ผู้เขียนข้อความ
ขึ้นอยู่กับ
1234567890'user#1234' @ key ( "am i authorized ?" )
def amiauthorized ( msg ):
return "Authorized"
amiauthorized . auth = { 1234567890 , 'user#1234' }
# only executable by user1 (with id 1234567890) and user2 (with username 'user#1234')สามารถจับคู่คำสั่งหลายคำด้วยข้อความ
@ key ( re . compile ( r"^([sS]*)$" ))
def printmsg ( msg , content ):
print ( f"@ { msg . author } :" )
print ( content )
@ key ( "whereami" )
def whereami ( msg ):
if msg . guild :
return msg . guild . name
else :
return "DM"
Discord-reargparse (สำหรับบอท Discord ที่โดดเด่นด้วย argparsing ตาม Regex ในคำสั่ง)