Esempio n. 1
0
 def _remove_connection(self):
     # remove link data
     if self.name not in SETTINGS.social_links:
         raise errors.FatalError(
             "social network state error : was in connected state but cannot find link data"
         )
     del (SETTINGS.social_links[self.name])
Esempio n. 2
0
    async def set_rally_id(self, ctx):
        member = ctx.author

        with self.update_lock:
            for guild in self.bot.guilds:
                await guild.chunk()

                if not member in guild.members:
                    continue

                role_mappings = list(data.get_role_mappings(guild.id))
                channel_mappings = list(data.get_channel_mappings(guild.id))

                rally_id = data.get_rally_id(member.id)
                if rally_id:
                    balances = rally_api.get_balances(rally_id)
                    for role_mapping in role_mappings:
                        try:
                            await grant_deny_role_to_member(
                                role_mapping, member, balances)
                        except discord.HTTPException:
                            raise errors.RequestError(
                                "network error, try again later")
                        except:
                            # Forbidden, NotFound or Invalid Argument exceptions only called when code
                            # or bot is wrongly synced / setup
                            raise errors.FatalError(
                                "bot is setup wrong, call admin")
                    for channel_mapping in channel_mappings:
                        try:
                            await grant_deny_channel_to_member(
                                channel_mapping, member, balances)
                        except discord.HTTPException:
                            raise errors.RequestError(
                                "network error, try again later")
                        except:
                            # Forbidden, NotFound or Invalid Argument exceptions only called when code
                            # or bot is wrongly synced / setup
                            raise errors.FatalError(
                                "bot is setup wrong, call admin")

            await pretty_print(
                ctx,
                "Command completed successfully!",
                title="Success",
                color=SUCCESS_COLOR,
            )
Esempio n. 3
0
 def call_api(self, api_endpoint, parameters):
     # this method is supposed to be redefined in child classes
     raise errors.FatalError(
         "social network missing call_api implementation")
Esempio n. 4
0
 def get_configuration(self):
     # this method is supposed to be redefined in child classes
     raise errors.FatalError(
         "social network missing get_configuration implementation")
Esempio n. 5
0
 def _make_connection(self, connection_data):
     # this method is supposed to be redefined in child classes
     raise errors.FatalError(
         "social network missing _make_connection implementation")