Esempio n. 1
0
    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)           
Esempio n. 2
0
 def __init__(self, bot):
     if bot.lower() == 'cleverbot':
         self.bot = ChatterBotFactory().create(ChatterBotType.CLEVERBOT).create_session()
     elif bot.lower() == 'jabberwacky':
         self.bot = ChatterBotFactory().create(ChatterBotType.JABBERWACKY).create_session()
     else:
         self.bot = ChatterBotFactory().create(ChatterBotType.PANDORABOTS, 'f6d4afd83e34564d').create_session()
Esempio n. 3
0
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()     
Esempio n. 4
0
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)
Esempio n. 5
0
    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())
Esempio n. 6
0
def call_bot(message):
    """
    Calls bot given message

    Returns response of the bot as a string
    """
    factory = ChatterBotFactory()

    bot = factory.create(ChatterBotType.PANDORABOTS, 'b0dafd24ee35a477')
    botSession = bot.create_session()

    return botSession.think(message)
Esempio n. 7
0
 def __init__(self, botid):
     """
     Initialize global class variables
     Create aiml object with file
     """
     try:
         self._factory = ChatterBotFactory()
         self._bot = self._factory.create(ChatterBotType.PANDORABOTS,
                                          __raspiaibotid__)
         self._botsession = self._bot.create_session()
     except NameError, x:
         print 'Exception: ', x
Esempio n. 8
0
    def __init__(self, interface):
        super
        self.interface = interface

        mail_usr = '******'
        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
Esempio n. 9
0
    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
Esempio n. 10
0
async def on_message(message):
    await bot.process_commands(message)
    if bot.user.mentioned_in(message):
        try:
            if str(message.author) == "Yakitrak#2464":
                factory = ChatterBotFactory()
                bot1 = factory.create(ChatterBotType.PANDORABOTS,
                                      "b0dafd24ee35a477")
                bot1session = bot1.create_session()
                # msg = message.content.split()
                # for word in msg:
                #    if word ==
                # Didn't know what you wanted up there, so I commented it out.
                await message.channel.send(bot1session.think(message.content))
        except:
            await message.channel.send("The Pandorabot api is down "
                                       "so you're seeing this message!")
Esempio n. 11
0
def chat(text):
    from chatterbotapi import ChatterBotFactory, ChatterBotType

    factory = ChatterBotFactory()

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

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

    return bot2session.think(text)
    while (1):

        print 'bot1> ' + s

        s = bot2session.think(s)
        print 'bot2> ' + s

        s = bot1session.think(s)
Esempio n. 12
0
class ChatterBot(object):

    def __init__(self, bot):
        if bot.lower() == 'cleverbot':
            self.bot = ChatterBotFactory().create(ChatterBotType.CLEVERBOT).create_session()
        elif bot.lower() == 'jabberwacky':
            self.bot = ChatterBotFactory().create(ChatterBotType.JABBERWACKY).create_session()
        else:
            self.bot = ChatterBotFactory().create(ChatterBotType.PANDORABOTS, 'f6d4afd83e34564d').create_session()

    def respond_to(self, msg):
        return self.bot.think(msg)
Esempio n. 13
0
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)
Esempio n. 14
0
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)
Esempio n. 15
0
	def __init__(self, interface):
		super
		self.interface = interface


		mail_usr 	= '******'
		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
Esempio n. 16
0
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))
Esempio n. 17
0
class Pandorabot(object):
    """ Description of Pandorabot class raspiai Pandorabot: http://www.pandorabots.com/pandora/talk?botid=f3d034f13e34d592 """
    def __repr__(self):
        if not self:
            return 'Attrs()'
        return '<%s>' % (self.__class__.__name__)

    def __init__(self, botid):
        """
        Initialize global class variables
        Create aiml object with file
        """
        try:
            self._factory = ChatterBotFactory()
            self._bot = self._factory.create(ChatterBotType.PANDORABOTS,
                                             __raspiaibotid__)
            self._botsession = self._bot.create_session()
        except NameError, x:
            print 'Exception: ', x
Esempio n. 18
0
from flask import Flask, request
import json
import requests
from Credentials import *
import os
from chatterbotapi import ChatterBotFactory, ChatterBotType

app = Flask(__name__)

factory = ChatterBotFactory()
bot1 = factory.create(ChatterBotType.PANDORABOTS, MyPandoraBotId)
bot1session = bot1.create_session()


@app.route('/', methods=['GET'])
def handle_verification():
    if request.args.get('hub.verify_token', '') == VERIFY_TOKEN:
        return request.args.get('hub.challenge', '')
    else:
        return 'Error, wrong validation token'


@app.route('/', methods=['POST'])
def handle_messages():
    payload = request.get_data()
    for sender, message in messaging_events(payload):
        msg = bot1session.think(message)
        if len(msg) > 320:
            for j in range(0, (len(msg) / 320), 1):
                if (j + 1) * 320 <= len(msg):
                    send_message(PAGE_ACCESS_TOKEN, sender,
Esempio n. 19
0
class Txtrbot(object):
	def __init__(self, interface):
		super
		self.interface = interface


		mail_usr 	= '******'
		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

	# individual commands
	def bot_kill(self, sender, message):
		sender_profile_name = str(self.interface.steamFriends.GetFriendPersonaName(sender))
		submessage = find_between(message, '[', ']')

		if submessage == 'KILL' or submessage == 'DIE ASSHOLE':
			print 'User "'+sender_profile_name+'" killed txtrbot!'
			self.interface.sendChatMessage(sender, '*shoots robot parts*')
			time.sleep(.5)
			self.interface.destroy(disconnect())
	
	def bot_help(self, sender, message):
		if message.lower() == '[help]':
			self.interface.sendChatMessage(sender, '...\nTo text someone from Steam: [@[email protected]] your message\n'+
												   'To send someone a message from Steam and or your phone: [*friend] your message\n'+
												   "Type [list friends] for a list txtrbot's of friends\n"+
												   'For a list of SMS gateways, visit http://www.emailtextmessages.com/\n')
		# get a list of txtrbot's friends
		if message.lower() == '[list friends]':
			self.interface.sendChatMessage(sender, 'txtrbot has '+str(len(self.interface.friends))+' best friends. '+
												   'They are: \n'+str(self.interface.friends)+'\n')

		if message.lower() == '[#mizzy#]':
			self.interface.sendChatMessage(sender, '...\n[+SteamID+] to add\n'+
												   '[-SteamID-] to remove\n'+
												   'http://steamid.co/')

	
	def bot_message(self, sender, message):
		sender_profile_name = str(self.interface.steamFriends.GetFriendPersonaName(sender))
		recepient = command_finder(message, '[*] ')

		if message[1] == '*':
			for friend in self.interface.friends:
				if friend[0] == recepient:
					recepient = friend[1]

			# error handling and feedback
			if str(SteamID(recepient)) == 'STEAM_0:0:0':
				self.interface.sendChatMessage(sender, 'Invalid friend "'+recepient+'."')
				message_log.write('Message send failed')
			else:
				self.interface.sendChatMessage(sender, 'Sent to '+recepient)
				self.interface.sendChatMessage(recepient, "("+sender_profile_name+") "+
										   	              message[message.find("] ")+1:])
	
	def bot_email(self, sender, message):
		sender_profile_name = str(self.interface.steamFriends.GetFriendPersonaName(sender))
	
		recepient = command_finder(message, '[@] ')
		if message[1] == '@':
	
			email_message = sender_profile_name + ':' + message[message.find("] ")+1:]
			email_message = email_message + '\n-- Sent from Steam using txtrbot. <3'
	
			gmail.send_gmail('*****@*****.**', 
							 'lollerskates', 
							 recepient,
							 email_message)

			self.interface.sendChatMessage(sender, 'Sent to '+recepient)

	def flirtCountdown(self):
		if self.flirt_time == 0:
			self.flirt_time = 1200
			print('Flirting...')
			self.random_flirt()
		else: 
			self.flirt_time -= 1

	def random_flirt(self):
		flirts =   ['Apart from being sexy, what do you do for a living?',
					'So what do you keep doing all day besides looking good?',
					'My parents told me angels arent real... I used to believe them, but then I saw you',
					'I hurt myself real bad while I was falling for you!',
					'I like the way you walk when you walk my way!',
					'Do you believe in love at first sight or should I walk by again?',
					'Hey are you free... for the rest of your life?',
					'Stop thinking about me!',
					'I was a careless girl until I met you!',
					'Listen up! You are under arrest for being that cute!',
					'Stop thinking about me. See, youre doing it... right now',
					'You better have a license, cause you are driving me crazy!',
					'Send me a picture so I can tell Santa my wish list.',
					'Did the sun come out or did you just smile at me?',
					'From A to Z all that really matters is U and I.',
					'Just got out of the shower... Why dont you come over and help me get dirty again?',
					'Come over and take off my lip gloss baby!',
					'I got lost on my way home, can I go home with you?',
					'The hottest thing a guy could wear is the lipstick off of my lips!',
					'I like to study... you!',
					'Tonight ill wear my heels... and nothing else.',
					'It isnt premarital sex if you have no intention of getting married.',
					'If you were an island... could I explore you?',
					'Your dad is one crazy terrorist and you cant deny it... because you are a bomb ;-)',
					'If love is a crime, lock me up, Im guilty',
					'If Santa comes down the chimney this year and tries to stuff you into a sack, dont worry! Thats what Ive wished for this Christmas!',
					'Its gotta be illegal to look this good!',
					"I feel great! And I don't kiss badly either",
					"There's so much to say but your eyes keep interrupting me.",
					"Is it hot in here or is it just you?",
					"If I follow you home, will you keep me?",
					"Please be patient--this is my first time.",
					"BITCH also stands for: Beautiful, Intelligent, Talented, and Charming Human being!"]
		rand_flirt = random.choice(flirts)
		rand_recip = random.choice(self.interface.friends)
		print("Flirting with '"+rand_recip[0]+".'")
		self.interface.sendChatMessage(rand_recip[1], str(rand_flirt))

	def bot_add_friend(self, sender, message):
		sender_profile_name = str(self.interface.steamFriends.GetFriendPersonaName(sender))

		recepient = command_finder(message, '[++]' )
		if message[1] == '+':
			steam_id = SteamID(recepient)
			self.interface.steamFriends.AddFriend(steam_id)
			self.interface.sendChatMessage(sender, 'Adding '+recepient+'.')
	def bot_remove_friend(self, sender, message):
		sender_profile_name = str(self.interface.steamFriends.GetFriendPersonaName(sender))

		recepient = command_finder(message, '[--]')
		if message[1] == '-':
			steam_id = SteamID(recepient)
			self.interface.steamFriends.RemoveFriend(steam_id)
			self.interface.sendChatMessage(sender, 'Remove '+recepient+'.')
Esempio n. 20
0
def getAIresponse2(s):
	factory = ChatterBotFactory()
	bot = factory.create(ChatterBotType.CLEVERBOT)
	bot_session = bot.create_session()
	response = bot_session.think(s)
	return response
Esempio n. 21
0
def getSession():
    factory = ChatterBotFactory()
    bot1 = factory.create(ChatterBotType.CLEVERBOT)    
    return bot1.create_session()
Esempio n. 22
0
    
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.
    
    You should have received a copy of the GNU Lesser General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
"""

factory = ChatterBotFactory()

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

bot2 = factory.create(ChatterBotType.JABBERWACKY)
bot2session = bot2.create_session()


while (1):
    
    s = raw_input()
	
    
    s = bot2session.think(s);
    print 'bot2> ' + s
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
    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()
Esempio n. 25
0
from chatterbotapi import ChatterBotFactory, ChatterBotType
import HTMLParser

h = HTMLParser.HTMLParser()
factory = ChatterBotFactory()

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

bot2 = factory.create(ChatterBotType.PANDORABOTS, "ea373c261e3458c6")
bot2session = bot2.create_session()


def getAnswer(question, engine):
    print("User asked: " + question)
    if engine == "2":
        s = question.encode("utf-8").strip()
        s = bot2session.think(s)
        s = h.unescape(s).encode("utf-8").strip()
    else:
        s = question.encode("utf-8").strip()
        s = bot1session.think(s)
        s = h.unescape(s).encode("utf-8").strip()

    print("Answered: " + s + "; with engine " + str(engine))
    return s
Esempio n. 26
0
 def __init__(self, bot):
     super(CleverBotPlugin, self).__init__(bot)
     factory = ChatterBotFactory()
     cleverbot = factory.create(ChatterBotType.CLEVERBOT)
     self.bot.brain = cleverbot.create_session()
Esempio n. 27
0
def getAIresponse2(s):
    factory = ChatterBotFactory()
    bot2 = factory.create(ChatterBotType.CLEVERBOT)
    bot2session = bot2.create_session()
    response = bot2session.think(s)
    return response
Esempio n. 28
0
# Copyright:   (c) MTJacobson 2014
# Licence:     <your licence
#-------------------------------------------------------------------------------
from __future__ import print_function
import time
import socket #imports module allowing connection to IRC
import threading #imports module allowing timing functions
import random
import sys
sys.path.append('D:\Git\lolLeastBot')
import lol_api
from chatterbotapi import ChatterBotFactory, ChatterBotType
from colorama import init, Fore
init(autoreset=True)

FACTORY = ChatterBotFactory()
bot1 = FACTORY.create(ChatterBotType.JABBERWACKY)
bot1session = bot1.create_session()

#sets variables for connection to twitch chat
#channel = '#leastaction'
server = 'irc.twitch.tv'

#LeastBot
bot_owner = 'LeastBot'
nick = 'LeastBot'
password = open("D:\\Git\\twitchLeastBot\\oauth.txt", "r").readline()

#LeastBot Quality Assurance
BOT_OWNER_2 = 'lbqas'
NICK_2 = 'lbqas'
Esempio n. 29
0
File: brain.py Progetto: hmarron/fyp
import socket
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():
Esempio n. 30
0
 def __init__(self):
     self.factory = ChatterBotFactory()
     self.jabberwacky = self.factory.create(ChatterBotType.JABBERWACKY)
     self.conversations = {}
Esempio n. 31
0
from chatterbotapi import ChatterBotFactory, ChatterBotType
from bot import Bot

factory = ChatterBotFactory()

bot1 = Bot("cleverbot")
bot1sesh = bot1.start_session(bot1)

bot2 = Bot("pandorabots")
bot2sesh = bot2.start_session(bot2)

start = "How are you?"

while (1):
    print 'bot1>' + start
    start = bot2sesh.think(start)
    print 'bot2>' + start
    start = bot1sesh.think(start)
Esempio n. 32
0
 def __init__(self):
     self.factory = ChatterBotFactory()
     self.jabberwacky = self.factory.create(ChatterBotType.JABBERWACKY)
     self.conversations = {}
Esempio n. 33
0
    )).replace("\n", " ") + " Read more: " + strip_tags(HTMLParser().unescape(
        requests.
        get('https://ajax.googleapis.com/ajax/services/search/web?v=1.0&rsz=1&userip=24.53.222.246&q=ftc%20team%20'
            + '%20'.join(x),
            proxies=proxies).json()["responseData"]['results'][0][
                'url'].encode('ascii', 'ignore'))).replace("\n", " ") +
    (" The Yellow Alliance: http://theyellowalliance.net/teams/view/" + x[0],
     "")[not is_number(x[0])],
    "GLRobot":
    lambda x: strip_tags(bot2session.think(' '.join(x)))
}
# Some basic variables used to configure the bot
server = "irc.freenode.net"  # Server
channel = "#GreasedLightning"  # Channel
botnick = "GLRobot"  # Your bots nick
factory = ChatterBotFactory()  #Setup chatterbot
bot2 = factory.create(ChatterBotType.PANDORABOTS, 'b0dafd24ee35a477')
bot2session = bot2.create_session()


def is_number(s):
    try:
        float(s)
        return True
    except ValueError:
        return False


def youtubeDownload(url):
    sendmsg(channel, "Downloading...")
    try:
Esempio n. 34
0
from chatterbotapi import ChatterBotFactory, ChatterBotType
import speech_recognition as sr
import sys
import subprocess
r = sr.Recognizer()
r.energy_threshold = 4000
r.dynamic_energy_threshold = True
factory = ChatterBotFactory()

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

user_input = "Say something to begin..."

print(user_input)

while True:
    with sr.Microphone() as source:
        r.adjust_for_ambient_noise(source)
        audio = r.listen(source, timeout=None)
    try:
        user_input = r.recognize(audio)
        print("User: "******"Could not understand  you")

    s = bot1session.think(user_input)
    subprocess.call('espeak -k20 -s135 -ven-rp+m7 "{0}" 2>/dev/null'.format(s),
                    shell=True)
    print 'James: ' + s
Esempio n. 35
0
# -*- 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
Esempio n. 36
0
				while (thinkstart + ((len(msg) + 1) / 15)) > time.time():
					time.sleep(1)
					print ".",
					sys.stdout.flush()
				print
			
			if LEARN == True:
				LearnAndUpdateTerm(memory, termlst, p)
	except (KeyboardInterrupt, SystemExit, EOFError):
		print "Saving..."
		out.write("END LOG: %s\n" % time.ctime())
		out.close()
		CloseMemory(memory, botname)

if __name__ == '__main__':
	factory = ChatterBotFactory()
	if sys.argv[1] == "clever":
		botname = "daisy_vs_clever"
		f = open(botname + ".log", "a")
		bot1 = factory.create(ChatterBotType.CLEVERBOT)
		bot1session = bot1.create_session()
		chatbot(botname, bot1session, f)
	elif sys.argv[1] == "pandora":
		botname = "daisy_vs_pandora"
		f = open(botname + ".log", "a")
		#bot1 = factory.create(ChatterBotType.PANDORABOTS, 'b0dafd24ee35a477')
		bot1 = factory.create(ChatterBotType.PANDORABOTS, '9fa364f2fe345a10') #mitsuku chatbot from mitsuku.com
		bot1session = bot1.create_session()
		bot1session.pandorabots_url = 'http://fiddle.pandorabots.com/pandora/talk-xml' #mitsuku doesn't work with the normal url
		chatbot(botname, bot1session, f)
	else:
Esempio n. 37
0
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import InvalidElementStateException, StaleElementReferenceException

from chatterbotapi import ChatterBotFactory, ChatterBotType
import time


factory = ChatterBotFactory()
#bot = factory.create(ChatterBotType.CLEVERBOT)
bot = factory.create(ChatterBotType.PANDORABOTS, 'b0dafd24ee35a477')
botsession = bot.create_session()


def checkForStart( browser ):
	try:
		message = ""
		while(message != "You're now chatting with a random stranger. Say hi!"):
			message = browser.find_element_by_css_selector('.statuslog')
			message = message.get_attribute('innerHTML')
		return
	except StaleElementReferenceException:
		checkForStart( browser )


browser = webdriver.Firefox();
browser.get('https://www.omegle.com');

spymodebtn = browser.find_element_by_id('spymodebtn')
spymodebtn.send_keys(Keys.ENTER)
Esempio n. 38
0
import reloader
reloader.enable(blacklist=['inspect','os','pickle','time','re','random','urllib','stripclub','math','udquery','sys','traceback','json','hashlib','irc','irc.bot','irc.client','ircbot','bot','chatterbotapi','socket'])

from irc import strings
from inspect import getmembers, isfunction
from bs4 import BeautifulSoup
import os,pickle,time,re,random,urllib2,urllib,requests,math,udquery,sys,traceback,json,hashlib,socket,datetime
import trpbot_commands
import stripclub
import redis
from irc.client import ip_numstr_to_quad,ip_quad_to_numstr
from Pastebin import PastebinAPI
from irc import bot as ircbot
from fnmatch import fnmatch
from chatterbotapi import ChatterBotFactory, ChatterBotType
cbfactory = ChatterBotFactory()
cbot = cbfactory.create(ChatterBotType.CLEVERBOT)

HOST = 'blacklotus.ca.us.quakenet.org' #'servercentral.il.us.quakenet.org'
PORT = 6667
NICK = 'TRPBot'
CHAN = '#trpbot'
AUTOJOIN = ['#theredpill',]
BOSS = 'tizenwork'
VERSION = '#theredpill bot v1.12'
AUTH = ''
CONFIG = 'config.json'

class TRPBot(ircbot.SingleServerIRCBot):
	def __init__(self,nickname=NICK,server=HOST,port=PORT,channel=CHAN):
		ircbot.SingleServerIRCBot.__init__(self,[(server, port)],nickname,nickname)
Esempio n. 39
0
 def started(self, *args):
     self.client = SteamClient().register(self)
     self.client.connect()
     self.friend_bots = {}
     self.factory = ChatterBotFactory()
Esempio n. 40
0
class Txtrbot(object):
    def __init__(self, interface):
        super
        self.interface = interface

        mail_usr = '******'
        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

    # individual commands

    def bot_kill(self, sender, message):
        sender_profile_name = str(
            self.interface.steamFriends.GetFriendPersonaName(sender))
        submessage = find_between(message, '[', ']')

        if submessage == 'KILL' or submessage == 'DIE ASSHOLE':
            print 'User "' + sender_profile_name + '" killed txtrbot!'
            self.interface.sendChatMessage(sender, '*shoots robot parts*')
            time.sleep(.5)
            self.interface.destroy(disconnect())

    def bot_help(self, sender, message):
        if message.lower() == '[help]':
            self.interface.sendChatMessage(
                sender,
                '...\nTo text someone from Steam: [@[email protected]] your message\n'
                +
                'To send someone a message from Steam and or your phone: [*friend] your message\n'
                + "Type [list friends] for a list txtrbot's of friends\n" +
                'For a list of SMS gateways, visit http://www.emailtextmessages.com/\n'
            )
        # get a list of txtrbot's friends
        if message.lower() == '[list friends]':
            self.interface.sendChatMessage(
                sender, 'txtrbot has ' + str(len(self.interface.friends)) +
                ' best friends. ' + 'They are: \n' +
                str(self.interface.friends) + '\n')

        if message.lower() == '[#mizzy#]':
            self.interface.sendChatMessage(
                sender, '...\n[+SteamID+] to add\n' +
                '[-SteamID-] to remove\n' + 'http://steamid.co/')

    def bot_message(self, sender, message):
        sender_profile_name = str(
            self.interface.steamFriends.GetFriendPersonaName(sender))
        recepient = command_finder(message, '[*] ')

        if message[1] == '*':
            for friend in self.interface.friends:
                if friend[0] == recepient:
                    recepient = friend[1]

            # error handling and feedback
            if str(SteamID(recepient)) == 'STEAM_0:0:0':
                self.interface.sendChatMessage(
                    sender, 'Invalid friend "' + recepient + '."')
                message_log.write('Message send failed')
            else:
                self.interface.sendChatMessage(sender, 'Sent to ' + recepient)
                self.interface.sendChatMessage(
                    recepient, "(" + sender_profile_name + ") " +
                    message[message.find("] ") + 1:])

    def bot_email(self, sender, message):
        sender_profile_name = str(
            self.interface.steamFriends.GetFriendPersonaName(sender))

        recepient = command_finder(message, '[@] ')
        if message[1] == '@':

            email_message = sender_profile_name + ':' + message[
                message.find("] ") + 1:]
            email_message = email_message + '\n-- Sent from Steam using txtrbot. <3'

            gmail.send_gmail('*****@*****.**', 'lollerskates', recepient,
                             email_message)

            self.interface.sendChatMessage(sender, 'Sent to ' + recepient)

    def flirtCountdown(self):
        if self.flirt_time == 0:
            self.flirt_time = 1200
            print('Flirting...')
            self.random_flirt()
        else:
            self.flirt_time -= 1

    def random_flirt(self):
        flirts = [
            'Apart from being sexy, what do you do for a living?',
            'So what do you keep doing all day besides looking good?',
            'My parents told me angels arent real... I used to believe them, but then I saw you',
            'I hurt myself real bad while I was falling for you!',
            'I like the way you walk when you walk my way!',
            'Do you believe in love at first sight or should I walk by again?',
            'Hey are you free... for the rest of your life?',
            'Stop thinking about me!',
            'I was a careless girl until I met you!',
            'Listen up! You are under arrest for being that cute!',
            'Stop thinking about me. See, youre doing it... right now',
            'You better have a license, cause you are driving me crazy!',
            'Send me a picture so I can tell Santa my wish list.',
            'Did the sun come out or did you just smile at me?',
            'From A to Z all that really matters is U and I.',
            'Just got out of the shower... Why dont you come over and help me get dirty again?',
            'Come over and take off my lip gloss baby!',
            'I got lost on my way home, can I go home with you?',
            'The hottest thing a guy could wear is the lipstick off of my lips!',
            'I like to study... you!',
            'Tonight ill wear my heels... and nothing else.',
            'It isnt premarital sex if you have no intention of getting married.',
            'If you were an island... could I explore you?',
            'Your dad is one crazy terrorist and you cant deny it... because you are a bomb ;-)',
            'If love is a crime, lock me up, Im guilty',
            'If Santa comes down the chimney this year and tries to stuff you into a sack, dont worry! Thats what Ive wished for this Christmas!',
            'Its gotta be illegal to look this good!',
            "I feel great! And I don't kiss badly either",
            "There's so much to say but your eyes keep interrupting me.",
            "Is it hot in here or is it just you?",
            "If I follow you home, will you keep me?",
            "Please be patient--this is my first time.",
            "BITCH also stands for: Beautiful, Intelligent, Talented, and Charming Human being!"
        ]
        rand_flirt = random.choice(flirts)
        rand_recip = random.choice(self.interface.friends)
        print("Flirting with '" + rand_recip[0] + ".'")
        self.interface.sendChatMessage(rand_recip[1], str(rand_flirt))

    def bot_add_friend(self, sender, message):
        sender_profile_name = str(
            self.interface.steamFriends.GetFriendPersonaName(sender))

        recepient = command_finder(message, '[++]')
        if message[1] == '+':
            steam_id = SteamID(recepient)
            self.interface.steamFriends.AddFriend(steam_id)
            self.interface.sendChatMessage(sender, 'Adding ' + recepient + '.')

    def bot_remove_friend(self, sender, message):
        sender_profile_name = str(
            self.interface.steamFriends.GetFriendPersonaName(sender))

        recepient = command_finder(message, '[--]')
        if message[1] == '-':
            steam_id = SteamID(recepient)
            self.interface.steamFriends.RemoveFriend(steam_id)
            self.interface.sendChatMessage(sender, 'Remove ' + recepient + '.')