Beispiel #1
0
 async def help(self, ctx):
     description = 'To subscribe to a service type `!service init <servicename>`\n'
     description = description + 'To unsubscribe to a service type `!service deinit <servicename>`\n'
     description = description + 'Available services are : \n'
     servicelist = getServiceList()
     for service in servicelist:
         description = description + f'**{service : <30}** - {servicelist[service]}\n'
     description = description + '\n'
     description = description + 'Type the ***init*** and ***deinit*** command in channel you want to subscribe service in.'
     description = description + ' Multiple service can be subscribed to in one channel.'
     embed = discord.Embed(title='Service List', description=description)
     await ctx.send(embed=embed)
Beispiel #2
0
    async def deinit(self, ctx, name: str):
        # get the service list
        servicelist = getServiceList()

        flag = False
        # check if service name entered is real service or not
        for service in servicelist:
            if service == name:
                flag = True
                break

        if flag:
            data = {}
            data['guild_id'] = ctx.guild.id
            data['channel_id'] = ctx.channel.id
            data['channel_name'] = ctx.channel.name
            data['service_name'] = name
            res = self.db.deleteChannelMapping(data)
            if res == STATUS.SUCCESS:
                await ctx.send(f'service *{name}* is now deactivated.')
                logging = getLogChannel(ctx.guild.id)
                if logging:
                    await self.bot.get_channel(logging).send(
                        f'**Service de-activated**: *{ctx.author.name}* de-activated service *{name}* for channel *{ctx.channel.name}*.'
                    )
            elif res == STATUS.FAIL.NOT_FOUND:
                await ctx.send(
                    f'Service *{name}* is already deactivated for this channel.'
                )
            else:
                await ctx.send(
                    f'Service *{name}* could not be deactivated for this channel.'
                )
        else:
            await ctx.send(
                f'Service *{name}* not found, see `!help service` for list of available services.'
            )