User:Chaser Zaks/Persistant Bots

From Second Life Wiki
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