Commit be925359 authored by IS1_4M's avatar IS1_4M
Browse files

added message removal feature to organizer cmds

parent 6db616fc
......@@ -173,6 +173,13 @@ class AbstractChanSuite:
return True
return False
async def remove_text_msg_from_chan(channel, message_text):
async for text in channel.history(limit=100):
if text.content == message_text:
await text.delete()
return True
return False
'''
add text channel to resolved club category channel
'''
......
......@@ -187,7 +187,16 @@ class ClubSuite(AbstractChanSuite):
if pin.content == content:
await pin.unpin()
return True
await message.channel.send('!unpin requires 3 things! Here\'s an example: !pin TheClubChannelYourPinisin And what text copy pasted is in that pinned message', delete_after = 10)
await message.channel.send('Couldn\'t find "' + content + '" in ' + terms[1], delete_after = 10)
elif content.startswith('!removemessage'):
terms = content.split(' ')
if len(terms) < 3:
await message.channel.send('!removemessage requires 3 things! Here\'s an example: !removemessage MyClubTextChannel text from message i want to remove', delete_after = 10)
channel = await ClubSuite.get_text_channel(club, terms[1])
content = ' '.join(terms[2:])
if await ClubSuite.remove_text_msg_from_chan(channel, content):
return True
await message.channel.send('Couldn\'t find "' + content + '" in ' + terms[1], delete_after = 10)
elif content.startswith('!requestbot'):
await message.channel.send('We will get back to you soon with questions and information about your bot!')
return True#unimplemented. To implement Soon
......
......@@ -107,7 +107,21 @@ class PubChanSuite(AbstractChanSuite):
return send_text
async def process_cli_commands(message):
return False
content = message.content.lower()
o_chan = AbstractChanSuite.is_cli(AbstractChanSuite.get_all_chans(message.guild, PublicChan.channel_type), message.channel, PublicChan.convener_role_name)
if not o_chan:
return False # Did not process commands
if content.startswith('!removemessage'):
terms = content.split(' ')
if len(terms) < 3:
await message.channel.send('!removemessage requires 3 things! Here\'s an example: !removemessage MyClubTextChannel text from message i want to remove', delete_after = 10)
channel = await PubChanSuite.get_text_channel(o_chan, terms[1])
content = ' '.join(terms[2:])
if await PubChanSuite.remove_text_msg_from_chan(channel, content):
return True
await message.channel.send('Couldn\'t find "' + content + '" in ' + terms[1], delete_after = 10)
async def process_user_commands(message):
content = message.content.lower()
......@@ -124,7 +138,6 @@ class PubChanSuite(AbstractChanSuite):
return True
elif content.startswith('!removetextchannel'):
if target + ' ' + channel + ' Starter' in [role.name for role in message.author.roles]:
pubchan = PubChanSuite.get_pubchan(PubChanSuite.get_all_pubchans(message.channel.guild), target)
for role in message.channel.guild.roles:
if role.name == target + channel + ' Starter':
await message.author.remove_roles(role)
......@@ -147,6 +160,6 @@ class PubChanSuite(AbstractChanSuite):
break
await PubChanSuite.remove_voice_channel(pubchan, channel)
return True
return False
return False
async def process_commands(message):
return await PubChanSuite.process_cli_commands(message) or await PubChanSuite.process_user_commands(message)
\ No newline at end of file
......@@ -121,6 +121,15 @@ class RestrictChanSuite(AbstractChanSuite):
await RestrictChanSuite.add_voice_channel(res_chan, content[len('!addvoicechannel '):])
elif content.startswith('!removevoicechannel'):
await RestrictChanSuite.remove_voice_channel(res_chan, content[len('!removevoicechannel '):])
elif content.startswith('!removemessage'):
terms = content.split(' ')
if len(terms) < 3:
await message.channel.send('!removemessage requires 3 things! Here\'s an example: !removemessage MyClubTextChannel text from message i want to remove', delete_after = 10)
channel = await RestrictChanSuite.get_text_channel(res_chan, terms[1])
content = ' '.join(terms[2:])
if await RestrictChanSuite.remove_text_msg_from_chan(channel, content):
return True
await message.channel.send('Couldn\'t find "' + content + '" in ' + terms[1], delete_after = 10)
return True
async def process_user_commands(message):
# Check if a valid command and respond accordingly if so.
......@@ -135,15 +144,21 @@ class RestrictChanSuite(AbstractChanSuite):
if rschan:
if content.startswith('!addtextchannel'):
await rschan_cli.send(message.author.name + ' would like to add a text channel to this restricted group: ' + addchanname + '. Would anyone like to take care of that?')
await message.channel.send('We heard your request. Our moderators will respond to your request soon :)', delete_after = 5)
return True
# remove a text channel from a hangout space.
elif content.startswith('!removetextchannel'):
await rschan_cli.send(message.author.name + ' would like to remove a text channel to this restricted group: ' + addchanname + '. Would anyone like to take care of that?')
await message.channel.send('We heard your request. Our moderators will respond to your request soon :)', delete_after = 5)
return True
elif content.startswith('!addvoicechannel'):
await rschan_cli.send(message.author.name + ' would like to add a voice channel to this restricted group: ' + addchanname + '. Would anyone like to take care of that?')
await message.channel.send('We heard your request. Our moderators will respond to your request soon :)', delete_after = 5)
return True
elif content.startswith('!removevoicechannel'):
await rschan_cli.send(message.author.name + ' would like to remove a voice channel to this restricted group: ' + addchanname + '. Would anyone like to take care of that?')
await message.channel.send('We heard your request. Our moderators will respond to your request soon :)', delete_after = 5)
return True
await message.channel.send('We heard your request. Our moderators will respond to your request soon :)', delete_after = 5)
return True
return False
async def process_commands(message):
return await RestrictChanSuite.process_cli_commands(message) or await RestrictChanSuite.process_user_commands(message)
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment