Skip to main content

botafar Code style: black

Add global remote controls and a real time livestream to your projects

  • Share a link and let others take the controls one by one
  • Forward the livestream to Twitch or YouTube (optional)
  • No hardware required, a phone can be used as a camera
  • Arduino and Raspberry Pi tutorials available
  • Desktop and mobile browser support, no apps, no signups

It works by decorating existing functions and class methods to respond to user input:

import botafar

j = botafar.Joystick("W","A","S","D")

@j.on_left
def turn_left():
    print("left!")

@j.on_right
def turn_right():
    print("right!")

# ...@j.on_up, on_down, on_center

botafar.run()

result

Check botafar.com for currently online bots!

Get started

Starting scenario

Let's suppose you have a Python project, main.py, where you have defined two functions greet and target:

def greet():
    print("hello")

def target():
    print("world")

greet()
target()

When you run main.py it calls those functions, and prints "hello" and "world" to the terminal:

$ python main.py
hello
world

You want be able to share a link through which people can remotely call these functions on your hardware, and see the results in real life through a low-latency livestream (and optionally, on Twitch or YouTube as well).

botafar enables you to do all these things.

Add remote controls and livestreaming

  1. Install the library (help)
pip install --upgrade botafar

On some Debian based operating systems such as Raspberry Pi OS, on you need to have libSRTP and other related network dependencies installed to be installed as well: sudo apt install libnss3 libnspr4 libsrtp2-1 -y

  1. Modify main.py:
  • Import botafar
  • Create a control, Joystick in this example, and bind 4 keys from keyboard to it
  • Use decorators (@-symbol) to select functions to call on user input
  • Call botafar.run()
import botafar

j = botafar.Joystick("W","A","S","D")

@j.on_left
def greet():
    print("hello")

@j.on_right
def target():
    print("world")

botafar.run()
  1. Execute the main.py file, and open the returned link in browser. Note that this browser can be on other device, for example the Python program can run on a Raspberry Pi and the browser setup is done on a desktop PC's browser (help).
$ python main.py

Bot running, connect at https://botafar.com/abcde-fghij-klmno
  1. From the browser, press the Try controls -button. Now when you press A and D keys from a keyboard or a touch screen, texts "hello" and "world" get printed on terminal.
$ python main.py

Bot running, connect at https://botafar.com/abcde-fghij-klmno
hello
world
hello
world
  1. Choose a stream source from the browser. It can be a webcam, a phone or a screen share (help).

  2. Give your bot a name and switch it to public

  3. The browser now shows a direct link to your bot you can share with anyone in the world! Others can press keyboard or touch screen to print "hello" and "world" to the terminal, and see the prints through a low-latency livestream.

If you got stuck, have an idea or you found a bug, write about it on the GitHub discussions forum. This tool is still under development, and all feedback is appreciated.

Keep reading if you want to learn how to:

Release files for botafar 0.0.10

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

Source distribution (sdist)

Source distribution for botafar 0.0.10
File Size Uploaded
botafar-0.0.10.tar.gz 63.7 kB Details

Built distribution (wheel)

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

Total release size: 107.7 kB

Release files / botafar-0.0.10.tar.gz

Download URL botafar-0.0.10.tar.gz
Size 63.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d920bbd85c172888c4473294e0e1405141e80c6ae26f06455e961f8514768036
BLAKE2b-256 checksum
How to use checksums
100f4fd7983b5dbb5aec7ddf463e0c7d2e7b422318c429a2dd9f9f562f4e2040
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.28.1

Release files / botafar-0.0.10-py3-none-any.whl

Download URL botafar-0.0.10-py3-none-any.whl
Size 44.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5e98bf6875e061d2d90fb93b4c3a1c4599ecbe6619595d1672fd8c25c88ba31a
BLAKE2b-256 checksum
How to use checksums
ad6f0d6dec53c3f891c35d05ac99d5467634852f71ce97dd49e6160890f471da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.28.1

Release history Release notifications | RSS feed

This release

0.0.10 This release

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

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