Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Hello reddit. I reverse engineered the Omegle protocol from the android app. I didn't have time to make a detailed writing, I will be busy in the following weeks. I made an event-based API in Python. You can use it to make clients or bots or whatever. But let's not make bots, there are lots of annoying bots in Omegle already.
import requests
import random
import time
class OmegleClient(object):
def __init__(self):
self.isDisconnected = False
def connect(self):
self.server = "http://front{}.omegle.com/".format(random.randint(1, 8))
shard_request = requests.post("{}/start".format(self.server), data={"rcs": 1})
self.shard_id = shard_request.json()
def process_events(self):
while not self.isDisconnected:
events_request = requests.post("{}/events".format(self.server), data={"id": self.shard_id})
events = events_request.json()
for event in events:
if event[0] == "waiting":
yield {"name": "waiting"}
elif event[0] == "connected":
yield {"name": "connected"}
elif event[0] == "statusInfo":
yield {"name": "omegleInfo", "online": event[1]["count"]}
elif event[0] == "gotMessage":
yield {"name": "message", "message": event[1]}
elif event[0] == "strangerDisconnected":
self.isDisconnected = True
yield {"name": "disconnected"}
else:
yield {"name": event[0], "event": event}
time.sleep(4)
def send_message(self, message):
requests.post("{}/send".format(self.server), data={"id": self.shard_id, "msg": message})
def disconnect(self):
requests.post("{}/disconnect".format(self.server), data={"id": self.shard_id})
self.isDisconnected = True
if __name__ == "__main__":
client = OmegleClient()
client.connect()
for event in client.process_events():
if event["name"] == "connected":
print "We are connected. Saying hi!"
client.send_message("Hi there!")
elif event["name"] == "message":
print "The stranger says: %s" % event["message"]
elif event["name"] == "omegleInfo":
print "There are %s people in Omegle right now." % event["online"]
elif event["name"] == "disconnected":
print "Dammit! The stranger left :("
@CoolOppo

This comment has been minimized.

Copy link

commented Jan 4, 2015

Anybody interested in this should take a look here as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.