Last active
August 29, 2015 14:00
-
-
Save AbstractBeliefs/43c8aabf6ad7099b1134 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CraicBot(sleekxmpp.ClientXMPP): | |
# Initiate the bot, set event handlers for when messages come in | |
def __init__(self, jid, password, room, nick): | |
sleekxmpp.ClientXMPP.__init__(self, jid, password) | |
self.room = room | |
self.nick = nick | |
self.add_event_handler("session_start", self.start) | |
self.add_event_handler("message", self.message) | |
def defaultSay(message): | |
self.send_message(mto=self.room, mbody=message, mtype="groupchat") | |
# Join a room | |
def start(self, event): | |
self.send_presence() | |
self.get_roster() | |
self.plugin['xep_0045'].joinMUC(self.room, self.nick, wait=True) | |
# When a message cointaining our name is sent, reply | |
def message(self, msg): | |
functionality.handler(self, msg) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment