Skip to content
Permalink
Browse files

connect to cleverbot.com

  • Loading branch information...
Stefan
Stefan committed Jan 25, 2014
1 parent 1b0b990 commit cce743342ba9e9223638e27d4e478f228441ca36
Showing with 52 additions and 0 deletions.
  1. 0 __init__.py
  2. +3 −0 buildout.cfg
  3. +42 −0 spacebot.py
  4. +7 −0 versions.cfg
No changes.
@@ -11,3 +11,6 @@ newest = false
recipe = zc.recipe.egg
eggs =
jabberbot
xmpppy
extra-paths = ${buildout:directory}/cleverbot
interpreter = py
@@ -0,0 +1,42 @@
from jabberbot import JabberBot, botcmd
from chatterbotapi import ChatterBotFactory, ChatterBotType

class SpaceBot(JabberBot):

def __init__(self, cleversession, *args, **kargs):
self.cleverbot = cleversession
super(SpaceBot, self).__init__(*args, **kargs)

def unknown_command(self, mess, cmd, args):
question = mess.getBody()
question = question.encode("utf8")
node = str(mess.getFrom()).split('/')[1]
print node
if (node=='horscht'):
return None

print question
try:
answ = self.cleverbot.think(question)
except:
return None
print answ
return answ

@botcmd
def status(self, mess, args):
return "Hallo Welt, alles bestens!"


if __name__ == '__main__':
username = 'horscht@terminal21.de'
password = ''
chatroom = 'discuss@conference.terminal21.de'

factory = ChatterBotFactory()
cbot = factory.create(ChatterBotType.CLEVERBOT)
csession = cbot.create_session()

bot = SpaceBot(csession, username, password)
bot.join_room(chatroom)
bot.serve_forever()
@@ -0,0 +1,7 @@
[versions]
jabberbot = 0.15
zc.recipe.egg = 2.0.1
xmpppy = 0.5.0rc1
cleverbot = 0.1.1


0 comments on commit cce7433

Please sign in to comment.
You can’t perform that action at this time.