Example #1
0
def listenServer(id, req):
    while True:

        site = url.urlopen(req)

        #We read the HTTP output to get what's going on
        rec = site.read()

        #print rec

        if 'strangerDisconnected' in rec:
            print('He is gone')
            #We start the whole process again
            new_log.write('--Disconnected--')
            new_log.close()
            omegleConnect()

        elif 'waiting' in rec:
            print("Waiting...")

        elif 'connected' in rec:
            print('Found one')
            print(id)
            cleverbot.Session()

        elif 'typing' in rec:
            print("He's typing something...")

        #When we receive a message, print it and execute the talk function
        elif 'gotMessage' in rec:
            reply = (rec[16:len(rec) - 2])
            new_log.write('Stranger: ' + reply + '\n')
            print 'Stranger: ', reply
            talk(id, req, reply)
Example #2
0
 def __init__(self, skype, user):
     self.s = skype
     self.user = user
     self.cb = cleverbot.Session()
     self.currentMsgDatetime = self.getCurrentMessageDatetime()
     self.currentMsg = self.getCurrentMessageBody()
     self.msg = ''
Example #3
0
 def on_robot_clicked(self, widget):
     self.set_active_button(False, False)
     self.controller.cb = cleverbot.Session()
     global bot
     bot = True
     self.on_clear()
     self.print_text("info", "Le test commence, c'est le robot qui joue")
     self.controller.socket.send("++++reload_ok++++")
Example #4
0
def cb(ask, nick):
    """Asks cleverbot a question, and logs
    and says the response (broken).
    
    Cleverbot API has been discontinued
    and so this will probably no longer work.
    """
    if config.get('cleverbot'):
        cbot = cleverbot.Session()
        response = cbot.Ask(" ".join(ask))
        ACTION_LOG.info(Fore.CYAN + "CBT" + Fore.RESET + " " + response)
        c.say(nick + ": " + response)
    else:
        c.msg("Cleverbot is currently disabled.", nick)
Example #5
0
def talk(id, req, reply):

    #Show the server that we're typing
    typing = url.urlopen('http://omegle.com/typing', '&id=' + id)
    typing.close()

    #Show the user that we can write now
    msg = str(cleverbot.Session().Ask(reply))
    new_log.write('Cleverbot: "' + msg + '"\n')
    print 'Cleverbot: "' + msg + '"'

    #Send the string to the stranger ID
    msgReq = url.urlopen('http://omegle.com/send', '&msg=' + msg + '&id=' + id)

    #Close the connection
    msgReq.close()
Example #6
0
def OnMessageStatus(Message, Status):
    if Status == 'RECEIVED':
        body = Message.Body
        from_handle = Message.FromHandle
        try:
            if not str(from_handle) in ignoreList:
                if not str(from_handle) in chats:
                    mycb = cleverbot.Session()
                    chats[str(from_handle)] = mycb

                msgSend = chats[str(from_handle)].Ask(body)
                chat = skype.CreateChatWith(from_handle)
                chat.SendMessage(msgSend)

                message = "Event ==> Message = {0} from {1} || Action ==> Send = {2}".format(
                    body.encode('ascii', 'ignore'), from_handle, msgSend)
                print message
        except Exception, e:
            print e
Example #7
0
import cleverbot
import subprocess

teacher = cleverbot.Session()
bot = raw_input('enter bot to grant intelligence: ')
time = int(raw_input('lesson repititions: '))
import pickle, random
lexicon = 'lexicon-' + bot
a = open(lexicon, 'rb')
successorlist = pickle.load(a)
a.close()


def nextword(a):
    if a in successorlist:
        return random.choice(successorlist[a])
    else:
        return 'the'


speech = ''
wisdom = ''
conversation = ''
response = 'Hello'
while speech != 'quit':
    speech = teacher.Ask(response)
    s = random.choice(speech.split())
    response = ''
    while True:
        neword = nextword(s)
        response += ' ' + neword
Example #8
0
import cleverbot
import subprocess

cbOne = cleverbot.Session()
cbTwo = cleverbot.Session()
x = cbOne.Ask('Hello')
y = cbTwo.Ask(x)
while True:
    print 'cb1: ', x
    subprocess.call('espeak -s 160 -p 30 -k20 -v en ' + '"' + x + '"',
                    shell=True)
    x = cbOne.Ask(y)
    print 'cb2: ', y
    subprocess.call('espeak -s 160 -p 60 -k20 -v en ' + '"' + y + '"',
                    shell=True)
    y = cbTwo.Ask(x)
Example #9
0
# coding=utf-8
import cleverbot
import formating

cb1 = cleverbot.Session()
cb2 = cleverbot.Session()

r1 = cb1.Ask("Salut")
print "cb1 : Salut"

while True:
    r2 = formating.from_bot(cb2.Ask(formating.to_bot(r1)))
    print "cb2 : {0}".format(r2)
    r1 = formating.from_bot(cb1.Ask(formating.to_bot(r2)))
    print "cb1 : {0}".format(r1)
Example #10
0
More info:
 * jenni: https://github.com/myano/jenni/
 * Phenny: http://inamidst.com/phenny/
"""


import cleverbot
from htmlentitydefs import name2codepoint
import json
from modules import unicode as uc
import random
import re
import time

mycb = cleverbot.Session()

nowords = ['reload', 'help', 'tell', 'ask']

r_entity = re.compile(r'&[A-Za-z0-9#]+;')
HTML_ENTITIES = { 'apos': "'" }

random.seed()


def chat(jenni, input):
    txt = input.groups()
    if len(txt) > 0:
        text = txt[1]
        if txt[1].startswith('\x03') or txt[1].startswith('\x01'):
            ## block out /ctcp
Example #11
0
import cleverbot

# beginning two different cleverbot sessions
# I use steve and bob to keep things separate while coding.
# This is not reflected in the html output.
steve = cleverbot.Session()
bob = cleverbot.Session()

# Gathering info....boring stuff
convo_start = raw_input("How would you like to begin the conversation? : ")
print ""
cycles = int(raw_input("How many cycles would you like to run? : "))
print ""

# Starting the conversation
print "Bob: " + convo_start
reply = steve.Ask(convo_start)
print "Steve: " + reply

i = 0

# continuing the conversation in the loop.
while (i <=
       cycles):  # you will have to edit the less than symbol on this line.
    reply = bob.Ask(reply)
    print "Bob: " + reply

    reply = steve.Ask(reply)
    print "Steve: " + reply

    i = i + 1
Example #12
0
            last_id_replied = id.strip()
            print "[+] Read last_reply_id", last_id_replied
        except IOError:
            print "[!] Could not read ", last_file
    else:
        print "[!] Didn't find ~/.twitter_last_reply file.. starting fresh prince"

    #twitter client to post. Posting requires oAuth schutff
    pbird = Twitter(auth=OAuth(oa_token, oa_token_secret, CONSUMER_KEY,
                               CONSUMER_SECRET),
                    secure=True,
                    api_version='1',
                    domain="api.twitter.com")

    #our cleverbot instance
    cbot = cleverbot.Session()

    #main loop. Just keep searching anyone talking to us
    while True:
        try:
            mentions = sbird.search(q='@SpeakingSecret',
                                    since_id=last_id_replied)['results']
            if not mentions:
                print "No one talking to us now...", time.ctime()

            for mention in mentions:
                #cut our @SpeakingSecret out
                message = mention['text'].replace('@SpeakingSecret', '')
                speaker = mention['from_user']
                speaker_id = str(mention['id'])
Example #13
0
 def __init__(self):
     self.speak = False
     self.conversation = False
     self.PiAI = cleverbot.Session()