Git Product home page Git Product logo

pyomegle's Introduction

Pyomegle

Python API for Omegle webchat. Compatible with Python3.

Installation

$ pip install pyomegle

Usage

from pyomegle import OmegleClient, OmegleHandler

"""
    Omegle interface for python

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

h = OmegleHandler(loop=True)            # session loop
c = OmegleClient(h, wpm=47, lang='en')  # 47 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(input_str)               # send string

Events

List of events accessible by OmegleHandler. Note that OmegleHandler uses a loop optional parameter, valid for start a new chat when a stranger disconnects.

  • waiting() Called when we are waiting for a stranger to connect
  • connected() Called when we are connected with a stranger
  • typing() Called when the user is typing a message
  • stopped_typing() Called when the user stop typing a message
  • message(message) Called when a message is received from the connected stranger
  • common_likes(likes) Called when you and stranger likes the same thing
  • disconnected() Called when a stranger disconnects
  • captcha_required() Called when the server asks for captcha
  • captcha_rejected() Called when server reject captcha
  • server_message(message) Called when the server report a message
  • status_info(status) Status info received from server
  • ident_digest(digests) Identity digest received from server

Inherit OmegleHandler class for implement your custom events.

class MyCustomHandler(OmegleHandler):

    def connected(self):
        super(MyCustomHandler, self).connected()

        self.omegle.send('Hi!')

Client

OmegleClient uses some optional initial parameters, the most useful are

  • lang='en' set the default chat language
  • wpm=42 set the words per minutes typing speed
  • topics=[] list of interests
  • event_delay=3 server polling delay in seconds

List of client methods

  • start() Start a new conversation
  • status() Return connection status
  • write(message) Simulates a message completely written with typing time
  • typing() Emulates typing in the conversation
  • stopped_typing() Emulates stopped typing into the conversation
  • send(message) Sends a message
  • recaptcha(challenge, response) Captcha validation
  • next() Starts with a new conversation
  • disconnect() Disconnect from the current conversation

License

pyomegle is released under the MIT License.

pyomegle's People

Contributors

danny-burrows avatar elias94 avatar eliascotto avatar ikoide avatar onsagere avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.