Exemplo n.º 1
0
    def runTasks(self):
        for room in PREFS.all():
            if room == "global":
                continue

            # Skip room if we're in lockdown mode.
            if PREFS.get(room, "lockdown", False):
                continue

            for task in self._tasks:
                if str(task) in PREFS.get(room, "enabled_tasks", []):
                    taskEntry = self._tasks[task]
                    if (int(time.time()) -
                            taskEntry["lastRun"]) >= taskEntry["runDelay"]:
                        # print("Running task " + task)
                        taskEntry["function"](room)
                        taskEntry["lastRun"] = calendar.timegm(time.gmtime())
Exemplo n.º 2
0
    ckey = "%06x" % random.randint(0, 0xFFFFFF)
    PREFS.set("global", "captain_key", ckey)
    print("Please run this command to gain superuser privileges (single-use!):\n\n " + WolfUtils.CMD_DELIM + "iamthecaptainnow " + ckey.upper() + "\n\n")
    

# Register the Client to be used
client = chatexchange6.Client('stackexchange.com')
client.login(__USER__, __PASS__)

# Get the Bot itself
me = client.get_me()

SESSION_STORAGE.set("bot_username", me.name.replace(" ", ""))
SESSION_STORAGE.set("bot_id", client._br.user_id)

allRooms = PREFS.all()

if len(allRooms) == 1:
    PREFS.set("1", "active", True)

for room in allRooms:
    if room == "global":
        continue

    if PREFS.get(room, "active", True):
        PREFS.set(room, "active", True)
        print("Updated room ID " + str(room) + " to new prefs format. It is now Active.")
    else:
        continue

    # Bind the user to the chat room