Commit 47a9e0c5 authored by IS1-4MJ's avatar IS1-4MJ
Browse files

added more emojis

parent dd3476d5
......@@ -15,6 +15,7 @@ from cryptography.fernet import Fernet
async def do_update(guild):
await AdminChanSuite.refresh_active_vars(guild)
await AdminChanSuite.ui_set_version(guild)
return 1
async def assert_auth(guild):
......@@ -207,6 +208,80 @@ class AdminChanSuite(AbstractChanSuite):
f = Fernet(key)
encrypted_string=encrypted_string.encode()
return f.decrypt(encrypted_string).decode()
async def ui_add_restrictchan(guild, author, name):
new_restrictChan = RestrictChan(guild, author, name)
return await new_restrictChan._init()
async def ui_add_pubchan(guild, author, name):
new_pubchan = PublicChan(guild, author, name)
return await new_pubchan._init(general_user_role_names)
async def ui_set_sender_name_as(guild, sender_name):
var_message = await AdminChanSuite.get_var_message(guild, 'sender_name=')
if var_message == -23:
return -23
return await AdminChanSuite.set_var(var_message, sender_name)
async def ui_set_authrole0_as(guild, authrole0name):
var_message = await AdminChanSuite.get_var_message(guild, 'auth_role_name0=')
if var_message == -23:
return -23
return await AdminChanSuite.set_var(var_message, authrole0name)
async def ui_set_authrole1_as(guild, authrole1name):
var_message = await AdminChanSuite.get_var_message(guild, 'auth_role_name1=')
if var_message == -23:
return -23
return await AdminChanSuite.set_var(var_message, authrole1name)
async def ui_set_auth_chan_name_as(guild, auth_chan_name):
var_message = await AdminChanSuite.get_var_message(guild, 'auth_channel_name=')
if var_message == -23:
return -23
return await AdminChanSuite.set_var(var_message, auth_chan_name)
async def ui_set_domain_dest_as(guild, dest):
var_message = await AdminChanSuite.get_var_message(guild, 'email_verification_destination_domain=')
if var_message == -23:
return -23
return await AdminChanSuite.set_var(var_message, dest)
async def ui_toggle_auth(guild):
var_message = await AdminChanSuite.get_var_message(guild, 'auth_channel_enabled=')
val_bool = await AdminChanSuite.get_auth_enabled(guild)
if not val_bool:
await assert_auth(guild)
auth_name = await AdminChanSuite.get_auth_channel_name(guild)
new_text = await AdminChanSuite.get_auth_chan_message(guild)
for channel in guild.text_channels:
if channel.name == auth_name:
for msg in await channel.pins(): # The only pinned message that can exist in auth is the one the bot sent lol
await msg.edit(content = new_text)
break
return await AdminChanSuite.set_var(var_message, str(not val_bool))
async def ui_set_welcome_message_as(guild, new_text):
var_message = await AdminChanSuite.get_var_message(guild, 'auth_channel_welcome_text=')
if var_message == -23:
return -23
await AdminChanSuite.set_var(var_message, new_text)
auth_name = await AdminChanSuite.get_auth_channel_name(guild)
for channel in guild.text_channels:
if channel.name == auth_name:
for msg in await channel.pins(): # The only pinned message that can exist in auth is the one the bot sent lol
await msg.edit(content = new_text)
break
return 1
async def ui_update(guild):
return await do_update(guild)
async def ui_set_version(guild):
var_message = await AdminChanSuite.get_var_message(guild, 'version=')
if var_message == -23:
return -23
return await AdminChanSuite.set_var(var_message, server_vars['version='])
async def process_cli_commands(message):
# for case sensitive commands
raw_text = message.content
......@@ -229,20 +304,15 @@ class AdminChanSuite(AbstractChanSuite):
pubName = lower_text_parts[1]
# Making a new channel should ALWAYS AUTOMATICALLY check for duplicates.
new_pubchan = PublicChan(message.guild, message.author, pubName)
return await new_pubchan._init(general_user_role_names)
return await AdminChanSuite.ui_add_pubchan(message.guild, message.author, pubName)
# when you come back, finish the auto check for dupes functions.
elif lower_text.startswith('!addrestrictchan'):
resName = lower_text_parts[1]
new_restrictChan = RestrictChan(message.guild, message.author, resName)
return await new_restrictChan._init()
return await AdminChanSuite.ui_add_pubchan(message.guild, message.author, resName)
elif lower_text.startswith('!setsendernameas '):
if len(raw_text_parts) != 2:
return -24
var_message = await AdminChanSuite.get_var_message(message.guild, 'sender_name=')
if var_message == -23:
return -23
return await AdminChanSuite.set_var(var_message, raw_text_parts[1])
sender_name = message.content[len('!setsendernameas '):]
return await AdminChanSuite.ui_set_sender_name_as(message.guild, sender_name)
elif lower_text.startswith('#!setemailpassas '):
if len(raw_text_parts) != 2:
return -24
......@@ -253,63 +323,29 @@ class AdminChanSuite(AbstractChanSuite):
if await AdminChanSuite.set_var(var_message, encrypted_pass) == 1:
return 8
elif lower_text.startswith('!setauthrole0as'):
if len(raw_text_parts) != 2:
return -24
var_message = await AdminChanSuite.get_var_message(message.guild, 'auth_role_name0=')
if var_message == -23:
return -23
return await AdminChanSuite.set_var(var_message, raw_text_parts[1])
authrole0name = message.content[len('!setauthrole0as '):]
return await AdminChanSuite.ui_set_authrole0_as(message.guild, authrole0name)
elif lower_text.startswith('!setauthrole1as'):
if len(raw_text_parts) != 2:
return -24
var_message = await AdminChanSuite.get_var_message(message.guild, 'auth_role_name1=')
if var_message == -23:
return -23
return await AdminChanSuite.set_var(var_message, raw_text_parts[1])
authrole1name = message.content[len('!setauthrole1as '):]
return await AdminChanSuite.ui_set_authrole1_as(message.guild, authrole1name)
elif lower_text.startswith('!setauthchannameas'):
if len(raw_text_parts) != 2:
return -24
var_message = await AdminChanSuite.get_var_message(message.guild, 'auth_channel_name=')
if var_message == -23:
return -23
return await AdminChanSuite.set_var(var_message, raw_text_parts[1])
return await AdminChanSuite.ui_set_auth_chan_name_as(message.guild, raw_text_parts[1])
elif lower_text.startswith('!setdestdomainas'):
if len(raw_text_parts) != 2:
return -24
var_message = await AdminChanSuite.get_var_message(message.guild, 'email_verification_destination_domain=')
if var_message == -23:
return -23
return await AdminChanSuite.set_var(var_message, raw_text_parts[1])
return await AdminChanSuite.ui_set_domain_dest_as(message.guild, raw_text_parts[1])
elif lower_text.startswith('!toggle_auth'):
var_message = await AdminChanSuite.get_var_message(message.guild, 'auth_channel_enabled=')
val_bool = await AdminChanSuite.get_auth_enabled(message.guild)
if not val_bool:
await assert_auth(message.guild)
auth_name = await AdminChanSuite.get_auth_channel_name(message.guild)
new_text = await AdminChanSuite.get_auth_chan_message(message.guild)
for channel in message.channel.guild.text_channels:
if channel.name == auth_name:
for msg in await channel.pins(): # The only pinned message that can exist in auth is the one the bot sent lol
await msg.edit(content = new_text)
break
return await AdminChanSuite.set_var(var_message, str(not val_bool))
return await AdminChanSuite.ui_toggle_auth(message.guild)
elif lower_text.startswith('!setwelcomemessageas '):
new_text = message.content[len('!setwelcomemessageas '):]
var_message = await AdminChanSuite.get_var_message(message.guild, 'auth_channel_welcome_text=')
if var_message == -23:
return -23
await AdminChanSuite.set_var(var_message, new_text)
auth_name = await AdminChanSuite.get_auth_channel_name(message.guild)
for channel in message.channel.guild.text_channels:
if channel.name == auth_name:
for msg in await channel.pins(): # The only pinned message that can exist in auth is the one the bot sent lol
await msg.edit(content = new_text)
break
return 1
return await AdminChanSuite.ui_set_welcome_message_as(message.guild, new_text)
elif lower_text.startswith('!update'):
return await do_update(message.guild)
return await AdminChanSuite.ui_update(message.guild)
return 0
'''
Case sensitive commands go second
'''
......@@ -320,4 +356,3 @@ class AdminChanSuite(AbstractChanSuite):
return await AdminChanSuite.process_cli_commands(message) or await AdminChanSuite.process_user_commands(message)
async def process_tasks(clis):
pass
\ No newline at end of file
......@@ -17,7 +17,7 @@ from restrictedchannel import RestrictChanSuite
from AbstractChannel import AbstractChanSuite
from AdminChannel import AdminChanSuite, AdminChannel
from SOCChannel import SOCChannelSuite
from UI import UI, AuthControlPanel, GeneralControlPanel
from UI import UI, AuthControlPanel, GeneralControlPanel, AdminControlPanel
from Auth import User, ghelp, authenticate, send_auth_code_to_user, make_new_member, process_auth
......@@ -185,7 +185,9 @@ async def on_message(message):
response = await AdminChanSuite.process_commands(message)
if response:
return await handle_response_codes(message, response)
if message.channel.id == AdminChanSuite.get_cli(AdminChanSuite.get_admincat(message.guild)).id:
if message.content.startswith('!commandpanel'):
return await AdminControlPanel._init_(message.channel)
'''
Check if the channel mentioned is a cli for a club. if so, perform club commands.
......@@ -263,6 +265,8 @@ async def on_message(message):
if response:
return await handle_response_codes(message, response)
# Always handle remaining response codes at the end.
return await handle_response_codes(message, response)
else:
......
......@@ -19,6 +19,15 @@ class EmailSuite:
#return (AdminChanSuite.get_send_email_addr(guild), AdminChanSuite.get_send_email_pass(guild))
return (aws_username,aws_pass)
def verify_email(to_email, login_username=aws_username, login_pass=aws_pass, from_email=send_account_email):
port = 465
context = ssl.create_default_context()
response = None
with smtplib.SMTP_SSL("email-smtp.us-east-1.amazonaws.com", port, context=context) as server:
server.login(login_username, login_pass)
response=server.verify(to_email)
server.close()
return response
def send_email_to_addr(to_email, message_subject, message_text,
login_username=aws_username, login_pass = aws_pass,
from_email = send_account_email,
......@@ -35,5 +44,4 @@ class EmailSuite:
response = server.sendmail(from_email, receiver_email, message)
server.close()
return response
\ No newline at end of file
return response
\ No newline at end of file
......@@ -113,6 +113,27 @@ class GeneralControlPanel(ControlPanel):
await ControlPanel.click(client, channel, selected_option, GeneralControlPanel.BUTTONS)
print('hello')
return CCONTROLPANELCLICKED
class AdminControlPanel(ControlPanel):
BUTTONS = {AADDPUBCHAN: 'Add an open channel',
AADDRESTRICTCHAN: 'Add a restricted channel',
ATOGGLEAUTH: "Toggle the auth channel",
ASETDESTDOMAINAS: "Change the email authentication goes to",
ASETSENDERNAMEAS: "Set the sender name of the authentication email",
ASETWELCOMEMESSAGEAS: "Set the welcome message in the auth channel",
ASETAUTHCHANNAMEAS: 'Change the auth channel name',
ASETAUTHROLE0AS: "Change the default role name",
ASETAUTHROLE1AS: "Change the special role name"
}
SIGNATURE='A'
async def _init_(channel):
await ControlPanel._init_(channel, AdminControlPanel.BUTTONS, AdminControlPanel.SIGNATURE)
return UCONTROLPANELADDITIONSUCCESS
async def click(client, channel, selected_option):
await ControlPanel.click(client, channel, selected_option, AdminControlPanel.BUTTONS)
return UCONTROLPANELCLICKED
class TextLister(ControlPanel):
BUTTONS = {GCLUBLIST:{GJOINCLUB: "joining a club",
......
......@@ -28,11 +28,16 @@ CSETUPEMAIL=16; CREQUESTBOT=17;CADDMEMBER=18; CADDCONVENER=19
OREMOVEMESSAGE=101
OOADDTEXTCHANNEL=700;OOREMOVETEXTCHANNEL=701;OOADDVOICECHANNEL=702;OOREMOVEVOICECHANNEL=703;
RRADDTEXTCHANNEL=800;RREMOVETEXTCHANNEL=801;RRADDVOICECHANNEL=802;RREMOVEVOICECHANNEL=803;
RADDTEXTCHANNEL=201;RREMOVETEXTCHANNEL=202;RADDVOICECHANNEL=203;RREMOVEVOICECHANNEL=204;
RREMOVEMESSAGE=205
AADDPUBCHAN=301;AADDRESTRICTCHAN=302;ASETSENDERNAMEAS=303;ASETAUTHROLE0AS=304;
ASETAUTHROLE1AS=305;ASETDESTDOMAINAS=306;ATOGGLE_AUTH=307;AUPDATE=308
ASETAUTHROLE1AS=305;ASETDESTDOMAINAS=306;ATOGGLEAUTH=307;AUPDATE=308
ASETAUTHCHANNAMEAS=309;ASETWELCOMEMESSAGEAS=310
GDESCRIBECLUB=401;GJOINCLUB=402;GLEAVECLUB=403;GCLUBLIST=404;GMAKECLUB=405;
GOADDTEXTCHANNEL=406;GOREMOVETEXTCHANNEL=407;GOADDVOICECHANNEL=408;GOREMOVEVOICECHANNEL=409;
......@@ -77,14 +82,29 @@ CONTROLMAP={CADDTEXTCHANNEL:ClubSuite.add_text_channel,
CWEEKLYREMINDER:ClubSuite.ui_weekly_reminder,
CUNSCHEDULEWEEKLYREMINDER:ClubSuite.ui_cancel_weekly_reminder,
CREQUESTBOT:ClubSuite.ui_requestbot,
GDESCRIBECLUB:ClubSuite.ui_describeclub,
GJOINCLUB:ClubSuite.add_member,
GLEAVECLUB:ClubSuite.kick_member,
GCLUBLIST:GCLUBLIST,
GMAKECLUB:ClubSuite.makeClub,
GHELP:ghelp,
UAUTHENTICATE: authenticate,
USENDAUTHEMAIL: send_auth_code_to_user,
OOADDTEXTCHANNEL: lambda x: x,#PubChanSuite.
AADDPUBCHAN: AdminChanSuite.ui_add_pubchan,
AADDRESTRICTCHAN: AdminChanSuite.ui_add_restrictchan,
ASETSENDERNAMEAS: AdminChanSuite.ui_set_sender_name_as,
ASETAUTHROLE0AS: AdminChanSuite.ui_set_authrole0_as,
ASETAUTHROLE1AS: AdminChanSuite.ui_set_authrole1_as,
ASETAUTHCHANNAMEAS: AdminChanSuite.ui_set_auth_chan_name_as,
ASETDESTDOMAINAS: AdminChanSuite.ui_set_domain_dest_as,
ATOGGLEAUTH: AdminChanSuite.ui_toggle_auth,
ASETWELCOMEMESSAGEAS: AdminChanSuite.ui_set_welcome_message_as,
AUPDATE: AdminChanSuite.ui_update
}
WRAPPERMAP = {CADDTEXTCHANNEL: lambda Text=None, channel=None, user=None: CONTROLMAP[CADDTEXTCHANNEL](channel.guild.get_channel(channel.category_id), Text),
......@@ -114,7 +134,16 @@ WRAPPERMAP = {CADDTEXTCHANNEL: lambda Text=None, channel=None, user=None: CONTRO
GHELP: lambda channel=None, user=None: CONTROLMAP[GHELP](channel),
UAUTHENTICATE: lambda channel=None, user=None, Text=None: CONTROLMAP[UAUTHENTICATE](channel, user, Text),
USENDAUTHEMAIL: lambda channel=None, user=None, EmailAddress=None, EmailConfirm=None: CONTROLMAP[USENDAUTHEMAIL](channel, user, EmailAddress, EmailConfirm),
AADDPUBCHAN: lambda channel=None, user=None, Text=None: CONTROLMAP[AADDPUBCHAN](channel.guild, user, Text),
AADDRESTRICTCHAN: lambda channel=None, user=None, Text=None: CONTROLMAP[AADDRESTRICTCHAN](channel.guild, user, Text),
ASETSENDERNAMEAS: lambda channel=None, user=None, Text=None: CONTROLMAP[ASETSENDERNAMEAS](channel.guild, Text),
ASETAUTHROLE0AS: lambda channel=None, user=None, Text=None: CONTROLMAP[ASETAUTHROLE0AS](channel.guild, Text),
ASETAUTHROLE1AS: lambda channel=None, user=None, Text=None: CONTROLMAP[ASETAUTHROLE1AS](channel.guild, Text),
ASETAUTHCHANNAMEAS: lambda channel=None, user=None, Text=None: CONTROLMAP[ASETAUTHCHANNAMEAS](channel.guild, Text),
ASETDESTDOMAINAS: lambda channel=None, user=None, Text=None: CONTROLMAP[ASETDESTDOMAINAS](channel.guild, Text),
ATOGGLEAUTH: lambda channel=None, user=None: CONTROLMAP[ATOGGLEAUTH](channel.guild),
ASETWELCOMEMESSAGEAS: lambda channel=None, user=None, Text=None: CONTROLMAP[ASETWELCOMEMESSAGEAS](channel.guild, Text),
AUPDATE: lambda channel=None, user=None: CONTROLMAP[AUPDATE](channel.guild),
}
TAGS={TEXT:'[Text]',
......@@ -159,7 +188,18 @@ TAGSTRINGS= {CADDTEXTCHANNEL:TAGS[TEXT],
GMAKECLUB: TAGS[TEXT],
GHELP: '',
UAUTHENTICATE: TAGS[TEXT],
USENDAUTHEMAIL: TAGS[EMAILADDRESS] + ' ' + TAGS[EMAILCONFIRMATION]
USENDAUTHEMAIL: TAGS[EMAILADDRESS] + ' ' + TAGS[EMAILCONFIRMATION],
AADDPUBCHAN: TAGS[TEXT],
AADDRESTRICTCHAN: TAGS[TEXT],
ASETSENDERNAMEAS: TAGS[TEXT],
ASETAUTHCHANNAMEAS: TAGS[TEXT],
ASETDESTDOMAINAS: TAGS[TEXT],
ATOGGLEAUTH: '',
ASETWELCOMEMESSAGEAS: TAGS[TEXT],
ASETAUTHROLE0AS: TAGS[TEXT],
ASETAUTHROLE1AS: TAGS[TEXT],
AUPDATE: ''
}
#-> Here are where the prompts for getting info for specific tags are. * prompts denote general prompts.
......@@ -203,4 +243,17 @@ GENERAL_OPTION_EMOJIS = {0: '\U0001F925',
17: '\U0001F92D',
18: '\U0001F92E',
19: '\U0001F92F',
20: '\U0001F930'}
20: '\U0001F930',
21: '\U0001F435',
22: '\U0001F412',
23: '\U0001F98D',
24: '\U0001F9A7',
25: '\U0001F436',
26: '\U0001F415',
27: '\U0001F9AE',
28: '\U0001F429',
29: '\U0001F415',
30: '\U0001F43A',
31: '\U0001F98A',
32: '\U0001F99D'}
......@@ -24,7 +24,8 @@ server_vars = {'sender_name=':'Discord++',
'email_verification_destination_domain=':'',
'auth_channel_welcome_text=':'''Welcome! To get started, please type in an '!' followed by your school email \n
Ex. !jnislam18@earlham.edu\n
You should see an email from Discord++ in your zimbra email. Enter the code into the chat.'''}
You should see an email from Discord++ in your zimbra email. Enter the code into the chat.''',
'version=': '0.1.5.5'}
auth_channel = 'auth'
domain_dest = '@earlham.edu'
......
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