@@ -0,0 +1,2847 @@
+#!/usr/bin/env python%0A# -*- coding: utf-8 -*-%0A%0Aimport os.path%0Aimport sys%0Aimport logging%0Aimport getpass%0Aimport aiml%0Afrom optparse import OptionParser%0A%0Aimport sleekxmpp%0A%0Aif sys.version_info %3C (3, 0):%0A    from sleekxmpp.util.misc_ops import setdefaultencoding%0A    setdefaultencoding('utf8')%0Aelse:%0A    raw_input = input%0A%0A%0Aclass HiHiBot(sleekxmpp.ClientXMPP):%0A%0A    def __init__(self, jid, password):%0A        self.aiml = aiml.Kernel()%0A        if os.path.isfile(%22standard.brn%22):%0A            self.aiml.bootstrap(brainFile=%22standard.brn%22)%0A        else:%0A            self.aiml.bootstrap(learnFiles=%22std-startup.xml%22, commands=%22load aiml b%22)%0A            self.aiml.saveBrain(%22standard.brn%22)%0A        self.aiml.setBotPredicate(%22name%22, %22%E6%B5%B7%E6%B4%8B%22)%0A        sleekxmpp.ClientXMPP.__init__(self, jid, password)%0A        self.add_event_handler(%22session_start%22, self.start)%0A        self.add_event_handler(%22message%22, self.message)%0A%0A    def start(self, event):%0A        self.send_presence()%0A        self.get_roster()%0A%0A    def message(self, msg):%0A        if msg%5B'type'%5D in ('chat', 'normal'):%0A            result = self.aiml.respond(msg%5B%22body%22%5D, msg%5B%22from%22%5D)%0A            if result:%0A                msg.reply(result).send()%0A%0A%0Aif __name__ == '__main__':%0A    # Setup the command line arguments.%0A    optp = OptionParser()%0A%0A    # Output verbosity options.%0A    optp.add_option('-q', '--quiet', help='set logging to ERROR',%0A                    action='store_const', dest='loglevel',%0A                    const=logging.ERROR, default=logging.INFO)%0A    optp.add_option('-d', '--debug', help='set logging to DEBUG',%0A                    action='store_const', dest='loglevel',%0A                    const=logging.DEBUG, default=logging.INFO)%0A    optp.add_option('-v', '--verbose', help='set logging to COMM',%0A                    action='store_const', dest='loglevel',%0A                    const=5, default=logging.INFO)%0A%0A    # JID and password options.%0A    optp.add_option(%22-j%22, %22--jid%22, dest=%22jid%22,%0A                    help=%22JID to use%22)%0A    optp.add_option(%22-p%22, %22--password%22, dest=%22password%22,%0A                    help=%22password to use%22)%0A%0A    opts, args = optp.parse_args()%0A%0A    # Setup logging.%0A    logging.basicConfig(level=opts.loglevel,%0A                        format='%25(levelname)-8s %25(message)s')%0A    if opts.jid is None:%0A        opts.jid = raw_input(%22Username: %22)%0A    if opts.password is None:%0A        opts.password = getpass.getpass(%22Password: %22)%0A%0A    xmpp = HiHiBot(opts.jid, opts.password)%0A    xmpp.register_plugin('xep_0030') # Service Discovery%0A    xmpp.register_plugin('xep_0004') # Data Forms%0A    xmpp.register_plugin('xep_0060') # PubSub%0A    xmpp.register_plugin('xep_0199') # XMPP Ping%0A%0A    # Connect to the XMPP server and start processing XMPP stanzas.%0A    if xmpp.connect():%0A        xmpp.process(block=True)%0A        print(%22Done%22)%0A    else:%0A        print(%22Unable to connect.%22)%0A

Create hihi.sleekxmpp.aiml.py