From anonymous, 8 Years ago, written in PHP.
This paste is a reply to Omegle o.o from Aha2Y
- go back
Viewing differences between Omegle o.o and Re: Omegle o.o
# - requests (

import requests
import sys
import json
import urllib
import random
import time

server = ""

debug_log = open("debug.log","a")        # Set to FALSE to disable excessive messages
config = {'verbose': open("/dev/null","w")}
headers = {}
headers['Referer'] = ''
headers['Connection'] = 'keep-alive'
headers['User-Agent'] = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.2 (KHTML, like Gecko) Ubuntu/11.10 Chromium/15.0.874.106 Chrome/15.0.874.106 Safari/535.2'
headers['Content-type'] = 'application/x-www-form-urlencoded; charset=UTF-8'
headers['Accept'] = 'application/json'
headers['Accept-Encoding'] = 'gzip,deflate,sdch'
headers['Accept-Language'] = 'en-US'
headers['Accept-Charset'] = 'ISO-8859-1,utf-8;q=0.7,*;q=0.3'

if debug_log:
    config['verbose'] = debug_log

def debug(msg):
    if debug_log:
        print "DEBUG: " + str(msg)
        debug_log.write(str(msg) + "\n")

def getcookies():
    r = requests.get("http://" + server + "/",config=config)
    return r.cookies

def start():
    r = requests.request("POST", "http://" + server + "/start?rcs=1&spid=", data="rcs=1&spid=", config=config, headers=headers)
    omegle_id = r.content.strip("\"")
    debug("Got ID: " + str(omegle_id))
    cookies = getcookies()
    event(omegle_id, cookies)

def send(omegle_id, cookies, msg):
    r = requests.request("POST","http://" + server + "/send", data="msg=" + urllib.quote_plus(msg) + "&id=" + omegle_id, config=config, headers=headers, cookies=cookies)
    if r.content == "win":
        print "You: " + msg
        print "Error sending message, check the log"

def event(omegle_id, cookies):
    captcha = False
    next = False
    r = requests.request("POST","http://" + server + "/events",data="id=" + omegle_id, cookies=cookies, config=config, headers=headers)
        parsed = json.loads(r.content)
        for e in parsed:
            if e[0] == "waiting":
                print "Waiting for a connection..."
            elif e[0] == "count":
                print "There are " + str(e[1]) + " people connected to Omegle"
            elif e[0] == "connected":
                print "Connection established!"
                send(omegle_id, cookies, "dicks")
            elif e[0] == "typing":
                print "Stranger is typing..."
            elif e[0] == "stoppedTyping":
                print "Stranger stopped typing"
            elif e[0] == "gotMessage":
                print "Stranger: " + e[1]
                    send(omegle_id, cookies, "What do you mean?")
                    debug("Send errors!")
            elif e[0] == "strangerDisconnected":
                print "Stranger Disconnected"
                next = True
            elif e[0] == "suggestSpyee":
                print "Omegle thinks you should be a spy. Fuck omegle."
            elif e[0] == "recaptchaRequired":
                print "Omegle think's you're a bot (now where would it get a silly idea like that?). Fuckin omegle. Recaptcha code: " + e[1]
                captcha = True
                print "Some shit is fucked up. Stay tuned for debugging information:"
                print json.dumps(parsed)
        print "Derka derka derka"
    if next:
        print "Reconnecting..."
    elif not captcha:
        event(omegle_id, cookies)