mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-12 22:49:53 -05:00
test uuid system
This commit is contained in:
parent
6f124a4fbd
commit
155f6a8ec1
@ -9,6 +9,7 @@ from sopel.tools import Identifier
|
|||||||
import functools
|
import functools
|
||||||
import copy
|
import copy
|
||||||
import datetime
|
import datetime
|
||||||
|
import uuid
|
||||||
import spicemanip
|
import spicemanip
|
||||||
|
|
||||||
from .Tools import command_permissions_check
|
from .Tools import command_permissions_check
|
||||||
@ -18,6 +19,8 @@ from .Database import db as spicedb
|
|||||||
|
|
||||||
class BotPrerun():
|
class BotPrerun():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
self.usedids = [0]
|
||||||
|
self.utilizedids = []
|
||||||
self.dict = {}
|
self.dict = {}
|
||||||
|
|
||||||
def prerun(self, trigger_command_type='module'):
|
def prerun(self, trigger_command_type='module'):
|
||||||
@ -53,15 +56,19 @@ class BotPrerun():
|
|||||||
|
|
||||||
# Run the function for all splits
|
# Run the function for all splits
|
||||||
for argsdict in argsdict_list:
|
for argsdict in argsdict_list:
|
||||||
|
trigger.sb["uuid"] = self.unique_id_create()
|
||||||
trigger.sb = copy.deepcopy(argsdict)
|
trigger.sb = copy.deepcopy(argsdict)
|
||||||
trigger.sb["args"], trigger.sb["hyphen_arg"] = self.trigger_hyphen_args(trigger.sb["args"])
|
trigger.sb["args"], trigger.sb["hyphen_arg"] = self.trigger_hyphen_args(trigger.sb["args"])
|
||||||
if not trigger.sb["hyphen_arg"]:
|
if not trigger.sb["hyphen_arg"]:
|
||||||
# check if anything prohibits the nick from running the command
|
# check if anything prohibits the nick from running the command
|
||||||
if self.trigger_runstatus(bot, trigger):
|
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:
|
else:
|
||||||
bot.say(trigger.sb["hyphen_arg"])
|
if trigger.sb["uuid"] not in self.utilizedids:
|
||||||
# self.trigger_hyphen_arg_handler(bot, trigger)
|
self.trigger_hyphen_arg_handler(bot, trigger)
|
||||||
|
self.utilizedids.append(trigger.sb["uuid"])
|
||||||
|
|
||||||
return internal_prerun
|
return internal_prerun
|
||||||
return actual_decorator
|
return actual_decorator
|
||||||
@ -173,5 +180,12 @@ class BotPrerun():
|
|||||||
|
|
||||||
return True
|
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()
|
prerun = BotPrerun()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user