Skip to main content

Pymegle

Pymegle is an unofficial API for Omegle's text chat using asyncio. It provides an interface for connecting to text chats and asynchronous event handling. This package also comes bundled with a full-featured user client that can be run in the console.

DISCLAIMER: This software is not intended to be used for spam or other disruptive/malicious activities. Please abide by Omegle's terms of service.

Installation

Pymegle can be installed from PyPi using the following command:

pip install pymegle

Starting Out

The simplest usage of this package is interacting with the user client. It can be run using the following code.

NOTE: Many consoles were not designed with asynchronous operation in mind and as a result may experience issues when running the interactive client. PyCharm's Python Console and the Windows command prompt tend to perform the best.

import pymegle

pymegle.run_user_clent()

The user client recreates the Omegle browser experience in the console, showcasing what can be done with this API.

Basic Usage

The OmegleChat class is the basic handler for text chat interactions. It represents a single chat between the client (user) and a partner. It can be inherited to handle various events, such as receiving messages.

For this example, we will make a simple dice roller that responds to a command given by the partner and sends a result.

import pymegle
import random

class DiceRoller(pymegle.OmegleChat):
  def __init__(self, **kwargs):
    super().__init__(**kwargs)
    
    # Automatically add 'diceroller' to the chat request's interests
    self.interests.add("diceroller")
   
  # This coroutine is called when the client successfully connects to a partner
  async def on_connected(self, i):
    # Send a greeting message
    await self.send_message("Hello! Type /roll and I will roll a 6 sided die for you")
  
  # This coroutine is called when the partner sends a message
  async def on_message(self, m):
    # Check if the message matches the specified command
    if m == "/roll":
      await self.send_message("🎲 Rolling...")
      await self.type_message(f"Result: {random.randrange(1, 7)}")

The above chat can then be run by doing:

chat = DiceRoller()
chat.start()

Then, connect to Omegle with diceroller in the interests to test it.

The chat class can be wrapped in an OmegleClient to provide more functionality, namely the ability to automatically begin a new chat when the current one is finished.

class MyClient(pymegle.OmegleClient):
  # This is called when a chat ends
  def on_chat_end(self, log):
    # Returning True tells the client to start a new chat
    return True

client = MyClient(DiceRoller)
client.start()

Release files for pymegle 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pymegle 0.0.2
File Size Uploaded
pymegle-0.0.2.tar.gz 9.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pymegle 0.0.2
File Interpreter ABI Platform
pymegle-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 19.7 kB

Release files / pymegle-0.0.2.tar.gz

Download URL pymegle-0.0.2.tar.gz
Size 9.9 kB
Tags Source
SHA-256 checksum
How to use checksums
7b9ff652d66d3225cbabe9d7a64691bf1f5a5e307d21ce360f70ab22e3c90d83
BLAKE2b-256 checksum
How to use checksums
bfb764687b841a44ed47a75a038235dffc1bfa757fccc273859a402e841955a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.7

Release files / pymegle-0.0.2-py3-none-any.whl

Download URL pymegle-0.0.2-py3-none-any.whl
Size 9.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
96ce65368fd48892861a835294c29541808b285f2c60a65bd4737f2b98e9ad9f
BLAKE2b-256 checksum
How to use checksums
3b4ef8b8ef21a678118b381b2e174fe16efd25cb470ede81f320a003ba6f6113
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.7

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page