Skip to content

Instantly share code, notes, and snippets.

@AbstractBeliefs
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AbstractBeliefs/43c8aabf6ad7099b1134 to your computer and use it in GitHub Desktop.
Save AbstractBeliefs/43c8aabf6ad7099b1134 to your computer and use it in GitHub Desktop.
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