Examples ======== If you're having trouble getting the chatbot setup, or don't know whether or not you want to start making the code, go no further! Easy examples will be shown here, as well as advanced examples. Usage ------ The following is nothing more than connecting to the chat, idling in the room:: import chatbot class MyBot(chatbot.ChatBot): """ This class inherites the chatbot """ def __init__(self, username, password, site): chatbot.ChatBot__init__(self, username, password, site) if __name__ == '__main__': bot = MyBot("MyUsername", "MyPassword", "http://mywiki.wikia.com") bot.start() To read the messages back to the user in terminal/command prompt, an event has to be used:: import chatbot class MyBot(chatbot.ChatBot): def __init__(self, username, password, site): chatbot.ChatBot__init__(self, username, password, site) def on_message(self, c, e): """ c - connection/client e - event This is what we'll use to gather and send data """ print "%s: %s" % (e.user, e.text) if __name__ == '__main__': bot = MyBot("MyUsername", "MyPassword", "http://mywiki.wikia.com") bot.start Replying multiple events in the chatroom, example being a kick and a ban:: import chatbot class MyBot(chatbot.ChatBot): def __init__(self, username, password, site): chatbot.ChatBot__init__(self, username, password, site) def on_kick(self, c, e): c.send("Oh dear!") def on_ban(self, c, e): c.send("Oh no! This is not good!") if __name__ == '__main__': bot = MyBot("MyUsername", "MyPassword", "http://mywiki.wikia.com") bot.start()