Exemplo n.º 1
0
    def createBot(self):
        #If there's an existing bot (i.e. /reload was ran) we'll kill the old one first
        if self.omegleBot != None:
            self.omegleBot.kill()
            self.client.disconnect()
            self.form.display()

        #Open the setup.json and load it
        try:
            with open('setup.json') as json_data:
                clientdata = json.load(json_data)

        #If no file exists, defaults are hardcoded so it doesn't break everything
        except (OSError, IOError):
            #Defaults
            clientdata = {}
            clientdata["startLine"] = ""
            clientdata["topics"] = []
            clientdata["shortcuts"] = {}

            #Warn user
            self.updateChat(
                "You have not created a setup.json file. Checkout the example version as this allows for topics & an optional automatic message. TUIMegle will continue with default settings in 5 seconds."
            )
            time.sleep(5)

        #Get the startline (or set to None)
        if clientdata["startLine"] == "":
            startline = None
        else:
            startline = clientdata["startLine"]

        #Shortcut-list
        self.shortcuts = clientdata["shortcuts"]

        #Reading from new setup
        self.omegleBot = OmegleBot(self.form, True, startline)

        #Creating client with topics from file
        self.form.Chat.entry_widget.buffer(["Connecting..."],
                                           scroll_if_editing=True)
        self.form.display()

        self.client = OmegleClient(self.omegleBot,
                                   wpm=42,
                                   lang='en',
                                   topics=clientdata["topics"])
        self.client.start()
Exemplo n.º 2
0
             'friendship',
             'family',
             'sadness',
             'read',
             'minecraft',
             'fortnite',
             'book',
             'music',
             'technology',
             'chill',
             'song',
             'songs',
             'singing']

h = OmegleHandler(loop=True)            # session loop
c = OmegleClient(h, wpm=30, lang='en', topics=interests)  # 30 words per minute
c.start()

'''
while 1:
    input_str = raw_input('')           # string input

    if input_str.strip() == '/next':
        c.next()                        # new conversation
    elif input_str.strip() == '/exit':
        c.disconnect()                  # disconnect chat session
        break
    else:
        c.send(input_str)               # send string
'''
Exemplo n.º 3
0
from pyomegle import OmegleClient, OmegleHandler

"""
    Omegle inteface for python

    /next
        starts a new conversation
    /exit
        exits chat session
"""

h = OmegleHandler(loop=True)            # session loop
c = OmegleClient(h, wpm=60, lang='en', topics=['lesbian', 'lesbians', 'les', 'lesbo'])  # 60 words per minute
c.start()

while 1:
    input_str = input('')           # string input

    if input_str.strip() == '/next':
        c.next()                        # new conversation
    elif input_str.strip() == '/exit':
        c.disconnect()                  # disconnect chat session
        break
    else:
        c.send("hi")               # send string
Exemplo n.º 4
0
                cc.disconnect()
                t.send('You have disconnected.')
            elif answer == '/auto':
                t.send('Auto mode: ON')
                checkpoint.autoMode = True
            elif answer == '/manual':
                t.send('Auto mode: OFF')
                checkpoint.autoMode = False
            else:
                cc.send(answer)
        time.sleep(0.5)


# Setting up Omegle Client
h = CustomHandler(checkpoint, loop=True)
client = OmegleClient(h, wpm=600, lang='it')  # COMMENTO PER LA LINGUA
cc = CustomClient(client, checkpoint)

h.cc = cc

# Starting Telegram bot
t = Telegram()
thread = threading.Thread(target=getUpdates)
thread.start()

# Checks for any input from the PC's keyboard
# /next = starts a new conversation
# /stop = stops automatically starting new conversations
# /exit = disconnects from current stranger and doesn't start a new conversation
while True:
    inputStr = input('')
Exemplo n.º 5
0
from pyomegle import OmegleClient, OmegleHandler
"""
    Omegle inteface for python

    /next
        starts a new conversation
    /exit
        exits chat session
"""

h = OmegleHandler(loop=True)  # session loop
c = OmegleClient(h,
                 wpm=47,
                 lang='en',
                 topics=[
                     "politics", "political", "communism", "communist",
                     "trump", "maga"
                 ])  # 47 words per minute
c.start()

while 1:
    input_str = raw_input('')  # string input

    if input_str.strip() == '/next':
        c.next()  # new conversation
    elif input_str.strip() == '/exit':
        c.disconnect()  # disconnect chat session
        break
    else:
        c.send(input_str)  # send string
Exemplo n.º 6
0
from pyomegle import OmegleClient
from pyomegle import OmegleHandler
import time

h = OmegleHandler(loop=True)
c = OmegleClient(h, wpm=47, lang="de", topics=[("TOPICS YOUR INTERESTED IN")])

c.start()

input_str = "YOUR TEXT"
input_str2 = "YOUR TEXT"

while 1:
    time.sleep(5)
    c.send(input_str)
    time.sleep(1)
    c.send(input_str2)
    time.sleep(7)
    c.next()
Exemplo n.º 7
0
class omegleApplication(npyscreen.NPSAppManaged):
    def onStart(self):
        #Create form
        self.form = self.addForm('MAIN', omegleForm, name='Omegle')

        #Pre-creation of bot
        self.form.Chat.entry_widget.buffer(["Creating OmegleBot..."],
                                           scroll_if_editing=True)
        self.omegleBot = None
        self.client = None

        #Set it up
        self.createBot()

    def createBot(self):
        #If there's an existing bot (i.e. /reload was ran) we'll kill the old one first
        if self.omegleBot != None:
            self.omegleBot.kill()
            self.client.disconnect()
            self.form.display()

        #Open the setup.json and load it
        try:
            with open('setup.json') as json_data:
                clientdata = json.load(json_data)

        #If no file exists, defaults are hardcoded so it doesn't break everything
        except (OSError, IOError):
            #Defaults
            clientdata = {}
            clientdata["startLine"] = ""
            clientdata["topics"] = []
            clientdata["shortcuts"] = {}

            #Warn user
            self.updateChat(
                "You have not created a setup.json file. Checkout the example version as this allows for topics & an optional automatic message. TUIMegle will continue with default settings in 5 seconds."
            )
            time.sleep(5)

        #Get the startline (or set to None)
        if clientdata["startLine"] == "":
            startline = None
        else:
            startline = clientdata["startLine"]

        #Shortcut-list
        self.shortcuts = clientdata["shortcuts"]

        #Reading from new setup
        self.omegleBot = OmegleBot(self.form, True, startline)

        #Creating client with topics from file
        self.form.Chat.entry_widget.buffer(["Connecting..."],
                                           scroll_if_editing=True)
        self.form.display()

        self.client = OmegleClient(self.omegleBot,
                                   wpm=42,
                                   lang='en',
                                   topics=clientdata["topics"])
        self.client.start()

    #Acts as a command handler
    def onNewMessage(self, message):
        #If this manages to get sent with nothing, nothing will happen
        if message.strip() == "":
            pass

        #This is a command (done so typos of commands don't send in embarassing fashion)
        elif message.strip().startswith("/"):
            #This command (/next) will move onto a new conversation
            if message.strip() == "/next":
                self.client.next()

            #Stops the application
            elif message.strip() == "/exit":
                self.omegleBot.kill()
                self.form.chat = []
                self.client.disconnect()

                self.form.Chat.entry_widget.buffer(["Exiting... Bye!"],
                                                   scroll_if_editing=True)
                self.form.display()
                time.sleep(3)
                exit(0)

            #Recreates the bot - allowing you to update the setup.json
            elif message.strip() == "/reload":
                self.createBot()

            elif message.strip().startswith("/sc"):
                #Get everything after first space
                shortcutname = message.strip().split(" ", 1)[1]

                #Send shortcut
                self.shortcutSend(shortcutname)

            elif message.strip() == "/disp":
                #Forces a full display refresh - good in case messages have hung without displaying for some reason?
                self.form.DISPLAY()

            else:
                #Handles as if it's a shortcut
                self.shortcutSend(message.strip()[1:])
        #Anything else will be sent as a message
        else:
            #Send the message & stop typing
            self.client.send(message.strip())
            self.client.stopped_typing()

            #Add to the chat
            outstring = "You: " + message.strip()
            self.updateChat(outstring)

    #This will use the form's
    def updateChat(self, outstring):
        #Upper line length
        lengthcap = self.form.Chat.width - 8

        #Cut the string into chunks of lengthcap if needed
        if len(outstring) > lengthcap:
            self.form.Chat.entry_widget.buffer([
                outstring[i:i + lengthcap]
                for i in range(0, len(outstring), lengthcap)
            ],
                                               scroll_if_editing=True)
        else:
            self.form.Chat.entry_widget.buffer([outstring],
                                               scroll_if_editing=True)

    def shortcutSend(self, shortcut):
        #Check we're good
        if shortcut == None or shortcut == "":
            return

        #Attempt to get the message to send
        try:
            messagesToSend = self.shortcuts[shortcut]
        except KeyError:
            #Do nothing if there isn't one found
            return

        #If we manage to get to this point despite there not being a message, we'll just exit
        if messagesToSend == None or len(messagesToSend) == 0:
            return

        #Send each message
        for messageToSend in messagesToSend:
            self.client.send(messageToSend)

            outstring = "You: " + messageToSend
            self.updateChat(outstring)

    def userIsTyping(self):
        #Checks the value of the textbox to see if the user is typing
        #NOTE: Seems always return false?
        if self.form.Message.value != "":
            self.client.typing()
        else:
            self.client.stopped_typing()
Exemplo n.º 8
0
from pyomegle import OmegleHandler, OmegleClient

unreadMessages = []
oHandler = OmegleHandler(unreadMessages, loop=True)
oClient = OmegleClient(oHandler, wpm=47, lang='en')


def build_speechlet_response(title, output, reprompt_text, should_end_session):
    return {
        'version': "1.0",
        'response': {
            'outputSpeech': {
                'type': 'PlainText',
                'text': output
            }
        },
        'card': {
            'type': 'Simple',
            'title': "SessionSpeechlet - " + title,
            'content': "SessionSpeechlet - " + output
        },
        'reprompt': {
            'outputSpeech': {
                'type': 'PlainText',
                'text': reprompt_text
            }
        },
        'shouldEndSession': should_end_session
    }