def test_deny_doc_id(self):
     subject = SoundeffectRequest(
         user="******",
         command="damn",
         youtube_id="VW2yff3su0U",
         start_time="00:01",
         end_time="00:05",
     )
     subject.save()
     request = SoundeffectRequest.get(command="damn")
     SoundeffectRequest.deny_doc_id("denier", request.doc_id)
     assert "damn" not in [
         request["command"] for request in SoundeffectRequest.all()
     ]
Example #2
0
    def route(self):
        if self.command == "soundeffect":
            try:
                sfx_request = SoundeffectRequestParser(self.user, self.args).parse()
            except Exception as e:
                return f'@{self.user} Correct Syntax: {HELP_COMMANDS["soundeffect"]}'

            SoundeffectRequest(
                user=self.user,
                youtube_id=sfx_request.youtube_id,
                command=sfx_request.command,
                start_time=sfx_request.start_time,
                end_time=sfx_request.end_time,
            ).save()

            return f"Thank you for your request @{self.user}, beginbotbot will you inform you when !{sfx_request.command} is available"

        # "!approve all"
        # "!approve 1"
        # "!approve @artmattdank"
        # "!approve !new_command"
        if self.command == "approve":
            if self.user in STREAM_LORDS:

                parser = RequestApproverParser(user=self.user, args=self.args).parse()

                if parser.target_user:
                    return SoundeffectRequest.approve_user(
                        self.user, parser.target_user
                    )
                elif parser.target_command:
                    return SoundeffectRequest.approve_command(
                        self.user, parser.target_command
                    )
                elif parser.doc_id:
                    return SoundeffectRequest.approve_doc_id(self.user, parser.doc_id)
                else:
                    return "Not Sure What to Approve"

        if self.command in ["deny"]:
            if self.user in STREAM_LORDS:
                parser = RequestApproverParser(user=self.user, args=self.args).parse()
                if parser.doc_id:
                    SoundeffectRequest.deny_doc_id(self.user, parser.doc_id)
                    return f"@{self.user} DENIED Request: {parser.doc_id}"

        if self.command in ["issue", "bug", "feature"]:
            if self.args:
                msg = " ".join(self.args)
                issue = Issue(user=self.user, msg=msg).save()
                return f"Thank You @{self.user} for your feedback, we will review and get back to you shortly"
            else:
                return f"@{self.user} Must include a description of the !issue"

        if self.command == "delete_issue" and self.user in STREAM_GODS:
            parser = RequestApproverParser(user=self.user, args=self.args).parse()

            if parser.doc_id:
                Issue.delete(parser.doc_id)
                return f"Issue: {parser.doc_id} Deleted "

        if self.command == "issues" and self.user in STREAM_GODS:
            return [
                f"@{issue['user']} ID: {issue.doc_id} - {issue['msg']}"
                for issue in Issue.all()
            ]

        if self.command == "requests":
            stats = SoundeffectRequest.formatted_stats()
            if not stats:
                stats = "Excellent Job Stream Lords No Requests!"
            return stats
 def test_deny_doc_id_when_request_is_not_real(self):
     user = "******"
     doc_id = 1
     # We expect this to throw an error
     SoundeffectRequest.deny_doc_id(user, doc_id)