def _create(self): """creates buckets unless they already exist""" if self.bucket: self.caller.msg(ERROR_PRE + "Bucket: %s already exists." % ju.decorate(self.bucket_name)) return else: ev.create_channel(self.bucket_name, desc=self.rhs, typeclass="world.jobs.bucket.Bucket") self._assign_bucket(self.bucket_name) self.bucket.db.createdby = self.caller self.caller.msg(SUCC_PRE + "Bucket: %s has been created." % ju.decorate(self.bucket_name))
def test_autocmdsets(self): import evennia from evennia.commands.default.cmdset_account import AccountCmdSet from evennia.comms.channelhandler import CHANNEL_HANDLER testchannel = evennia.create_channel("channeltest", locks="listen:all();send:all()") CHANNEL_HANDLER.add(testchannel) CHANNEL_HANDLER.update() self.assertTrue(testchannel.connect(self.account)) self.assertTrue(testchannel.has_connection(self.account)) a, b, c, d = self.cmdset_a, self.cmdset_b, self.cmdset_c, self.cmdset_d self.set_cmdsets(self.account, a, b, c, d) deferred = cmdhandler.get_and_merge_cmdsets(self.session, self.session, self.account, self.char1, "session", "") def _callback(cmdset): pcmdset = AccountCmdSet() pcmdset.at_cmdset_creation() pcmds = [cmd.key for cmd in pcmdset.commands ] + ["a", "b", "c", "d"] + ["out"] self.assertTrue( all(cmd.key or hasattr(cmd, "is_channel") in pcmds for cmd in cmdset.commands)) self.assertTrue( any(hasattr(cmd, "is_channel") for cmd in cmdset.commands)) deferred.addCallback(_callback) return deferred
def SubmitJob(self, name, location, subject): handlervar = search.scripts('JobHandler') failstring = 'A critical failure has occurred while hunting in ' + location + ' staff is advised to run a scene to play out the consequences.' try: handlervar = handlervar[0] except IndexError: handlervar = create_script('world.jobs.JobHandler',key='JobHandler',persistent=True) self.caller.msg("Jobs system initialized.") try: jobchan = search.channels('Jobs')[0] except IndexError: jobchan = create_channel('Jobs',desc='A channel for announcing incoming jobs to staff.',locks='control:perm(Developer);listen:perm(Admin);send:false()') date = time.strftime("%a") + " " + time.strftime("%b") + " " + time.strftime("%d") gen_deadline = datetime.date.today() + datetime.timedelta(days=7) gen_deadline = gen_deadline.strftime("%a %b %d") commenttime = date + " at " + time.strftime("%I").strip("0") + ":" + time.strftime("%M") + " " + time.strftime("%p") try: handlervar.db.joblist[handlervar.db.buckets['HUNT'] - 1].append([name,subject,date,gen_deadline,tuple([subject,failstring,commenttime])]) jobchan.msg("A critical failure on hunting has occurred, generating a job named: " + name) return except KeyError: handlervar.db.buckets['HUNT'] = len(handlervar.db.buckets) + 1 handlervar.db.joblist.append([]) handlervar.db.deadlines.append(['7']) handlervar.db.joblist[handlervar.db.buckets['HUNT'] - 1].append([name,subject,date,gen_deadline,tuple([subject,failstring,commenttime])]) jobchan.msg("A critical failure on hunting has occurred, generating a job named: " + name) return
def _create(self, caller): """creates buckets unless they already exist""" # Exists? if self.bucket: caller.msg(_ERROR_PRE + "Bucket: |w%s|n already exists." % self.bucket_name) return # Description? try: ev.create_channel(self.bucket_name, desc=self.rhs_text, typeclass="world.jobs.bucket.Bucket") self._assign_bucket(self.bucket_name) self.bucket.db.createdby = self.caller.key caller.msg(_SUCC_PRE + "Bucket: |w%s|n has been created." % self.bucket_name) except AttributeError: self.caller.msg(_ERROR_PRE + "A description must be provided for the bucket.")
def AddBeat(self, source, reason): try: beatchannel = search.channels('Beats')[0] except IndexError: beatchannel = create_channel( 'Beats', desc= 'A log of all beats gained by players outside of daily gains', locks= 'control:perm(Immortals);listen:perm(Wizards);send:false()') self.db.beatlog.append("From |400" + source + "|n On |224" + time.strftime("%b") + " " + time.strftime("%d") + " " + time.strftime("%Y") + "|n for |040" + reason + "|n") beatchannel.msg(self.name + " added a beat for |040" + reason + "|n from |400" + source)
def test_autocmdsets(self): import evennia from evennia.commands.default.cmdset_player import PlayerCmdSet from evennia.comms.channelhandler import CHANNEL_HANDLER testchannel = evennia.create_channel("channeltest", locks="listen:all();send:all()") CHANNEL_HANDLER.add(testchannel) CHANNEL_HANDLER.update() self.assertTrue(testchannel.connect(self.player)) self.assertTrue(testchannel.has_connection(self.player)) a, b, c, d = self.cmdset_a, self.cmdset_b, self.cmdset_c, self.cmdset_d self.set_cmdsets(self.player, a, b, c, d) deferred = cmdhandler.get_and_merge_cmdsets(self.session, self.session, self.player, self.char1, "session", "") def _callback(cmdset): pcmdset = PlayerCmdSet() pcmdset.at_cmdset_creation() pcmds = [cmd.key for cmd in pcmdset.commands] + ["a", "b", "c", "d"] + ["out"] self.assertTrue(all(cmd.key or hasattr(cmd, "is_channel") in pcmds for cmd in cmdset.commands)) self.assertTrue(any(hasattr(cmd, "is_channel") for cmd in cmdset.commands)) deferred.addCallback(_callback) return deferred
def _create(self): """ job/create <bucket>/<title>=<comments> Creates a new job in Bucket with Title and Comments :param self: :param bucket: :param title: :param text: :return: """ # Set up our arguments args = [self.lhs_obj, self.lhs_act, self.rhs] bucket, title, msgtext = args if ju.isbucket(bucket): if args: # Job Creation jhash = '%s %s %s %s' % (bucket, title, date.today().strftime(), str(random.randrange(1,1000000))) jid = hashlib.md5(jhash.encode(utf-8)).hexdigest() self.job = ev.create_channel(jid, desc=title, typeclass="world.jobs.job.Job") self.job.tags.add(bucket, category="jobs") self.job.tags.add(job, category="jobs") self._add_msg(jid=jid, bucket=bucket, title=title, msgtext=msgtext, action="create", parent=jid) ret = SUCC_PRE + "Job: %s created." % ju.decorate(title) # No args else: sysmsg = ERROR_PRE + "The correct syntax is +job/create Bucket/Title=Text" # No bucket else: sysmsg = ERROR_PRE + "%s is an invalid bucket." % ju.decorate(bucket) ret = {} act = "cre" ret[msg] = {"act": act, "actlist": self.job.db.actions_list, "caller": self.caller, "stat": exit_status, "msg": msg} return ret