Source code for bot.plugs.set
# bot/plugs/set.py
#
#
""" set a tag on an object. """
## IMPORTS
from bot.utils import get_args, get_opts
from bot import kernel
import logging
## set command
[docs]def do_set(event):
try: attr, match, tag = get_args(event.rest)
except ValueError: logging.warn("set <attr> <match> <tag>") ; return
opts = get_opts(event.rest)
nr = 0
for obj in event.objects(attr):
if attr in obj and match in str(obj[attr]): obj[tag] = opts[tag] ; obj.sync() ; nr += 1
kernel.register("set", do_set)