async def beam_edit(self, ctx, name: str, key: str, value: str): """Edit beam""" if not repo_b.exists(name): raise errors.BadArgument("Invalid beam") if key in ("active", "admin_id", "replace", "timeout"): try: value = int(value) except ValueError: raise errors.BadArgument("Value has to be integer.") announce = True if key in ("admin_id"): announce = False repo_b.set(name=name, key=key, value=value) await self.event.sudo(ctx, f"Beam **{name}** updated: {key} = {value}.") if not announce: return await self.announce(beam=name, message=f"Beam updated: {key} is now {value}.")
async def beam_open(self, ctx, name: str): """Open closed beam""" repo_b.set(name=name, key="active", value=1) await self.event.sudo(ctx, f"Beam **{name}** opened.") await self.announce(beam=name, message="Beam opened!")
async def beam_close(self, ctx, name: str): """Close beam""" repo_b.set(name=name, key="active", value=0) await self.event.sudo(ctx, f"Beam **{name}** closed.") await self.announce(beam=name, message="Beam closed.")