test uuid system

This commit is contained in:
deathbybandaid 2019-05-23 21:20:39 -04:00
parent 6f124a4fbd
commit 155f6a8ec1

View File

@ -9,6 +9,7 @@ from sopel.tools import Identifier
import functools
import copy
import datetime
import uuid
import spicemanip
from .Tools import command_permissions_check
@ -18,6 +19,8 @@ from .Database import db as spicedb
class BotPrerun():
def __init__(self):
self.usedids = [0]
self.utilizedids = []
self.dict = {}
def prerun(self, trigger_command_type='module'):
@ -53,15 +56,19 @@ class BotPrerun():
# Run the function for all splits
for argsdict in argsdict_list:
trigger.sb["uuid"] = self.unique_id_create()
trigger.sb = copy.deepcopy(argsdict)
trigger.sb["args"], trigger.sb["hyphen_arg"] = self.trigger_hyphen_args(trigger.sb["args"])
if not trigger.sb["hyphen_arg"]:
# check if anything prohibits the nick from running the command
if self.trigger_runstatus(bot, trigger):
function(bot, trigger, *args, **kwargs)
if trigger.sb["uuid"] not in self.utilizedids:
function(bot, trigger, *args, **kwargs)
self.utilizedids.append(trigger.sb["uuid"])
else:
bot.say(trigger.sb["hyphen_arg"])
# self.trigger_hyphen_arg_handler(bot, trigger)
if trigger.sb["uuid"] not in self.utilizedids:
self.trigger_hyphen_arg_handler(bot, trigger)
self.utilizedids.append(trigger.sb["uuid"])
return internal_prerun
return actual_decorator
@ -173,5 +180,12 @@ class BotPrerun():
return True
def unique_id_create(self):
unique_id = 0
while unique_id in self.usedids:
unique_id = uuid.uuid4()
self.usedids.append(unique_id)
return unique_id
prerun = BotPrerun()