async def is_invoked_by_message(message: Message, client: Client): ca: ChannelAuthority = ChannelAuthority(message.guild) if message.content.startswith("!request"): qa: QueueAuthority = QueueAuthority(message.guild) if not qa.is_office_hours_open(): warning = await message.channel.send( "Office hours are closed. Please try again after they have opened.".format( message.author.mention, ca.waiting_channel.mention)) await warning.delete(delay=7) await message.delete() return False if qa.is_member_in_queue(message.author): warning = await message.channel.send( "{} you are already in the queue. Please continue waiting.".format( message.author.mention, ca.waiting_channel.mention)) await warning.delete(delay=7) await message.delete() return False if message.channel == ca.waiting_channel: return True else: warning = await message.channel.send("{} you must be in {} to request a place in the queue.".format( message.author.mention, ca.waiting_channel.mention)) await warning.delete(delay=7) await message.delete() return False return False
async def handle(self): qa: QueueAuthority = QueueAuthority(self.guild) ca: ChannelAuthority = ChannelAuthority(self.guild) # Remove TA from list of available TAs. if "force" in self.message.content: qa.force_close_office_hours() await ca.queue_channel.send( command.name(self.message.author) + " has forced OH to close.") await ca.waiting_channel.send( "Ok, y'all. Office hours have ended for now. An announcement will appear here when they have reopened." ) return is_open, was_removed, ta_count = qa.close_office_hours( self.message.author.id) if ta_count > 0 and is_open and was_removed: await ca.queue_channel.send( command.name(self.message.author) + " has checked out of office hours.") # Last TA was removed, or TA queue was empty when called elif ta_count <= 0 and is_open: await qa.remove_all() await ca.queue_channel.send( command.name(self.message.author) + " has closed office hours!") await ca.waiting_channel.send( "Ok, y'all. Office hours have ended for now. An announcement will appear here when they have reopened." ) logger.info("Office hours closed by {}".format( command.name(self.message.author)))
async def handle(self): qa: QueueAuthority = QueueAuthority(self.guild) request = "[Student did not supply text]" if " " in self.message.content: # remove the !request from the front of the message request = " ".join(self.message.content.split()[1:]) ca: ChannelAuthority = ChannelAuthority(self.guild) # Build embedded message color = discord.Colour(0).blue() embeddedMsg = discord.Embed(description=request, timestamp=dt.now(), colour=color) author: Member = self.message.author embeddedMsg.set_author(name=command.name(author)) embeddedMsg.add_field(name="Accept request by typing", value="!accept") embeddedMsg.add_field(name="Reject request by typing", value="!reject {} [text to be sent to student]".format(author.id)) # Send embedded message announcement = await ca.queue_channel.send(embed=embeddedMsg) qa.add_to_queue(author, request, announcement) await self.message.delete() logger.info("{} added to queue with request text: {}".format( command.name(author), request ))
async def handle(self): qa: QueueAuthority = QueueAuthority(self.guild) qa.remove_all() ca: ChannelAuthority = ChannelAuthority(self.guild) await ca.waiting_channel.send( "Ok, y'all. Office hours have ended for now. An announcement will appear here when they have reopened.") logger.info("Office hours closed by {}".format( name(self.message.author) ))
async def handle(self): qa: QueueAuthority = QueueAuthority(self.guild) qa.open_office_hours() ca: ChannelAuthority = ChannelAuthority(self.guild) await ca.waiting_channel.send( "Office hours are live. Get in line with !request") logger.info("Office hours opened by {}".format( name(self.message.author) ))
async def handle(self): qa: QueueAuthority = QueueAuthority(self.guild) student_id = self.message.content.split(" ")[1] student: Member = self.guild.get_member(int(student_id)) session: OHSession = await qa.find_and_remove_by_user_id(student) await session.announcement.delete() reject_message = " ".join(self.message.content.split(" ")[2:]) await student.send("Your request was fulfilled by the following message: {}".format(reject_message))
async def handle(self): qa: QueueAuthority = QueueAuthority(self.guild) ca: ChannelAuthority = ChannelAuthority(self.guild) # Add TA to list of available TAs. Return True if fresh opening, True if newly added TA fresh_open, is_new_ta = qa.open_office_hours(self.message.author.id) if fresh_open: await ca.queue_channel.send("Office hours are live!") await ca.waiting_channel.send( "Office hours are live. Get in line with !request") logger.info("Office hours opened by {}".format( command.name(self.message.author))) if is_new_ta: await ca.queue_channel.send( command.name(self.message.author) + " has checked into office hours!")
async def handle(self): qa: QueueAuthority = QueueAuthority(self.guild) queue = qa.retrieve_queue() if "id" in self.message.content: await self.message.author.send("Your id is {}. Your spot in the queue will appear here: {}".format( self.message.author.id, get_globals()["props"]["queue_url"], )) else: msg: Message = await self.message.channel.send( "Queue status can be viewed here: {}. Do `!status id` and I will DM you your id.".format( get_globals()["props"]["queue_url"] )) await msg.delete(delay=10) await self.message.delete()
async def handle(self): qa: QueueAuthority = QueueAuthority(self.guild) if not qa.is_ta_on_duty(self.message.author.id): await self.message.channel.send("You must be on duty to accept a request!") return # get oldest queue item (and also remove it) session: OHSession = await qa.dequeue(self.message.author) if not session: msg = await self.message.channel.send("No one is in the queue. Perhaps you're lonely?\n" "https://giphy.com/gifs/30-rock-liz-lemon-jack-donaghy-VuWtVHkMjrz2w") await msg.delete(delay=7) await self.message.delete() return # create role for channel role: Role = await self.guild.create_role(name="{}'s OH session".format(command.name(session.member)), hoist=True) num_roles = len(self.guild.roles) # todo find bot role insert this underneath # await role.edit(position=num_roles-2) session.role = role await session.member.add_roles(session.role) await self.message.author.add_roles(session.role) # create channel ra: RoleAuthority = RoleAuthority(self.guild) session_category: CategoryChannel = await self.guild.create_category_channel( "Session for {}".format(command.name(session.member)), overwrites={ role: PermissionOverwrite(read_messages=True, attach_files=True, embed_links=True), ra.student: PermissionOverwrite(read_messages=False), ra.un_authenticated: PermissionOverwrite(read_messages=False) }) text_channel: TextChannel = await session_category.create_text_channel("Text Cat") await session_category.create_voice_channel("Voice chat") session.room = session_category # attach user ids and channel ids to OH room info in channel authority ca: ChannelAuthority = ChannelAuthority(self.guild) await session.announcement.delete() await self.message.delete() ca.add_oh_session(session) await text_channel.send("Hi, {} and {}! Let the learning commence! Type !close to end the session!".format( session.member.mention, session.ta.mention, )) logger.info("OH session for {} accepted by {}".format( command.name(session.member), command.name(self.message.author)))
async def handle(self): qa: QueueAuthority = QueueAuthority(self.guild) # get oldest queue item (and also remove it) session: OHSession = await qa.dequeue(self.message.author) # create role for channel role: Role = await self.guild.create_role(name="{}'s OH session".format(name(session.member)), hoist=True) num_roles = len(self.guild.roles) # todo find bot role insert this underneath # await role.edit(position=num_roles-2) session.role = role await session.member.add_roles(session.role) await self.message.author.add_roles(session.role) # create channel ra: RoleAuthority = RoleAuthority(self.guild) session_category: CategoryChannel = await self.guild.create_category_channel( "Session for {}".format(name(session.member)), overwrites={ role: PermissionOverwrite(read_messages=True, attach_files=True, embed_links=True), ra.student: PermissionOverwrite(read_messages=False), ra.un_authenticated: PermissionOverwrite(read_messages=False) }) text_channel: TextChannel = await session_category.create_text_channel("Text Cat") await session_category.create_voice_channel("Voice chat") session.room = session_category # attach user ids and channel ids to OH room info in channel authority ca: ChannelAuthority = ChannelAuthority(self.guild) await session.announcement.delete() await self.message.delete() ca.add_oh_session(session) await text_channel.send("Hi, {} and {}! Let the learning commence! Type !close to end the session!".format( session.member.mention, session.ta.mention, )) logger.info("OH session for {} accepted by {}".format( name(session.member), name(self.message.author)))
def index(): queue = QueueAuthority.queue_for_web() for item in queue: item["member"] = item["member-id"] return render_template('index.html', queue=queue)