twitchio我怎样才能使Twitch Bot命令只对管理人员可用?



我怎样才能使Twitch Bot命令只对管理人员可用?有些命令只对管理员可用,有些命令对所有人都可用。

这是我的代码:

from twitchio.ext import commands
import openpyxl
from openpyxl import load_workbook
from decouple import config
temp_initial_channels = str(config('CHANNEL'))
temp_xlsx_name = str(config('XLSX_NAME'))
class Bot(commands.Bot):
def __init__(self):
super().__init__(irc_token=config('TMI_TOKEN'), client_id=config('CLIENT_ID'), nick=config('BOT_NICK'), prefix=config('BOT_PREFIX'),
initial_channels=[temp_initial_channels])
async def event_ready(self):
ws = bot._ws
await ws.send_privmsg("whitebot201", f"whitebot201 이 준비 완료 되었습니다!")
async def event_message(self, message):
print(message.content)
await self.handle_commands(message)

@commands.command(name='test')
async def test(self, ctx):
await ctx.send(f'test pass!!!')

bot = Bot()
bot.run()

扩展您的代码以支持读取IRCv3标签。

您需要启用标签功能

发送

CAP REQ:twitch.tv/tags

在加入任何房间之前

然后读取PRIVMSG标签的badges,查找IRCv3标签的badges密钥中存在的broadcastermoderator徽章

例如:

@badge-info=;badges=moderator/1,ambassador/1;client-nonce=ba9231972a6341b6370876a2eb159723;color=#033700;display-name=BarryCarlyon;emotes=;flags=;id=a69c4d4d-541f-4615-89e9-ba278580a2eb;mod=1;room-id=56410307;subscriber=0; tmisent -ts=1614265271314;turbo=0;user-id=15185913;

你可以看到我有moderatorambassador徽章。

最新更新