当前位置: 首页>>代码示例>>Python>>正文


Python ChatterBotFactory.create方法代码示例

本文整理汇总了Python中chatterbotapi.ChatterBotFactory.create方法的典型用法代码示例。如果您正苦于以下问题:Python ChatterBotFactory.create方法的具体用法?Python ChatterBotFactory.create怎么用?Python ChatterBotFactory.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在chatterbotapi.ChatterBotFactory的用法示例。


在下文中一共展示了ChatterBotFactory.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: do

# 需要导入模块: from chatterbotapi import ChatterBotFactory [as 别名]
# 或者: from chatterbotapi.ChatterBotFactory import create [as 别名]
def do(speech):

     factory = ChatterBotFactory()

     bot1 = factory.create(ChatterBotType.CLEVERBOT)
     bot1session = bot1.create_session()

     bot2 = factory.create(ChatterBotType.PANDORABOTS, 'b0dafd24ee35a477')
     bot2session = bot2.create_session()

     while(speech!="bye bye"):

        if speech.find("search twitter for")!=-1:
             speech=speech.replace("search twitter for",'')
             search.main(speech)
        elif speech.find("show twitter trend")!=-1:
             trending.main()
        elif speech.find("tell the weather")!=-1:
             weather.main()
        elif speech.find('show my e-mail')!=-1:
             mailtest.main()
        elif speech.find('send email')!=-1:
             mailtest2.main()
        elif speech.find('search bing for')!=-1:
             speech=speech.replace('search bing for','')
             bingsearch.main(speech)
        else:
             s = bot2session.think(speech);
             print 'yam> ' + s
             talks.main(s) 
            

        speech=listen()
        speech=speech.lower()     
开发者ID:gpratyush,项目名称:Yam,代码行数:36,代码来源:trytry.py

示例2: main

# 需要导入模块: from chatterbotapi import ChatterBotFactory [as 别名]
# 或者: from chatterbotapi.ChatterBotFactory import create [as 别名]
    def main():
        factory = ChatterBotFactory()
        print 'hi'
        bot2 = factory.create(ChatterBotType.PANDORABOTS, 'b0dafd24ee35a477')
        bot2session = bot2.create_session()

        api = get_api()
        if not api:
            return
        try:
            status = api.received_messages(count=1)
        except tweetpony.APIError as err:
            print "Oh no! Your tweet could not be sent. Twitter returned error #%i and said: %s" % (err.code, err.description)
        else:
           message_id=status[0]['id']
           user_id=status[0]['sender_screen_name']
        status = api.received_messages(since_id=message_id)
        while(1):
            if status:
                message_id=status[0]['id']
                user_id=status[0]['sender_screen_name']
                s = status[0]['text']
                if s=='Take':
                
                    s='You can download the image from the link - '+take_image();
                else:
                    s = bot2session.think(s);
                api.send_message(screen_name=user_id,text=s)
            time.sleep(60)
            status=api.received_messages(since_id=message_id)           
开发者ID:eclubiitk,项目名称:ZIZO101,代码行数:32,代码来源:demo.py

示例3: sms

# 需要导入模块: from chatterbotapi import ChatterBotFactory [as 别名]
# 或者: from chatterbotapi.ChatterBotFactory import create [as 别名]
def sms():
    factory = ChatterBotFactory()
    bot = factory.create(ChatterBotType.CLEVERBOT)
    botSession = bot.create_session()
    
    text = request.form.get('Body', '')
    text = botSession.think(text)

    response = twiml.Response()
    response.sms(text)
    return str(response)
开发者ID:jromer94,项目名称:CleverText,代码行数:13,代码来源:app.py

示例4: _setup

# 需要导入模块: from chatterbotapi import ChatterBotFactory [as 别名]
# 或者: from chatterbotapi.ChatterBotFactory import create [as 别名]
    def _setup(self):

        factory = ChatterBotFactory()
        self.bot = factory.create(ChatterBotType.CLEVERBOT)
        self.template = spade.Behaviour.ACLTemplate()
        self.template.setLanguage('english')
        self.t = spade.Behaviour.MessageTemplate(self.template)

        self.addBehaviour(self.MessageManager(), self.t)
        if self.sendFirst:
            self.addBehaviour(self.InitChatBot())
开发者ID:ivpusic,项目名称:spade-samples,代码行数:13,代码来源:chatbot.py

示例5: ChatterBots

# 需要导入模块: from chatterbotapi import ChatterBotFactory [as 别名]
# 或者: from chatterbotapi.ChatterBotFactory import create [as 别名]
class ChatterBots():
    def __init__(self):
        self.factory = ChatterBotFactory()
        self.jabberwacky = self.factory.create(ChatterBotType.JABBERWACKY)
        self.conversations = {}

    def respond(self,question, conversation_id):
        try:
            self.conversations[conversation_id]
        except KeyError:
            self.conversations[conversation_id] = self.jabberwacky.create_session()

        return self.conversations[conversation_id].think(question)
开发者ID:LeastAction,项目名称:lolLeastBot,代码行数:15,代码来源:lol_bot.py

示例6: __init__

# 需要导入模块: from chatterbotapi import ChatterBotFactory [as 别名]
# 或者: from chatterbotapi.ChatterBotFactory import create [as 别名]
    def __init__(self, name, bottype, lang="en", pandoraid=""):
        self.bottypestr=bottype
        if bottype=="cleverbot":
            self.bottype=ChatterBotType.CLEVERBOT
        elif bottype=="jabberwacky":
            self.bottype=ChatterBotType.JABBERWACKY
        elif bottype=="pandorabots":
            self.bottype=ChatterBotType.PANDORABOTS

        factory = ChatterBotFactory()

        self.pandoraid=pandoraid
        self.name=name
        self.session=factory.create(self.bottype,self.pandoraid).create_session()
        self.lang=lang
开发者ID:pawl,项目名称:talking-bots,代码行数:17,代码来源:chatet.py

示例7: SteamEcho

# 需要导入模块: from chatterbotapi import ChatterBotFactory [as 别名]
# 或者: from chatterbotapi.ChatterBotFactory import create [as 别名]
class SteamEcho(Component):
    channel = 'steam'

    def __init__(self, username, password):
        super(SteamEcho, self).__init__()
        self.username = username
        self.password = password

    def started(self, *args):
        self.client = SteamClient().register(self)
        self.client.connect()
        self.friend_bots = {}
        self.factory = ChatterBotFactory()

    @handler('friend_message')
    def _friend_message(self, steamid, chat_entry_type, message):
        if chat_entry_type == EChatEntryType.ChatMsg:
            print('[Incoming Friend Message] ' + message)
            self.stimulate_chatter_bot(steamid, message)

    def stimulate_chatter_bot(self, steamid, message):
        if steamid not in self.friend_bots:
            bot = self.factory.create(ChatterBotType.CLEVERBOT)
            bot_session = bot.create_session()
            self.friend_bots[steamid] = bot_session

        bot_session = self.friend_bots[steamid]
        response = bot_session.think(message)
        self.fire(SendFriendMessage(steamid, EChatEntryType.ChatMsg, response))

    @handler('send_friend_message')
    def _send_friend_message(self, steamid, chat_entry_type, message):
        if chat_entry_type == EChatEntryType.ChatMsg:
            print('[Outgoing Friend Message] ' + message)

    @handler('logged_on')
    def _handle_logged_on(self, steamid):
        self.fire(SetPersonaState(EPersonaState.Online))

    @handler('connected')
    def _handle_connected(self):
        self.client.login(self.username, self.password)

    @handler('friend_request')
    def _handle_friend_request(self, steamid):
        print('[Friend Request] ' + str(steamid))
开发者ID:flowbish,项目名称:steamedrice,代码行数:48,代码来源:example_chatterbot.py

示例8: listener

# 需要导入模块: from chatterbotapi import ChatterBotFactory [as 别名]
# 或者: from chatterbotapi.ChatterBotFactory import create [as 别名]
    pub.publish(String(s))

    
def listener():

    # In ROS, nodes are uniquely named. If two nodes with the same
    # node are launched, the previous one is kicked off. The
    # anonymous=True flag means that rospy will choose a unique
    # name for our 'listener' node so that multiple listeners can
    # run simultaneously.
    rospy.init_node('chat_bot', anonymous=True)

    rospy.Subscriber("speech", String, callback)
    rospy.Publisher('chat_bot/speech', String)

    # spin() simply keeps python from exiting until this node is stopped
    rospy.spin()

if __name__ == '__main__':
    factory = ChatterBotFactory()
    bot = factory.create(ChatterBotType.CLEVERBOT)
    session = bot.create_session()
    pub = rospy.Publisher('chat_bot/speech', String)
    listener()




#bot2 = factory.create(ChatterBotType.PANDORABOTS, 'b0dafd24ee35a477')
#bot2session = bot2.create_session()
开发者ID:Greg8978,项目名称:ros_chat_bot,代码行数:32,代码来源:ros_chatterbotapitest.py

示例9: ChatterBotFactory

# 需要导入模块: from chatterbotapi import ChatterBotFactory [as 别名]
# 或者: from chatterbotapi.ChatterBotFactory import create [as 别名]
import android, time
from chatterbotapi import ChatterBotFactory,ChatterBotType

droid = android.Android()

factory = ChatterBotFactory()

c=1

if (not c):
    print("* PandoraBots selected *")
    bot = factory.create(ChatterBotType.PANDORABOTS, 'b0dafd24ee35a477')
    
elif(c==1):
    print("* JabberWacky selected *")
    bot = factory.create(ChatterBotType.JABBERWACKY)
else:
    print("* Clerverbot selected *")
    bot = factory.create(ChatterBotType.CLEVERBOT)

session = bot.create_session()

readSms = set()

while 1:
 time.sleep(10)
 msgIDs = droid.smsGetMessageIds(True, 'inbox').result
 if msgIDs:
  for msgID in msgIDs:
   if (msgID not in readSms):
    message = droid.smsGetMessageById(msgID, ['address','body']).result
开发者ID:mouuff,项目名称:NotClever,代码行数:33,代码来源:NotClever-SMS-android.py

示例10: getSession

# 需要导入模块: from chatterbotapi import ChatterBotFactory [as 别名]
# 或者: from chatterbotapi.ChatterBotFactory import create [as 别名]
def getSession():
    factory = ChatterBotFactory()
    bot1 = factory.create(ChatterBotType.CLEVERBOT)    
    return bot1.create_session()
开发者ID:alec-heif,项目名称:cleverbot-conversation,代码行数:6,代码来源:api.py

示例11: Copyright

# 需要导入模块: from chatterbotapi import ChatterBotFactory [as 别名]
# 或者: from chatterbotapi.ChatterBotFactory import create [as 别名]
# -*- coding: utf-8 -*-
from chatterbotapi import ChatterBotFactory, ChatterBotType
import sys
"""
    chatterbotapi
    Copyright (C) 2011 [email protected]
"""

factory = ChatterBotFactory()

bot1 = factory.create(ChatterBotType.CLEVERBOT)
bot1session = bot1.create_session()

bot2 = factory.create(ChatterBotType.PANDORABOTS, 'b0dafd24ee35a477')
bot2session = bot2.create_session()

s = sys.argv[1]
s = bot2session.think(s);
print s
开发者ID:ALiJaB157,项目名称:jack-telegram-bot,代码行数:21,代码来源:chatter.py

示例12: __init__

# 需要导入模块: from chatterbotapi import ChatterBotFactory [as 别名]
# 或者: from chatterbotapi.ChatterBotFactory import create [as 别名]
 def __init__(self, bot):
     super(CleverBotPlugin, self).__init__(bot)
     factory = ChatterBotFactory()
     cleverbot = factory.create(ChatterBotType.CLEVERBOT)
     self.bot.brain = cleverbot.create_session()
开发者ID:lauxley,项目名称:StupidBot,代码行数:7,代码来源:cleverircbot.py

示例13: ChatterBotFactory

# 需要导入模块: from chatterbotapi import ChatterBotFactory [as 别名]
# 或者: from chatterbotapi.ChatterBotFactory import create [as 别名]
import sys
import aiml
import speech
import marshal
import chatterbotapi
import wolframalpha

wa = wolframalpha.Client("UPV478-9L6XGWQHPA")
informationPods = 3

usingJarvis = True
informationMode = False

from chatterbotapi import ChatterBotFactory, ChatterBotType
factory = ChatterBotFactory()
cbb = factory.create(ChatterBotType.JABBERWACKY)
cb = cbb.create_session()

k = aiml.Kernel()
#k.learn("std-startup.xml")
#k.respond("LOAD AIML B")
k.loadBrain("jarvis.brn")

k.setBotPredicate("name","Jarvis")

sessionFile = file("jarvis.ses", "rb")
session = marshal.load(sessionFile)
sessionFile.close()

for pred,value in session.items():
    k.setPredicate(pred, value, "jarvis")
开发者ID:hmarron,项目名称:fyp,代码行数:33,代码来源:brain.py

示例14: getAIresponse2

# 需要导入模块: from chatterbotapi import ChatterBotFactory [as 别名]
# 或者: from chatterbotapi.ChatterBotFactory import create [as 别名]
def getAIresponse2(s):
	factory = ChatterBotFactory()
	bot = factory.create(ChatterBotType.CLEVERBOT)
	bot_session = bot.create_session()
	response = bot_session.think(s)
	return response
开发者ID:BeauGieskens,项目名称:rpi_ai,代码行数:8,代码来源:bot_chatter.py

示例15: Txtrbot

# 需要导入模块: from chatterbotapi import ChatterBotFactory [as 别名]
# 或者: from chatterbotapi.ChatterBotFactory import create [as 别名]
class Txtrbot(object):
	def __init__(self, interface):
		super
		self.interface = interface


		mail_usr 	= '[email protected]'
		mail_pw 	= 'lollerskates'

		self.gmail_reader = gmail.GmailReader(mail_usr, mail_pw)

		self.cleverbot_sessions = {}
		self.cleverbot_factory = ChatterBotFactory()

		self.mail_time = 5
		self.flirt_time = 1200

	def OnConnected(self):
		pass

	def OnDisconnected(self):
		pass

	def OnLoggedOn(self):
		pass

	def OnLoggedOff(self):
		pass

	def OnFriendMsg(self, senderID, message):
		pass

	def cleverbot(self, sender, message):
		#print(self.cleverbot_sessions.keys())
		if sender not in self.cleverbot_sessions.keys():
			print("--New cleverbot session--")
			self.cleverbot_sessions[sender] = self.cleverbot_factory.create(ChatterBotType.CLEVERBOT).create_session()
			response = self.cleverbot_sessions[sender].think(message)
			print("Cleverbot: "+response)
			self.interface.sendChatMessage(sender, response)
		else:
			response = self.cleverbot_sessions[sender].think(message)
			print("Cleverbot: "+response)
			self.interface.sendChatMessage(sender, response)

	def checkMail(self):
		if self.mail_time == 0:
			self.mail_time = 5
			print('Checking mail...')
			mails = self.gmail_reader.fetch_unseen()
			for mail in mails:
				self.processMail(mail[0], mail[1])
		else: 
			self.mail_time -= 1

	def processMail(self, mail_from, message):
		message = message.replace('\n-- Sent from Steam using txtrbot. <3', '')

		recepient = command_finder(message, '[*] ')
		if recepient != None:
				for friend in self.interface.friends:
					if friend[0] == recepient:
						recepient = friend[1]
		
				self.interface.sendChatMessage(recepient, 
											   "("+mail_from+")"
											   +message[message.find("] ")+1:])

	def SteamLoop(self):
		self.checkMail()
		#pass
		#self.flirtCountdown()

	# chat call back commands
	def chat_commands(self, sender, message):
		sender_profile_name = str(self.interface.steamFriends.GetFriendPersonaName(sender))

		# chat commands for the bot
		# say hi!
		if message.lower() == 'hi txtrbot':
			self.interface.sendChatMessage(sender, 'hi '+sender_profile_name+" <3")
	
	   	# handle special commands between
	   	# angle brackets
	   	if message.startswith('['):
			try:
				self.bot_kill			(sender, message)
				self.bot_help			(sender, message)
	
				self.bot_message		(sender, message)
				self.bot_email			(sender, message)
	
				self.bot_add_friend		(sender, message)
				self.bot_remove_friend	(sender, message)
			except: pass
		else:
			# cleverbot
			try:
				self.cleverbot 			(sender, message)
			except: pass
#.........这里部分代码省略.........
开发者ID:nuds7,项目名称:text2steam,代码行数:103,代码来源:txtrbot.py


注:本文中的chatterbotapi.ChatterBotFactory.create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。