예제 #1
0
파일: tags.py 프로젝트: 1lann/PCSocBot
 def eval(self, platform):
     platform = platform.lower()
     tags = Tag.select_or_err(lambda x: x.platform == platform)
     return EmbedTable(fields=['User', 'Tag'],
                       table=[(self.from_id(tag.user).name, tag.tag)
                              for tag in tags],
                       title="Showing tags for " + platform.title(),
                       colour=self.EMBED_COLOR)
예제 #2
0
 def eval(self, name):
     user = self.from_name(name)
     if user is None:
         raise CommandFailure("User not found")
     tags = Tag.select_or_err(lambda x: x.user == int(user.id), "User has no tags")
     return EmbedTable(fields=['Platform', 'Tag'],
                       table=[(x.platform.title(), x.tag) for x in tags],
                       colour=self.EMBED_COLOR, user=user,
                       title="Tags for " + bold(user.name))
예제 #3
0
    async def eval(self):
        # Open the JSON file or create a new dict to load
        try:
            with open(WHITELIST_FILE, 'r') as old:
                whitelist_dict = json.load(old)
        except FileNotFoundError:
            raise CommandFailure('Whitelist is empty!')

        return EmbedTable(fields=['User', 'MC Name'],
                          table=[(self.from_id(user).name, mc_user['name']) for user, mc_user in whitelist_dict.items()],
                          colour=self.EMBED_COLOR,
                          title="Minecraft Whitelist")
예제 #4
0
파일: tags.py 프로젝트: inuradz/PCSocBot
    def eval(self, platform):
        platform = platform.lower()
        tags = Tag.select_or_err(lambda x: x.platform == platform)
        tab = []
        for tag in tags:
            try:
                tab.append((self.from_id(tag.user).name, tag.tag))
            except AttributeError:
                continue

        return EmbedTable(fields=['User', 'Tag'],
                          table=tab,
                          title="Showing tags for " + platform.title(),
                          colour=self.EMBED_COLOR)
예제 #5
0
    def eval(self):
        # Open the JSON file, skip if it does not exist
        try:
            with open(TWITCH_FILE, 'r') as old:
                channels = json.load(old)
        except FileNotFoundError:
            raise CommandFailure("Broadcaster list is empty!")

        names = [value['name'] for key, value in channels['channels'].items()]
        names = sorted(names)

        return EmbedTable(fields=['Broadcasters'],
                          table=[(name, ) for name in names],
                          colour=TWITCH_COLOR)
예제 #6
0
파일: tags.py 프로젝트: inuradz/PCSocBot
 def eval(self):
     tags = [(platform, )
             for platform in sorted(select(x.platform for x in Tag))]
     return EmbedTable(fields=['Platform'],
                       table=tags,
                       colour=self.EMBED_COLOR)