class LeaderboardsServerFactory(ServerFactory): protocol = LeaderboardsProtocol def startFactory(self): self.leaderboards_service = Leaderboards( self.max_clients, self.db_name, self.db_host, self.db_port, self.secret ) def __init__(self, max_clients, service, db_name, db_host, db_port, secret): """ Server factory constructor """ self.service = service self.max_clients = max_clients self.db_name = db_name self.db_host = db_host self.db_port = db_port self.secret = secret log.msg("Leaderboards server initialized") def buildProtocol(self, addr): """ This method calls when new client connected """ p = self.protocol() p.factory = self p = self.leaderboards_service.initClient(p, addr) log.msg("class LeaderboardsServerFactory, method buildProtocol: protocol was built") return p
def startFactory(self): self.leaderboards_service = Leaderboards( self.max_clients, self.db_name, self.db_host, self.db_port, self.secret )
'{author} tried to slap {target} but missed. Clumsy!', ] @bot.event async def on_ready(): print(f'{bot.user} has connected to Discord!') @bot.command( name='roll', help= 'Rolls a class, either from a provided list (separated by space), or from a pre-selected list.' ) async def roll(ctx, *elements): list = elements or roll_list sample = random.sample(list, 1)[0] await ctx.send(str(sample)) @bot.command(name='slap', help='Slap someone with a random object') async def roll(ctx, target): sample = random.sample(slap_list, 1)[0] await ctx.send(sample.format(author=ctx.author, target=target)) bot.add_cog(Leaderboards(bot)) bot.add_cog(Info(bot)) bot.add_cog(ClassCalls(bot)) bot.run(TOKEN)