Changed random generating to use SystemRandom, for better random numbers
This commit is contained in:
parent
aaa63a7c27
commit
2f9b75f5d7
3 changed files with 8 additions and 8 deletions
|
@ -77,7 +77,7 @@ class Core:
|
||||||
async def doggo(self, ctx):
|
async def doggo(self, ctx):
|
||||||
"""Use this to print a random doggo image.
|
"""Use this to print a random doggo image.
|
||||||
Doggo is love, doggo is life."""
|
Doggo is love, doggo is life."""
|
||||||
f = glob.glob('images/doggo*')[random.randint(0, len(glob.glob('images/doggo*')) - 1)]
|
f = glob.glob('images/doggo*')[random.SystemRandom().randint(0, len(glob.glob('images/doggo*')) - 1)]
|
||||||
with open(f, 'rb') as f:
|
with open(f, 'rb') as f:
|
||||||
await self.bot.upload(f)
|
await self.bot.upload(f)
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ class Core:
|
||||||
async def snek(self, ctx):
|
async def snek(self, ctx):
|
||||||
"""Use this to print a random snek image.
|
"""Use this to print a random snek image.
|
||||||
Sneks are o3o"""
|
Sneks are o3o"""
|
||||||
f = glob.glob('images/snek*')[random.randint(0, len(glob.glob('images/snek*')) - 1)]
|
f = glob.glob('images/snek*')[random.SystemRandom().randint(0, len(glob.glob('images/snek*')) - 1)]
|
||||||
with open(f, 'rb') as f:
|
with open(f, 'rb') as f:
|
||||||
await self.bot.upload(f)
|
await self.bot.upload(f)
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ class Core:
|
||||||
await self.bot.say("What die has more than 100 sides? Please, calm down")
|
await self.bot.say("What die has more than 100 sides? Please, calm down")
|
||||||
return
|
return
|
||||||
|
|
||||||
valueStr = ", ".join(str(random.randint(1, num)) for i in range(0, int(dice)))
|
valueStr = ", ".join(str(random.SystemRandom().randint(1, num)) for i in range(0, int(dice)))
|
||||||
|
|
||||||
if dice == 1:
|
if dice == 1:
|
||||||
fmt = '{0.message.author.name} has rolled a {2} sided die and got the number {3}!'
|
fmt = '{0.message.author.name} has rolled a {2} sided die and got the number {3}!'
|
||||||
|
|
|
@ -121,10 +121,10 @@ class Interaction:
|
||||||
battleP1 = discord.utils.find(lambda m: m.id == p1[0], ctx.message.server.members)
|
battleP1 = discord.utils.find(lambda m: m.id == p1[0], ctx.message.server.members)
|
||||||
battleP2 = ctx.message.author
|
battleP2 = ctx.message.author
|
||||||
|
|
||||||
fmt = config.battleWins[random.randint(0, len(config.battleWins) - 1)]
|
fmt = config.battleWins[random.SystemRandom().randint(0, len(config.battleWins) - 1)]
|
||||||
battlingOff(ctx.message.author.id)
|
battlingOff(ctx.message.author.id)
|
||||||
|
|
||||||
if random.randint(1, 100) < 50:
|
if random.SystemRandom().randint(0, 1):
|
||||||
await self.bot.say(fmt.format(battleP1.mention, battleP2.mention))
|
await self.bot.say(fmt.format(battleP1.mention, battleP2.mention))
|
||||||
updateBattleRecords(battleP1, battleP2)
|
updateBattleRecords(battleP1, battleP2)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -55,7 +55,7 @@ class Links:
|
||||||
|
|
||||||
# Get the link if it exists, if not return saying no results found
|
# Get the link if it exists, if not return saying no results found
|
||||||
if len(results) > 0:
|
if len(results) > 0:
|
||||||
index = random.randint(0, len(results) - 1)
|
index = random.SystemRandom().randint(0, len(results) - 1)
|
||||||
imageLink = 'http://{}'.format(results[index].get('representations').get('full')[2:].strip())
|
imageLink = 'http://{}'.format(results[index].get('representations').get('full')[2:].strip())
|
||||||
else:
|
else:
|
||||||
await self.bot.say("No results with that search term, {0}!".format(ctx.message.author.mention))
|
await self.bot.say("No results with that search term, {0}!".format(ctx.message.author.mention))
|
||||||
|
@ -97,7 +97,7 @@ class Links:
|
||||||
if len(data) == 1:
|
if len(data) == 1:
|
||||||
rand_image = data[0]['file_url']
|
rand_image = data[0]['file_url']
|
||||||
else:
|
else:
|
||||||
rand_image = data[random.randint(0, len(data)-1)]['file_url']
|
rand_image = data[random.SystemRandom().randint(0, len(data)-1)]['file_url']
|
||||||
await self.bot.say(rand_image)
|
await self.bot.say(rand_image)
|
||||||
|
|
||||||
def setup(bot):
|
def setup(bot):
|
||||||
|
|
Loading…
Reference in a new issue