Commit c4fd80a8 authored by IS1_4M's avatar IS1_4M
Browse files

fixed removemessage command and added fixed auth

parent be925359
......@@ -155,6 +155,23 @@ class AbstractChanSuite:
# remove from the list, i guess
pass
'''
Adds a private voice channel for cli organizers only
'''
async def add_private_voice_chan(chan, channelName, CLIUserRoleName, CLIUserPermissions):
CLIUserRoleName = chan.name + ' ' + CLIUserRoleName
new_channel = await AbstractChanSuite.add_voice_channel(chan, channelName)
for role in chan.guild:
new_channel.set_permissions(role, read_messages=False, send_messages=False, connect=False, speak=False)
await new_channel.set_permissions(AbstractChanSuite.get_role(chan, CLIUserRoleName), CLIUserPermissions)
async def add_private_text_chan(chan, channelName, CLIUserRoleName, CLIUserPermissions):
CLIUserRoleName = chan.name + ' ' + CLIUserRoleName
new_channel = await AbstractChanSuite.add_text_channel(chan, channelName)
for role in chan.guild:
new_channel.set_permissions(role, read_messages=False, send_messages=False, connect=False, speak=False)
await new_channel.set_permissions(AbstractChanSuite.get_role(chan, CLIUserRoleName), CLIUserPermissions)
'''
add text channel to resolved club category channel
'''
......
......@@ -35,7 +35,7 @@ def is_auth(channel, auth_channel_name):
auth_channel = 'auth'
domain_dest = '@earlham.edu'
send_account_email='earlhamhackerscontrol@gmail.com'
with open('../../../ECHackersBotCreds/credentials.json') as file:
with open('../../../ECHackersBotCreds/credentials_test_bot.json') as file:
credentials = json.load(file)
student_role_name = 'ECStudent'
......@@ -96,13 +96,15 @@ async def on_message(message):
if content.startswith('!auth'): # this allows users to put in their codes
if await auth_user.authenticate(content[len('!auth '):].upper(), student_role_name, faculty_role_name) == True:
users.remove(auth_user)
await message.channel.send('Authenticatoin succeeded... Moving to Full Discord', delete_after = 3)
await message.channel.send('Authenticatoin succeeded... Moved you to the full discord. Look at all channels for information!', delete_after = 5)
else:
await message.channel.send('Authentication failed... ' + content[len('!auth '):] + ' is not the correct auth code', delete_after = 3)
else: #anything else is ![prefix] which files an email attempt
if '@' in content:
content = content[:content.index('@')]
print('sent email to ' + content[len('!'):])
auth_user.send_auth_email_to_addr(content[len('!'):], domain_dest,send_account_email, account_password)
await message.channel.send('Send auth code to: ' + content[len('!'):], delete_after = 3)
await message.channel.send('Send auth code to: ' + content[len('!'):] + '@earlham.edu', delete_after = 3)
#run(killer)
await message.delete(delay=3)
return
......
......@@ -15,7 +15,9 @@ def get_member_by_discord_name(guild, discord_name):
class Club(AbstractChannel): # Creates a club category channel with CLUB MEMBER role read and write permissions for club members and CLI access for club convenors
Convenor_cli_permissions = {'read_messages':True,
'send_message':True}
'send_message':True,
'connect':True,
'speak':True} # WIP Project
Member_permissions = {'read_messages':True,
'send_messages':True,
'connect':True,
......@@ -132,6 +134,9 @@ class ClubSuite(AbstractChanSuite):
send_text += command + '\n\t'
return send_text
async def add_private_voice_chan(club, channelName):
await AbstractChanSuite.add_private_voice_chan(club, channelName, Club.convener_role_name, Club.Convenor_cli_permissions)
async def process_cli_commands(message):
content = message.content.lower()
message_parts = content.split(' ')
......@@ -150,6 +155,12 @@ class ClubSuite(AbstractChanSuite):
return True
elif content.startswith('!removevoicechannel'): # remove club voice channel
await ClubSuite.remove_voice_channel(club, content[len('!removevoicechannel '):].replace(' ', '-')); return True
elif content.startswith('#!newpvoicechannel'):
await ClubSuite.add_private_voice_chan(club, content[len('!newpvoicechannel '):])
elif content.startswith('#!newptextchannel'):
await ClubSuite.add_private_text_chan(club, content[len('!newptextchannel '):])
elif content.startswith('!closeclub'):
await ClubSuite.delete_category(club); return True
elif content.startswith('!addmember'):
......@@ -167,17 +178,19 @@ class ClubSuite(AbstractChanSuite):
for pin in await message.channel.pins():
if pin.content.startswith("DESCRIPTION SET TO:"):
await pin.unpin()
await (await message.channel.send('DESCRIPTION SET TO: ' + content[len('!describe '):])).pin()
await (await message.channel.send('DESCRIPTION SET TO: ' + message.content[len('!describe '):])).pin()
return True
elif content.startswith('!pin'):
terms = content.split(' ')
terms = message.content.split(' ')
terms[1] = message_parts[1]
if len(terms) < 3:
await message.channel.send('!pin requires 3 things! Here\'s an example: !pin MyClubTextChannel what I want to pin and you can include spaces here', delete_after = 10)
channel = await ClubSuite.get_text_channel(club, terms[1])
if channel != False:
await (await channel.send(' '.join(terms[2:]))).pin()
elif content.startswith('!unpin'):
terms = content.split(' ')
terms = message.content.split(' ')
terms[1] = message_parts[1]
if len(terms) < 3:
await message.channel.send('!pin requires 3 things! Here\'s an example: !pin MyClubTextChannel what I want to pin and you can include spaces here', delete_after = 10)
channel = await ClubSuite.get_text_channel(club, terms[1])
......@@ -189,7 +202,8 @@ class ClubSuite(AbstractChanSuite):
return True
await message.channel.send('Couldn\'t find "' + content + '" in ' + terms[1], delete_after = 10)
elif content.startswith('!removemessage'):
terms = content.split(' ')
terms = message.content.split(' ')
terms[1] = message_parts[1]
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])
......
......@@ -108,12 +108,14 @@ class PubChanSuite(AbstractChanSuite):
async def process_cli_commands(message):
content = message.content.lower()
message_parts = content.split(' ')
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(' ')
terms = message.content.split(' ')
terms[1] = message_parts[1]
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])
......
......@@ -10,7 +10,7 @@ from datetime import datetime
from random import random
import json
with open('../../../ECHackersBotCreds/credentials.json') as file:
with open('../../../ECHackersBotCreds/credentials_test_bot.json') as file:
credentials = json.load(file)
auth_channel = 'auth'
......@@ -140,7 +140,7 @@ You should see an email from earlhamhackerscontrol@gmail.com in your zimbra emai
def valid_student_email(earlham_email_handle):
year = User.is_int(earlham_email_handle[-2:])
return (year and 16 <= year <= 20)
return (year and 17 <= year <= 20)
class ECMember:
def __init__(self):
# give them access to information channel and meet & greet channels.
......
......@@ -110,6 +110,7 @@ class RestrictChanSuite(AbstractChanSuite):
return send_text
async def process_cli_commands(message):
content = message.content.lower()
message_parts = content.split(' ')
res_chan = AbstractChanSuite.is_cli(AbstractChanSuite.get_all_chans(message.guild, RestrictChan.channel_type), message.channel, RestrictChan.convener_role_name)
if not res_chan:
return False # Did not process commands
......@@ -122,7 +123,8 @@ class RestrictChanSuite(AbstractChanSuite):
elif content.startswith('!removevoicechannel'):
await RestrictChanSuite.remove_voice_channel(res_chan, content[len('!removevoicechannel '):])
elif content.startswith('!removemessage'):
terms = content.split(' ')
terms = message.content.split(' ')
terms[1] = message_parts[1]
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])
......
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