GLaDOS/proposal/dynamic.py

37 lines
1.3 KiB
Python

# Import the relevant bot and libraries
from main import my_bot
import uuid
# Setup some global vars
vip_nicks = {"Darks"}
vip_channel = uuid.uuid4()
# Create a "private" function to handle the VIP channel
@my_bot.command("!vip")
def cmd_vip(msg):
if msg.author not in vip_nicks:
my_bot.send(msg.to, "Sorry but you're not a VIP. This command is for VIPs only.")
return
# No arguments, give the channel name as private message
if msg == "":
my_bot.send(msg.author, f"The VIP channel is #{vip_channel}")
# If message was send in a public channel, send a reminder
if msg.to.beginswith("#"):
my_bot.send(msg.to, "Check you private messages, {msg.author}.")
# Parse args
match(msg.text.split()):
case ["invite", nick]:
vip_nicks.add(nick)
my_bot.send(msg.to, f"{nick} is now a VIP.")
case ["exclude", nick]:
try:
vip_nicks.remove(nick)
my_bot.send(msg.to, f"{nick} is no longer a VIP.")
except KeyError:
my_bot.send(msg.to, f"{nick} not found in the VIPs.")
case ["list"]:
my_bot.send(msg.to, "VIPs are " + ", ".join(vip_nicks) + ".")
case _, :
my_bot.send(msg.to, "Invalid command. Valid ones are: `invite <nick>`, `exclude <nick>`, `list`.")