How can I make Twitch Bot commands available to managers only? Some commands are only available to the manager, and some commands are available to everyone.
that is my code:
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()
Expand your code to support reading IRCv3 tags.
You'll need to enable the tags capability
Send
CAP REQ :twitch.tv/tags
Before joining any rooms
Then read the badges
of the tags of a PRIVMSG
and look for the broadcaster
or moderator
badge existing in the badges
key of the IRCv3 Tags
For example:
@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;tmi-sent-ts=1614265271314;turbo=0;user-id=15185913;user-type=mod :barrycarlyon!barrycarlyon@barrycarlyon.tmi.twitch.tv PRIVMSG #somechannel :test
You can see I have the moderator
and ambassador
badges.