Beispiel #1
0
    def reward_xp(self, event, user_id):
        points = self.config.reward_points
        uid = self.get_id(user_id)
        if int(uid) in event.guild.members:
            name = str(event.guild.members[int(uid)])
        else:
            name = uid
        if uid is None:
            event.msg.reply("🚫 invalid snowflake/mention").after(5).delete()
            event.msg.delete()
            return
        user = self.get_user(uid)

        if points < 0:
            event.msg.reply("🚫 removing xp is not allowed!")
            log_to_bot_log(self.bot, f"âš  {event.author} tried to remove xp from {name}")
            return
        xp = user["xp"] + points
        self.users.update_one({
            "user_id": str(uid)
        }, {
            "$set": {
                "xp": xp
            }
        })
        event.msg.reply(f":ok_hand: <@{uid}> received some xp for helping out!")
        log_to_bot_log(self.bot, f":pencil: {event.msg.author} gave {points} to {name} (``{uid}``), new xp total: {xp}")
Beispiel #2
0
 def github(self, event):
     event.msg.reply(
         f"My source code can be found at <{self.config.source_code_location}>"
     )
     log_to_bot_log(
         self.bot,
         ":bug: " + str(event.msg.author) + " used the Github command.")
Beispiel #3
0
    def give_xp(self, event, user_id, points):
        uid = self.get_id(user_id)

        if uid is None:
            event.msg.reply(":no_entry_sign: invalid snowflake/mention").after(
                5).delete()
            return
        user = self.get_user(uid)

        if user["xp"] + points < 0:
            xp = 0
            self.users.update_one({"user_id": str(uid)}, {"$set": {"xp": xp}})
            log_to_bot_log(
                self.bot,
                ":pencil: {mod} updated point total for {user} to {points}".
                format(mod=str(event.msg.author),
                       user=str(uid),
                       points=str(xp)))
            event.msg.reply("User cannot have below 0 points, so set to 0."
                            ).after(5).delete()
            event.msg.delete()
            return
        xp = user["xp"] + points
        self.users.update_one({"user_id": str(uid)}, {"$set": {"xp": xp}})
        event.msg.reply(":ok_hand: {user} point total updated to {points}".format(user=str(uid), points=xp)) \
            .after(5).delete()
        event.msg.delete()
        log_to_bot_log(
            self.bot,
            ":pencil: {mod} updated point total for {user} to {points}".format(
                mod=str(event.msg.author), user=str(uid), points=str(xp)))
Beispiel #4
0
 def remove_squasher_roles(self):
     t = time.time()
     purchases = self.purchases.find({
         "expired": False,
         "time": {
             "$lt": t - 604800.0
         },
         "type": "bug_squasher"
     })
     for purchase in purchases:
         print("[SQ] expired squasher role detected.")
         # purchase has expired.
         guild = self.bot.client.api.guilds_get(self.config.dtesters_guild_id)
         if not guild:  # if not in guild, wait until we are.
             print("[SQ] guild couldn't be found.")
             return
         member = guild.get_member(str(purchase["user_id"]))
         # they left, so that means they don't have bug squasher
         if not member:
             self.set_purchase_expired(purchase["_id"])
             continue
         role = self.config.roles["squasher"]
         if role in member.roles:
             member.remove_role(role)
         log_to_bot_log(self.bot,
                        "Removed the bug squasher role from {} as their purchase expired".format(str(member)))
         self.set_purchase_expired(purchase["_id"])
Beispiel #5
0
 def questions_made_easy(self, event, args):
     #Checks to see if the topic in the list and then replies with the message in annouceBot.py
     args.question_title = args.question_title.lower()
     event.msg.delete()
     if args.question_title in self.config.frequently_asked_questions.keys():
         event.msg.reply(self.config.frequently_asked_questions[args.question_title])
         log_to_bot_log(self.bot, ":notebook: "+str(event.msg.author)+" used the tag command for `"+args.question_title+"`.")
Beispiel #6
0
    def on_message_create(self, event):

        # If the bot does the thing in the right channel, check what mentors are available.
        if self.config.join_phrase in event.content and event.channel_id == self.config.channels[
                'new_bh']:
            the_chosen_one = self.get_mentor()
        else:
            return
        # If there's at least one mentor in the list, ping them.
        if the_chosen_one is None:
            self.bot.client.api.channels_messages_create(
                self.config.channels['mentor'],
                self.config.messages['no_bh_mentors'].format(
                    event.content[10:28]))
            log_to_bot_log(
                self.bot, self.config.messages['no_bh_mentors'].format(
                    event.content[10:28]))
            return
        react_message = self.bot.client.api.channels_messages_create(
            self.config.channels['mentor'],
            self.config.messages['new_bh_join'].format(event.content[10:28],
                                                       the_chosen_one.id))
        self.bot.client.api.channels_messages_reactions_create(
            self.config.channels['mentor'], react_message.id,
            self.build_emoji('mentor'))
Beispiel #7
0
    def start_command(self, event):
        """Start the event"""
        if self.status != "Scheduled":
            event.msg.reply("Event has already started")
            return

        if event.guild is None:
            return
        # give bug hunters access to submission channel
        participants_role = event.guild.roles[int(self.config.participants_role)]
        event_channel = event.guild.channels[int(self.config.event_channel)]

        # determine current overrides and if one exists just flip the read channel bit around
        perms = event_channel.overwrites
        view_channel = 1024

        if participants_role.id in perms.keys():
            # update existing override
            allow = perms[participants_role.id].allow.add(view_channel)
            deny = perms[participants_role.id].deny.sub(view_channel)
            event_channel.create_overwrite(participants_role, allow=allow, deny=deny)
        else:
            # no override present, make a new one
            event_channel.create_overwrite(participants_role, allow=view_channel, deny=0)

        self.status = "Started"
        event.channel.send_message(
            "<:approve:302137375092375553> Submissions channel unlocked and commands unlocked, here we go")
        log_to_bot_log(self.bot, ":unlock: {name} (`{id}`) started the event.".format(name=str(event.msg.author),
                                                                                      id=event.msg.author.id))
        self.save_event_stats()
Beispiel #8
0
    def revoke(self, event, report):
        """Revoke a submission"""
        if event.msg.channel.id != self.config.event_channel:
            return

        trello_info = TrelloUtils.getCardInfo(event, report)
        if trello_info is None:
            # invalid card
            event.msg.reply("I can't even fetch info for that, you sure you reported that one?")
            return
        if not trello_info["id"] in self.reported_cards.keys():
            # not reported yet
            event.msg.reply("I don't have a report for that card, how do you expect me to edit a non existing thing?")
            return
        report_info = self.reported_cards[trello_info["id"]]
        if report_info["author_id"] != str(event.author.id):
            # someone else reported
            event.msg.reply(
                "I think there's been a case of mistaken identity here, this report was made by {} and it looks like you are {}".format(
                    self.participants[str(report_info["author_id"])], str(event.author)))
            return

        # delete message and entry
        event.msg.channel.get_message(report_info["message_id"]).delete()
        del self.reported_cards[trello_info["id"]]
        event.msg.reply(":warning: Your submission has been nuked <@{}>!".format(event.author.id))
        log_to_bot_log(self.bot,
                       f":outbox_tray: {event.author} (``{event.author.id}``)  has revoked <https://trello.com/c/{trello_info['shortLink']}>")
        self.save_event_stats()
Beispiel #9
0
 def cancel_help_request(self, event):
     session = self.helpme.find_one(
         {'$and': [{
             'helpee_id': event.author.id
         }, {
             'active': True
         }]})
     if session:
         last_event = session['history'][-1][1]
         if last_event == 'waiting':
             try:
                 self.bot.client.api.channels_messages_delete(
                     self.config.channels['mentor'],
                     session['status_message_id'])
             except APIException:
                 pass
         elif last_event == 'assigned':
             self.send_dm(session['mentor_id'],
                          f'{event.author} cancelled their HelpMe request')
         session['history'].append(
             (time.time(), 'cancelled', event.author.id))
         self.helpme.update_one(
             {'_id': session['_id']},
             {'$set': {
                 'history': session['history'],
                 'active': False
             }})
         event.msg.reply(f'I have cancelled your open HelpMe request')
         log_to_bot_log(
             self.bot,
             f'{event.author} cancelled their HelpMe request ({str(session["_id"])})'
         )
     else:
         event.msg.reply("You don't have an open HelpMe request")
Beispiel #10
0
 def clear_user(self, event, user, reason):
     """Someone's been so bad we need to remove all their submissions :("""
     if not str(user.id) in self.participants:
         # that definitely was the wrong user
         event.msg.reply("This user has not participated in the event")
         return
     else:
         # seperate list to remove as we can't alter the list we are iterating over
         to_remove = []
         for rid, report in self.reported_cards.items():
             if str(user) == str(report["author_id"]):
                 try:
                     channel = event.guild.channels[self.config.event_channel]
                     channel.get_message(report["message_id"]).delete()
                 except APIException:
                     pass  # mod already removed it?
                 to_remove.append(rid)
         for r in to_remove:
             del self.reported_cards[r]
         event.channel.send_message(
             "<{}> cleared reports from {}.".format(self.config.emojis["yes"], self.participants[str(user)]))
         log_to_bot_log(self.bot,
                        ":wastebasket: {mod} cleared all submissions for {user} with reason {reason}".format(
                            mod=str(event.msg.author), user=self.participants[str(user)], reason=reason))
         del self.participants[str(user)]
         self.save_event_stats()
Beispiel #11
0
    def give_xp(self, event, user_id, points):
        uid = self.get_id(user_id)
        if int(uid) in event.guild.members:
            name = str(event.guild.members[int(uid)])
        else:
            name = uid

        if uid is None:
            event.msg.reply(":no_entry_sign: invalid snowflake/mention").after(5).delete()
            return
        user = self.get_user(uid)

        if user["xp"] + points < 0:
            points = -user["xp"]
        xp = user["xp"] + points
        self.users.update_one({
            "user_id": str(uid)
        }, {
            "$set": {
                "xp": xp
            }
        })
        event.msg.reply(f":ok_hand: {name} point total updated to {xp}").after(5).delete()
        event.msg.delete()
        log_to_bot_log(self.bot,f":pencil: {event.msg.author} gave {points} to {name} (``{user_id}``), new xp total: {xp}")
Beispiel #12
0
    def give_lifetime_xp(self, event, user_id, points):
        uid = self.get_id(user_id)
        if int(uid) in event.guild.members:
            name = str(event.guild.members[int(uid)])
        else:
            name = uid

        if uid is None:
            event.msg.reply(":no_entry_sign: invalid snowflake/mention").after(5).delete()
            return
        user = self.get_user(uid)

        if user.get("badge-progress") is None:
            event.msg.reply(":no_entry_sign: that user doesn't have lifetime XP. Wumpus forgot about them"
                            " (they need to perform a bot action or gain XP)").after(5).delete()
            return

        self.users.update_one({
            "user_id": str(uid)
        }, {
            "$set": {
                "badge-progress": user.get("badge-progress", user["xp"]) + points
            }
        })

        badge_progress = user["badge-progress"]
        event.msg.reply(f":ok_hand: {name} lifetime XP total updated to {badge_progress}.").after(5).delete()
        event.msg.delete()
        log_to_bot_log(self.bot,
                       f":pencil: {event.msg.author} gave {points} lifetime XP to {name} (``{user_id}``), new xp total: {xp}")
Beispiel #13
0
    def edit(self, event, details):
        if event.msg.channel.id != self.config.event_channel:
            return
        parts = details.split("|")
        if len(parts) < 3:
            event.msg.reply(
                "<@{}> It seems you're missing parts, the syntax for this command is `+edit <trello link> | <section (destination or info)> | <new info>`".format(
                    event.author.id))
            return
        if len(parts) > 3:
            parts[2] = "|".join(parts[2:])
        link = parts[0]
        section = parts[1].strip(" ").lower()
        info = parts[2]

        trello_info = TrelloUtils.getCardInfo(event, link)
        if trello_info is None:
            event.msg.reply("I can't even fetch info for that, you sure you reported that one?")
            return
        if not trello_info["id"] in self.reported_cards.keys():
            event.msg.reply("I don't have a report for that card, how do you expect me to edit a non existing thing?")
            return
        report_info = self.reported_cards[trello_info["id"]]
        if report_info["author_id"] != str(event.author.id):
            event.msg.reply(
                "I think there's been a case of mistaken identity here, this report was made by {} and it looks like you are {}".format(
                    self.participants[str(report_info["author_id"])], str(event.author)))
            return
        dmessage = event.guild.channels[self.config.event_channel].get_message(report_info["message_id"])
        content = dmessage.content
        new_message = ""
        lines = content.splitlines()
        if section == "destination":
            new_message = "\n".join(lines[:2])
            while not lines[2].startswith("**Submitted by**:"):
                lines.pop(2)
            new_message += "\n**Destination**: {}\n{}".format(sanitize.S(info, escape_codeblocks=True),
                                                              "\n".join(lines[2:]))
        elif section == "info":
            count = 0
            while not lines[count].startswith("**Detailed info**"):
                count += 1
            new_message = "\n".join(lines[:count])
            new_message += "\n**Detailed info**: {}\n{}".format(sanitize.S(info, escape_codeblocks=True),
                                                                "\n".join(lines[-1:]))
        else:
            event.msg.reply("Unknown section")
            return
        if len(new_message) > 2000:
            event.msg.reply(
                "<@{}> Sorry, but would make the report too long for me to process, would mind removing {} characters? Then everything should be fine again.".format(
                    event.author.id, len(new_message) - 2000))
            return
        print(new_message)
        dmessage.edit(new_message)

        event.channel.send_message("<@{}>, your report has been updated!".format(event.author.id))
        log_to_bot_log(self.bot,
                       ":pencil: {} has updated the {} of their submission for <https://trello.com/c/{}>".format(
                           str(event.author), section.lower(), trello_info["shortLink"]))
Beispiel #14
0
    def end_event(self, event):
        """End the event, hide channel and prep for approval/denial"""
        participants_role = event.guild.roles[int(self.config.participants_role)]
        event_channel = event.guild.channels[int(self.config.event_channel)]
        perms = event_channel.overwrites
        view_channel = 1024

        if participants_role.id in perms.keys():
            event_channel.create_overwrite(participants_role, allow=0, deny=1024)
        else:
            event_channel.create_overwrite(participants_role, allow=0, deny=1024)
        event.msg.delete()
        event.channel.send_message("<{}> Event ended, preparing submissions...".format(self.config.emojis["yes"]))
        log_to_bot_log(self.bot,
                       ":lock: {user} ended event, prepping the submissions".format(user=str(event.msg.author)))
        self.status = "Ended"
        self.save_event_stats()

        # loop through all submissions and add reactions to it
        for reporter, report in self.reported_cards.items():
            message = event_channel.get_message(report["message_id"])
            self.bot.client.api.channels_messages_reactions_create(event_channel.id, message.id,
                                                                   self.config.emojis["yes"])
            self.bot.client.api.channels_messages_reactions_create(event_channel.id, message.id,
                                                                   self.config.emojis["no"])
        event.msg.reply("<@{}> all {} submissions have been prepped for approval/denial!".format(event.author.id, len(
            self.reported_cards)))
Beispiel #15
0
 def update_subscriptions(self, event, report_id, scopes = None):
     report = self.reports.find_one({'report_id': report_id})
     if report is not None:
         user_id = str(event.author.id)
         user_scopes = Scope(report['subs'].get(user_id, 0))
         old_scopes = user_scopes
         # User wants all notifications (or wants to reverse that)
         if scopes is None:
             if user_scopes == Scope.ALL:
                 # Could be confusing but acts as a toggle for convenience
                 user_scopes = Scope.NONE
                 response = f"You'll no longer receive notifications for #{report_id}"
             else:
                 user_scopes = Scope.ALL
                 response = f"You'll receive all notifications for #{report_id}"
         # User wants to clear notifications
         elif scopes.lower() in ['clear', 'none']:
             if user_scopes:
                 user_scopes = Scope.NONE
                 response = f"You'll no longer receive notifications for #{report_id}"
             else:
                 response = f"You haven't registered for notifications for #{report_id}"
         # User wants specific notifications
         else:
             req_scopes = Scope.NONE
             # Try to parse the scopes they wanted
             try:
                 for s in scopes.split(','):
                     req_scopes |= Scope[s.upper()]
             except KeyError:
                 response = "I didn't recognise one or more of those scopes. Try `+notify <id>` to receive all notifications for a report"
             else:
                 if req_scopes != Scope.NONE:
                     if req_scopes in user_scopes:
                         response = f"You already have notifications for these scopes. You can use `+notify <id> clear` to remove them"
                     else:
                         user_scopes |= req_scopes
                         response = f"You'll receive `{self._get_scope_str(user_scopes)}` notifications for #{report_id}"
         # If they've made valid changes to their scopes
         if old_scopes != user_scopes:
             # Removed
             if user_scopes == Scope.NONE:
                 self.reports.update_one({'report_id': report_id}, {'$unset': {f'subs.{user_id}': ''}})
                 log_to_bot_log(self.bot, f':pager: {event.author} removed notifications for #{report_id}')
             # Added/Changed
             else:
                 scope_str = self._get_scope_str(user_scopes)
                 self.reports.update_one({'report_id': report_id}, {'$set': {f'subs.{user_id}': user_scopes.value}})
                 log_to_bot_log(self.bot,
                                f':pager: {event.author} registered for `{scope_str}` notifications for #{report_id}')
         event.msg.reply(f'{event.author.mention} {response}').after(5).delete()
     else:
         event.msg.reply(f"{event.author.mention} I can't find that report ID").after(5).delete()
     if not event.msg.channel.is_dm:
         try:
             event.msg.delete()
         except APIException:
             # Bug Bot caught it
             pass
Beispiel #16
0
 def reload_plugins(self, event):
     # do NOT reload this plugin, command execution gets interrupted otherwise!
     todo = [plugin for name, plugin in self.bot.plugins.items() if name != "reload"]
     for p in todo:
         c = p.__class__
         self.bot.rmv_plugin(c)
         self.bot.add_plugin(c)
     event.msg.reply("🔁 All plugins (and configs) have been reloaded")
     log_to_bot_log(self.bot, f"🔁 {event.msg.author} reloaded all plugins (and configs)")
Beispiel #17
0
 def grant_role(self, event):
     if 441739649753546764 in event.member.roles:
         event.member.remove_role(441739649753546764)
         log_to_bot_log(self.bot, f":thumbsdown: {str(event.author)} removed the A11y role from themselves.")
         event.msg.reply(f"<@{event.author.id}> I have removed the A11y (Accessibility Role) from you. Use the same command again to add the role to yourself.").after(5).delete()
         event.msg.delete()
     else:
         event.member.add_role(441739649753546764)
         log_to_bot_log(self.bot, f":thumbsup: {event.author} added the A11y role to themselves.")
         event.msg.reply(f"<@{event.author.id}> I have added the A11y (Accessibility Role) to you. Use the same command again to remove the role from yourself.").after(5).delete()
         event.msg.delete()
Beispiel #18
0
 def answer_frequent_questions(self, event):
     if event.author.id in self.bot_IDs.values():
         return
     for role in event.member.roles:
         if role in self.advanced_roles.values():
             return
     self.FAQ_dictionary = self.get_questions_as_a_dict()
     for key in self.FAQ_dictionary.keys():
         if key.lower() in event.content.lower():
             time.sleep(3)
             event.reply(self.FAQ_dictionary[key].replace("\\n", "\n"))
             log_to_bot_log(self.bot, f":clock1: {event.author} activated the auto response.")
Beispiel #19
0
 def add_xp(self, user_id, amount):
     uid = str(user_id)
     user = self.users.find_one({'user_id': uid})
     if user is None:
         user = {'user_id': uid, 'xp': 0}
         self.users.insert_one(user)
     total = user['xp'] + amount
     self.users.update_one({'user_id': uid}, {'$set': {'xp': total}})
     log_to_bot_log(
         self.bot,
         f':pencil: Updated point total for {uid} to {total} for completing a HelpMe request'
     )
Beispiel #20
0
 def set_dm_guide_percentage(self, event, percent):
     percent = percent / 100
     self.experiments["dm-guide-on-join"] = percent
     file = open("experiments.json", "w")
     file.write(json.dumps(self.experiments))
     file.close()
     event.msg.reply(
         ":ok_hand: set dm guide percentage experimentation thing to `{percent}`"
         .format(percent=percent * 100))
     log_to_bot_log(
         self.bot,
         ":wrench: DM Guide percentage updated to `{percent}` by {user}".
         format(percent=percent * 100, user=str(event.msg.author)))
Beispiel #21
0
 def make_unmentionable_after_ping(self, event):
     if event.author.id in self.config.bot_IDs.values():
         return
     for Mentioned_Role in self.config.role_IDs.values():
         # errors if it's an int, so making it a string
         Mentioned_Role = str(Mentioned_Role)
         if Mentioned_Role in event.content:
             # in order to make it unmentionable it has to be an int. So now changing that var back to an int.
             Mentioned_Role = int(Mentioned_Role)
             Role_To_Make_Mentionable = event.guild.roles.get(Mentioned_Role)
             Role_To_Make_Mentionable.update(mentionable=False)
             log_to_bot_log(self.bot, f":exclamation: A role ping was detected and the role was successfully set to be unmentionable.")
             return
     return
Beispiel #22
0
 def emergency_lockdown(self, event, args):
     event.msg.delete()
     for name, channelID in self.config.channels_to_lockdown.items():
         # lock the channel if listed or when locking everything
         if name in args.channel_names or args.channel_names == "all":
             log_to_bot_log(self.bot, ":lock: The "+name+" channel has been locked by "+str(event.msg.author)+" for the reason: "+args.reason+".")
             # grab the first (bug hunter or test role) for the queue, grab everyone (or whatever test role is there) for public channels
             rolename = "bug_hunter" if name == "bug" else "everyone"
             role = event.guild.roles[self.config.role_IDs_to_lockdown[rolename]]
             channel = event.guild.channels[channelID]
             channel.send_message(args.reason)
             # deny reactions and sending perms
             channel.create_overwrite(role, allow=0, deny=2112)
     event.msg.reply("Lockdown command has successfully completed!")
Beispiel #23
0
 def sync_queue(self, event):
     queue = event.guild.channels[self.config.channels['bug-approval-queue']]
     reports = []
     for message in queue.messages:
         if message.author.id == self.config.bug_bot_user_id:
             search = re.findall(r'(?<=Report\sID:\s\*{2})[0-9]+', message.content)
             if search:
                 report_id = int(search[-1])
                 if not self.reports.find_one({'report_id': report_id}):
                     reports.append({'report_id': report_id, 'subs': {}, 'queue_msg': message.id})
     if len(reports) > 0:
         self.reports.insert_many(reports)
     log_to_bot_log(self.bot,
                    f':envelope_with_arrow: {event.author} triggered a notify sync. {len(reports)} unseen reports added to the database')
     event.msg.delete()
Beispiel #24
0
 def remove_report(self, event, report):
     trello_info = TrelloUtils.getCardInfo(event, report)
     if trello_info is None:
         event.msg.reply("I can't even fetch info for that, you sure someone reported that one?")
         return
     if not trello_info["id"] in self.reported_cards.keys():
         event.msg.reply(
             "I don't have a report for that card, how do you expect me to edit a non existing thing?")
         return
     report_info = self.reported_cards[trello_info["id"]]
     event.guild.channels[self.config.event_channel].get_message(report_info["message_id"]).delete()
     del self.reported_cards[trello_info["id"]]
     event.msg.reply(":warning: Submission has been nuked <@{}>!".format(event.author.id))
     log_to_bot_log(self.bot, ":wastebasket: {} has removed <https://trello.com/c/{}>".format(str(event.author),
                                                                                              trello_info[
                                                                                                  'shortLink']))
Beispiel #25
0
 def export(self, event, file_name):
     log_to_bot_log(self.bot, ":notepad_spiral: {user} is performing an XP export".format(
         user=str(event.author)
     ))
     msg = event.msg.reply(":gem: computing... (this might take a while)")
     with open(file_name, "w+") as file:
         user_dict = self.users.find()
         newly_formed_user_dict = {}
         for user in iter(user_dict):
             newly_formed_user_dict[user["user_id"]] = {
                 "x": user["xp"],
                 "p": user.get("badge-progress", user["xp"])
             }
         data = json.dumps(newly_formed_user_dict)
         file.write(data)
     msg.edit(":ok_hand: complete! saved to `{file_name}`".format(
         file_name=file_name
     ))
Beispiel #26
0
 def change_verification_level(self, event, level, reason=None):
     vl = VerificationLevel.get(level.lower())
     if vl is not None:
         if event.guild.verification_level != vl:
             try:
                 self.bot.client.api.guilds_modify(event.guild.id, reason, verification_level=vl.value)
             except APIException:
                 event.msg.reply("Failed to change the server verification level")
             else:
                 if reason is None:
                     reason = ""
                 else:
                     reason = " with reason `{}`".format(reason)
                 log_to_bot_log(self.bot, ":vertical_traffic_light: {} changed the server verification level to {}{}".format(event.msg.author, level, reason))
                 event.msg.reply("Server verification level changed successfully")
         else:
             event.msg.reply("The server verification level is already set to {}".format(level))
     else:
         event.msg.reply("That level name doesn't seem to be valid")
Beispiel #27
0
 def lift_lockdown(self, event, channels):
     event.msg.delete()
     for name, channelID in self.config.channels_to_lockdown.items():
         # unlock the channel if listed or when unlocking everything
         if name in channels or channels == "all":
             log_to_bot_log(self.bot, ":unlock: The "+name+" channel has been unlocked by "+str(event.msg.author)+".")
             # grab the first (bug hunter or test role) for the queue, grab everyone (or whatever test role is there) for public channels
             rolename = "bug_hunter" if name == "bug" else "everyone"
             role = event.guild.roles[self.config.role_IDs_to_lockdown[rolename]]
             channel = event.guild.channels[channelID]
             channel.create_overwrite(role, allow=2048 if name == "bug" else 0, deny=64)
             # clean up lockdown message, scan last 5 messages just in case
             limit = 5
             count = 0
             for message in channel.messages_iter(chunk_size=limit):
                 if message.author.id == self.bot.client.api.users_me_get().id:
                     message.delete()
                 count = count + 1
                 if count >= limit:
                     break
     event.msg.reply("Unlock command has successfully completed!")
Beispiel #28
0
 def guide_send(self, event):
     randnum = random.random()
     time.sleep(30)
     if randnum <= self.experiments["dm-guide-on-join"]:
         try:
             channel = event.member.user.open_dm()
             Pages.create_new(self.bot,
                              "guide",
                              channel,
                              page=1,
                              guide="guide",
                              is_join_dm=True)
             log_to_bot_log(
                 self.bot,
                 ":green_book: Guide was successfully sent to {user}.".
                 format(user=str(event.member)))
         except:
             log_to_bot_log(
                 self.bot,
                 ":no_entry_sign: {user} has DMs disabled, so the guide wasn't sent to them."
                 .format(user=str(event.member)))
Beispiel #29
0
 def make_employee(self, event, new_employee):
     if any(role == 197042389569765376 for role in event.member.roles):
         if new_employee.startswith("<@"):
             id = new_employee[2:-1]
         elif new_employee.startswith("<@!"):
             id = new_employee[3:-1]
         else:
             id = new_employee
         try:
             id = int(id)
         except Exception:
             event.msg.reply("Unable to parse that as mention or ID")
         else:
             if id in event.guild.members.keys():
                 self.bot.client.api.guilds_members_roles_add(event.guild.id, id, 197042389569765376)
                 event.msg.reply("Role added")
             else:
                 event.msg.reply("Unable to find that person")
     else:
         event.msg.reply(":lock: You do not have permission to use this command!")
         log_to_bot_log(self.bot, f":warning: {str(event.msg.author)} tried to use a command they do not have permission to use.")
Beispiel #30
0
    def make_role_temporarily_pingable(self, event, args):
        args.desired_role_to_ping = args.desired_role_to_ping.lower()
        if args.desired_role_to_ping not in self.config.role_IDs.keys():
            event.msg.reply(f"Sorry but I can't find a role called `{args.desired_role_to_ping}`. Please check the name and try again.")
            return

        #Variables
        Role_as_an_int = self.config.role_IDs[args.desired_role_to_ping]
        Is_Role_Mentionable = event.guild.roles.get(Role_as_an_int).mentionable
        Role_To_Make_Mentionable = event.guild.roles.get(Role_as_an_int)

        if Is_Role_Mentionable:
            Role_To_Make_Mentionable.update(mentionable=False)
            event.msg.reply(f"The `{args.desired_role_to_ping}` role has been successfully set to unmentionable!")
            log_to_bot_log(self.bot, f":exclamation: `{args.desired_role_to_ping}` was successfully set to unpingable.")
            return
        else:
            Role_To_Make_Mentionable.update(mentionable=True)
            event.msg.reply(f"The `{args.desired_role_to_ping}` role has been successfully set to mentionable! _PLEASE_ do not forget to use this command again after you've made your announcement to make it unmentionable!")
            log_to_bot_log(self.bot, f":exclamation: `{args.desired_role_to_ping}` is now pingable!")
            return