示例#1
0
 async def newuser(self, context):
     embed = create_embed(
         "Time to add a new user",
         description=
         "To add a new user, we will need the person's name and school ID number. Please enter your full name."
     )
     message = await context.send(embed=embed)
     resp = await self.client.wait_for("message",
                                       check=check(context.author,
                                                   context.channel))
     current = User()
     goodName = False
     while (goodName == False):
         if ' ' in resp.content:
             current.firstName = resp.content.split(' ')[0]
             current.lastName = resp.content.split(' ')[1]
             current.fullName = current.firstName + current.lastName
             goodName = True
         elif ',' in resp.content:
             current.firstName = resp.content.split(',')[0]
             current.lastName = resp.content.split(',')[1]
             current.fullName = current.firstName + current.lastName
             goodName = True
         else:
             await context.send("Invalid name! Please enter your full name")
             goodName = False
     embed = create_embed(
         f"Continue your Profile, {current.firstName}",
         description=
         "Please enter your school student ID! This is so that you can be recognized by your teachers or students."
     )
     message = await context.send(embed=embed)
     resp = await self.client.wait_for("message",
                                       check=check(context.author,
                                                   context.channel))
     current.schoolID = resp.content
     embed = create_embed(f"Confirm your information, {current.firstName}",
                          description="Is this correct? ✅ or ❌",
                          fields=[["First Name:", current.firstName, True],
                                  ["Last Name", current.lastName, True],
                                  ["School ID", current.schoolID]])
     message = await context.send(embed=embed)
     react = await get_reacts(context, self.client, message, ["✅", "❌"])
     if react.emoji == "✅":
         await context.send("Successfully set your profile!")
     elif react.emoji == "❌":
         await context.send("Cancelled your profile!")
     else:
         raise Exception("You've broken Python!")
示例#2
0
    async def joinclass(self, context):
        await context.send(
            "Enter the join code provided by your teacher! (Example: `783465`)"
        )
        resp = await self.client.wait_for("message",
                                          check=check(context.author,
                                                      context.channel))

        class React:
            emoji = "❌"

        react = React()
        while (react.emoji == "❌"):
            code = int(resp.content)
            embed = create_embed(
                "Are you sure?",
                description="Are you sure you want to join this class? ✅ or ❌",
                fields=
                [["Class", "Biology Honors"],
                 [
                     "Description:",
                     "Bio Honors Period 4! Room 68, Second Floor. Have fun learning Biology!"
                 ], ["Teacher", "Mr. Jeff", True],
                 [
                     "Meeting Times",
                     "Monday: 2-3:30, Tuesday: 4-5, Wednesday: 2-3:30, Thursday: 4-5, Friday: 2-3:30"
                 ]])
            message = await context.send(embed=embed)
            react = await get_reacts(context, self.client, message, ["✅", "❌"])
            if react.emoji == "✅":
                await context.send("Successfully joined class!")
            elif react.emoji == "❌":
                await context.send("Cancelled joining class!")
            else:
                raise Exception("You've broken Python!")
示例#3
0
 async def viewTasks(self, context):
     #index = 0
     #while(index<10):
     #next10[i]=results[i]
     next10 = [
         Task("Homework Three", "Biology Honors",
              "Read Pages 23-31 in your textbook and take notes",
              datetime(2021, 5, 5)),
         Task("Assignment Three", "Pre-Calculus",
              "Finish the problems on quadratic equations.",
              datetime(2021, 5, 6)),
         Task(
             "Essay One", "English Honors",
             "Please submit your rough drafts of your essay on the importance of Beowulf in Old English literature",
             datetime(2021, 5, 10)),
         Task("Extra Credit", "Biology Honors",
              "Watch the Discovery Channel and take notes",
              datetime(2021, 5, 11)),
         Task("Homework Four", "Biology Honors",
              "Read Pages 34-45 in your textbook and take notes",
              datetime(2021, 5, 11)),
         Task("Assignment Four", "Pre-Calculus",
              "Finish the problems on quadratic equations.",
              datetime(2021, 5, 12)),
         Task("Reading Five", "American History",
              "Read the fifth chapter in your textbooks",
              datetime(2021, 5, 13)),
         Task("Reading Six", "American History",
              "Read the fifth chapter in your textbooks",
              datetime(2021, 5, 20)),
         Task("Homework Five", "Biology Honors",
              "Read Pages 48-60 in your textbook and take notes",
              datetime(2021, 5, 17)),
         Task("Assignment Five", "Pre-Calculus",
              "Finish the problems on logarithmic equations.",
              datetime(2021, 5, 18)),
     ]
     current_day = int(datetime.now().strftime("%w"))
     embed = create_embed(
         "Your Next 10 Classes, Exams, and Tasks",
         fields=[[
             "Name", "\n\n".join([
                 str(dashboardcodes[type(n).__name__.lower()] + " " +
                     n.name) for n in next10
             ]), True
         ],
                 [
                     "Date/Time", "\n\n".join(
                         n.at[current_day] if isinstance(n.at, list
                                                         ) else str(n.at)
                         for n in next10), True
                 ],
                 [
                     "Teacher/Class",
                     "\n\n".join(n.subject for n in next10), True
                 ], ["Key", "🏫 Class, 📚 Task, 📝 Exam"]])
     await context.send(embed=embed)
示例#4
0
 async def help(self, context):
     fields = [[
         f"All `{cog}` Commands:", "".join([
             f" • `{cmd}`\n"
             for cmd in self.client.get_cog(cog).get_commands()
         ]).rstrip()
     ] for cog in self.cogs]
     embed = create_embed("Help",
                          description=self.client.description,
                          fields=fields)
     await context.send(embed=embed)
示例#5
0
 async def show_help(self, context, name: Optional[str]):
     self.cogs = [c for c in self.client.cogs.keys()]
     if name is None:
         await self.help(context)
         return
     if name in self.cogs:
         await self.cat_help(context, name)
     if get(self.client.commands, name=name):
         await self.cmd_help(self.client, context, name)
     else:
         await context.send(embed=create_embed(
             "Help", description=f"The command `{name}` does not exist!"))
示例#6
0
 async def viewExams(self, context):
     next10 = [
         Exam(
             "History Quiz One", "American History",
             "Short     quiz on the importance of Washington's presidential precident",
             datetime(2021, 5, 6, 8, 00)),
         Exam("English Quiz One", "English Honors", "Quiz on Beowulf.",
              datetime(2021, 5, 7, 10, 00)),
         Exam("Bio Quiz One", "Biology Honors",
              "Will cover the parts of the cell, open notes",
              datetime(2021, 5, 10, 9, 00)),
         Exam("Calc Quiz One", "Pre-Calculus",
              "Quiz on      quadratic equations, bring your calculator!",
              datetime(2021, 5, 12, 11, 00)),
         Exam("Bio Quiz Two", "Biology Honors",
              "Short quiz on recent reading assignment",
              datetime(2021, 5, 17, 9, 00)),
         Exam("Calc Quiz Two", "Pre-Calculus",
              "Quiz on logarithms and logarithmic equations.",
              datetime(2021, 5, 19, 11, 00)),
         Exam(
             "History Quiz Two", "American History",
             "Short assessment of your understanding of the early presidents",
             datetime(2021, 5, 20, 8, 00)),
         Exam("Bio Test One", "Biology Honors",
              "Short quiz on recent reading assignment",
              datetime(2021, 5, 31, 9, 00)),
         Exam("Calc Test One", "Pre-Calculus",
              "Covers the material learned this semester",
              datetime(2021, 6, 2, 11, 00)),
         Exam("History Test One", "American History",
              "Covers the material thus far assigned",
              datetime(2021, 6, 3, 8, 00))
     ]
     current_day = int(datetime.now().strftime("%w"))
     embed = create_embed(fields=[
         [
             "Name", "\n\n".join([
                 str(dashboardcodes[type(n).__name__.lower()] + " " +
                     n.name) for n in next10
             ]), True
         ],
         [
             "Date/Time", "\n\n".join(
                 n.at[current_day] if isinstance(n.at, list) else str(n.at)
                 for n in next10), True
         ], ["Teacher/Class", "\n\n".join(
             n.subject
             for n in next10), True], ["Key", "🏫 Class, 📚 Task, 📝 Exam"]
     ])
     await context.send(embed=embed)
示例#7
0
 async def cat_help(self, context, category):
     embed = create_embed(
         "Help",
         description=f"Help with the `{category}` category",
         fields=[[
             "Description:",
             self.client.get_cog(category).description
             if self.client.get_cog(category).description else None
         ],
                 [
                     "Commands", "".join([
                         f" • `{cmd}` - {cmd.brief}\n" for cmd in
                         self.client.get_cog(category).get_commands()
                     ]).rstrip()
                 ]])
     await context.send(embed=embed)
示例#8
0
 async def cmd_help(self, client, context, command):
     command = get(self.client.commands, name=command)
     embed = create_embed(
         "Help",
         description=f"Help with the `{command}` command",
         fields=[
             ["Syntax", syntax(client, command)],
             [
                 "Brief Description",
                 command.brief if command.brief else "None"
             ],
             [
                 "Description",
                 command.description if command.description else "None"
             ],
             [
                 "Aliases",
                 ", ".join(command.aliases) if command.aliases else "None"
             ]
         ])
     await context.send(embed=embed)
示例#9
0
 async def newexam(self, context):
     embed = create_embed(
         "Time to make a new Exam!",
         description=
         "Which class is this exam for?\n\nYour classes: `Science`, `History`, `English`, `Math`, `Tech`, `Spanish`, and `Computer Science`"
     )
     await context.send(embed=embed)
     current = Exam()
     subject = await self.client.wait_for("message",
                                          check=check(
                                              context.author,
                                              context.channel))
     current.subject = subject.content
     embed = create_embed(f"New Exam for {current.subject}",
                          description="Please enter the exam name!")
     message = await context.send(embed=embed)
     resp = await self.client.wait_for("message",
                                       check=check(context.author,
                                                   context.channel))
     current.name = resp.content
     embed = create_embed(
         f"New Exam: {current.name}",
         description="A description of this exam (optional)")
     message = await context.send(embed=embed)
     resp = await self.client.wait_for("message",
                                       check=check(context.author,
                                                   context.channel))
     current.description = resp.content
     while True:
         embed = create_embed(
             f"New Exam: {current.name}",
             description=
             "When is this exam at? Format: mm/dd/yy hh:mm AM/PM\nExample: `03/09/21 3:45 PM`."
         )
         message = await context.send(embed=embed)
         resp = await self.client.wait_for("message",
                                           check=check(
                                               context.author,
                                               context.channel))
         resp = resp.content.split("/")
         if len(resp) == 3:
             try:
                 endsplit = resp[2].split(" ")
                 resp[2] = endsplit[0]
                 t = endsplit[1].split(":")
                 if len(t) == 2 and all(len(x) == 2 for x in resp):
                     for x in range(len(resp)):
                         resp[x] = int(resp[x])
                     for x in range(len(t)):
                         t[x] = int(t[x])
                     if endsplit[2].lower() == "pm":
                         t[0] += 12
                     current.date = datetime.datetime(
                         resp[2], resp[0], resp[1], t[0], t[1])
                     current.at = current.date
                     break
             except Exception as e:
                 print(e)
                 await context.send("Invalid Date!")
         else:
             await context.send("Invalid Date!")
     embed = create_embed(
         f"Exam: {current.name}",
         description="Is this correct? ✅ or ❌",
         fields=[["Description", current.description],
                 ["Subject", current.subject, True],
                 [
                     "At",
                     current.date.strftime(
                         "%A %B %d, %Y (%m/%d/%y) at %I:%M %p"), True
                 ]])
     message = await context.send(embed=embed)
     react = await get_reacts(context, self.client, message, ["✅", "❌"])
     if react.emoji == "✅":
         await context.send("Successfully added exam!")
     elif react.emoji == "❌":
         await context.send("Cancelled adding exam!")
     else:
         raise Exception("You've broken Python!")
示例#10
0
    async def newclass(self, context):
        embed = create_embed(
            "Create a class!",
            description=
            "To create a class, first choose whether you are creating this class for yourself or as a teacher. If you are creating this as a teacher, you will be provided with a class code to share with your students.",
            fields=[["As a Teacher", "React with 👨‍🏫", True],
                    ["For Yourself", "React with 👨‍🎓", True]])
        message = await context.send(embed=embed)
        react = await get_reacts(context, self.client, message, ["👨‍🏫", "👨‍🎓"])
        current = Class()
        if react.emoji == "👨‍🏫":
            current.teacher = context.author.id
            current.subject = current.teacher
        elif react.emoji == "👨‍🎓":
            embed = create_embed(
                "Moving on...",
                description=
                "Now, tell me the name of the teacher who is teaching this class. Just type it in below:"
            )
            message = await context.send(embed=embed)
            resp = await self.client.wait_for("message",
                                              check=check(
                                                  context.author,
                                                  context.channel))
            current.teacher = resp.content
            current.subject = current.teacher
        else:
            raise Exception("You've broken Python!")

        embed = create_embed(
            "Perfect! Let's keep going...",
            description=
            "Now, set your class name. This is what you will use to add Tasks and Exams, and to reference it later. Just type it in below:"
        )

        message = await context.send(embed=embed)
        resp = await self.client.wait_for("message",
                                          check=check(context.author,
                                                      context.channel))
        current.name = resp.content
        embed = create_embed(f'{current.name} is your class',
                             description="Is this correct?")
        message = await context.send(embed=embed)
        react = await get_reacts(context, self.client, message, ["❌", "✅"])
        while (react.emoji == "❌"):
            embed = create_embed(
                #Maybe 'your' name? If its the teacher??
                "Please enter the class's name: ")
            message = await context.send(embed=embed)
            resp = await self.client.wait_for("message",
                                              check=check(
                                                  context.author,
                                                  context.channel))
            current.name = resp.content
            embed = create_embed(f'{current.name} is your class name',
                                 description="Is this correct?")
            message = await context.send(embed=embed)
            react = await get_reacts(context, self.client, message, ["❌", "✅"])

        embed = create_embed(
            f"Now, we need the information for {current.name}'s schedule",
            description=f"Please enter the hours that {current.name} will meet"
        )
        message = await context.send(embed=embed)
        index = 0
        for item in current.days:
            message = await context.send(
                f"Please enter times for {c_daysList[index]}! If the class doesn't meet on that day, enter anything that's not two numbers separated by a `-`."
            )
            resp = await self.client.wait_for("message",
                                              check=check(
                                                  context.author,
                                                  context.channel))
            try:
                resp = resp.content
                if not "-" in resp:
                    raise Exception("Nope")
                current.days[index] = str(resp)
                index += 1
            except Exception as e:
                index += 1
        current.at = current.days
        embed = create_embed(
            "Almost done! The last thing to do is to enter a description of the class"
        )
        message = await context.send(embed=embed)
        resp = await self.client.wait_for("message",
                                          check=check(context.author,
                                                      context.channel))
        current.description = resp.content
        embed = create_embed(
            "Is this correct?",
            fields=[[
                "Teacher",
                "You" if isinstance(current.teacher, int) else current.teacher,
                True
            ], ["Name", current.name, True],
                    ["Description", current.description, True],
                    [
                        "Meeting Times", ", ".join([
                            c_daysList[i] + ": " + current.days[i]
                            for i in range(7)
                        ])
                    ]])
        message = await context.send(embed=embed)
        react = await get_reacts(context, self.client, message, ["✅", "❌"])
        if react.emoji == "✅":
            await context.send("Successfully added class!")
        elif react.emoji == "❌":
            await context.send("Cancelled adding class!")
        else:
            raise Exception("You've broken Python!")
示例#11
0
 async def howto(self, context):
     await context.send(
         embed=create_embed("How-To", description=self.client.howto))
示例#12
0
 async def info(self, context):
     await context.send(
         embed=create_embed("Info", description=self.client.info))
示例#13
0
    async def dashboard(self, context):

        next10 = [
            Class(
                "Biology Honors",
                "Bio Honors Period 4! Room 68, Second Floor. Have fun learning Biology!",
                [None, "8-9", "9-10", "10-11", "11-12", None, "7-8"],
                "Mr. Jeff"),
            Task("Homework Three", "Biology Honors",
                 "Read Pages 23-31 in your textbook and take notes",
                 datetime(2021, 5, 5)),
            Class("Pre-Calculus",
                  "Pre-Calc Period 1! Room 45a, First Floor. Math is cool!",
                  ["9-10", "10-11", "11-12", None, "7-8", None, "8-9"],
                  "Ms. Russo"),
            Task("Assignment Three", "Pre-Calculus",
                 "Finish the problems on quadratic equations.",
                 datetime(2021, 5, 6)),
            Class("American History",
                  "History Period 2, Room 21, First Floor.",
                  ["10-11", "11-12", None, "7-8", "8-9", None, "9-10"],
                  "Mr. Singer"),
            Task(
                "Essay One", "American History",
                "Finish your essays on the importance of the Madison v. Marbury case",
                datetime(2021, 5, 7)),
            Exam(
                "History Quiz One", "American History",
                "Short quiz on the importance of Washington's presidential precident",
                datetime(2021, 5, 6, 8, 00)),
            Class(
                "English Honors",
                "Honors English Period 3, at Room 33, First Floor. Please come prepared with notebooks, pencils, and your books.",
                ["11-12", "12-1", "7-8", "8-9", "9-10", "12-1", "10-11"],
                "Mrs. Berg"),
            Task(
                "Essay One", "English Honors",
                "Please submit your rough drafts of your essay on the importance of Beowulf in Old English literature",
                datetime(2021, 5, 10)),
            Class(
                "Biology Honors",
                "Bio Honors Period 4! Room 68, Second Floor. Have fun learning Biology!",
                [None, "8-9", "9-10", "10-11", "11-12", None, "7-8"],
                "Mr. Jeff")
        ]
        current_day = int(datetime.now().strftime("%w"))
        embed = create_embed(
            "Your Next 10 Classes, Exams, and Tasks",
            fields=[
                [
                    "Name", "\n\n".join([
                        str(dashboardcodes[type(n).__name__.lower()] + " " +
                            n.name) for n in next10
                    ]), True
                ],
                [
                    "Date/Time", "\n\n".join(
                        str(n.at[(current_day + 1) %
                                 7]) if isinstance(n.at, list) else str(n.at)
                        for n in next10), True
                ],
                [
                    "Teacher/Class", "\n\n".join(n.subject for n in next10),
                    True
                ], ["Key", "🏫 Class, 📚 Task, 📝 Exam"]
            ])
        await context.send(embed=embed)