User:Chaser Zaks/Persistant Bots

From Second Life Wiki
< User:Chaser Zaks
Revision as of 14:21, 16 April 2019 by Chaser Zaks (talk | contribs) (w)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Persistent bots are bots that will automatically reconnect to Second Life when they are disconnected. This often, unfortunately, includes when they are administratively kicked.

Proper bots should not attempt to reconnect when they receive KickUser from the simulator.

Example message

{
    "KickUser":
    {
        "TargetBlock":
        {
            "TargetIP": "0.0.0.0",
            "TargetPort": 0
        },
        "UserInfo":
        {
            "AgentID": gAgent.getID(),
            "SessionID": gAgent.getSessionID(),
            "Reason": "You have been logged out by an administrator."
        }
    }
}

Example Implementation

class bot:
    def connect(self):
       ...
    def onMessage(self, msg):
        if msg.name == "KickUser":
            self.kicked = True

while True:
    bot.connect()
    if bot.kicked:
        break