{"id":18217256,"url":"https://github.com/davidemodolo/orangepi_bot_server","last_synced_at":"2025-04-10T11:51:37.752Z","repository":{"id":259251586,"uuid":"877407228","full_name":"davidemodolo/orangepi_bot_server","owner":"davidemodolo","description":"Host Telegram, Discord and Twitch bots on Orange Pi","archived":false,"fork":false,"pushed_at":"2024-11-06T10:23:19.000Z","size":806,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-06T21:18:28.614Z","etag":null,"topics":["bot","discord-bot","orange-pi","python","raspberry-pi","raspbian-os","telegram-bot","twitch-bot"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/davidemodolo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-23T15:41:34.000Z","updated_at":"2024-11-06T10:23:23.000Z","dependencies_parsed_at":"2024-10-30T22:45:31.824Z","dependency_job_id":"e9a8fc59-1ac6-4732-a6cc-94e23e442d8f","html_url":"https://github.com/davidemodolo/orangepi_bot_server","commit_stats":null,"previous_names":["davidemodolo/orangepi_bot_server"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidemodolo%2Forangepi_bot_server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidemodolo%2Forangepi_bot_server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidemodolo%2Forangepi_bot_server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidemodolo%2Forangepi_bot_server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davidemodolo","download_url":"https://codeload.github.com/davidemodolo/orangepi_bot_server/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248215191,"owners_count":21066621,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bot","discord-bot","orange-pi","python","raspberry-pi","raspbian-os","telegram-bot","twitch-bot"],"created_at":"2024-11-03T17:04:02.904Z","updated_at":"2025-04-10T11:51:37.734Z","avatar_url":"https://github.com/davidemodolo.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Orange Pi used as Server for Telegram, Discord, and Twitch Bots\n\nTested on Orange Pi Zero 2W 2GB RAM.\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"pics/logo.png\" alt=\"Orange Pi Logo\" width=\"250\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"pics/board.png\" alt=\"Board Image\" width=\"450\"\u003e\n\u003c/p\u003e\n\n# Initial Setup\n\n1. Download the OS iso (I used the Raspberry Pi OS opizero2w Desktop version from [GitHub](https://github.com/leeboby/raspberry-pi-os-images));\n2. Prepare a microSD card with the OS image (using [Balena Etcher](https://etcher.balena.io/)) and insert it into the board;\n3. Connect the board to a monitor, keyboard, and mouse and power it up;\n4. Go through the initial setup.\n\n# Fix the disk space\n\n```bash\ndf -h\n```\n\nIf the disk space is not correct (you have a 32GB cards but it only shows 8GB), you need to expand the filesystem:\n\n```bash\nsudo raspi-config\n```\n\nThen go to **Advanced** -\u003e **Expand Filesystem**\n\nReboot the system:\n\n```bash\nsudo reboot\n```\n\nCheck the disk space again:\n\n```bash\ndf -h\n```\n\n# Script to run all bots at the startup\n\nThe idea is that it will scan a specific folder (recursively) and run each `bot.py` file in a separate thread.\n\nSave the file as `run_bots.py` in the `/home/orangepi/` folder.\n\n```python\nimport os\nimport subprocess\nimport threading\n\nBOTS_DIR = \"/home/orangepi/bots\"  # Adjust this path to where your bots folder is located\n\ndef run_bot(bot_path):\n    \"\"\"\n    Function to run a bot file using subprocess\n    \"\"\"\n    try:\n        print(f\"Running bot: {bot_path}\")\n        subprocess.run(['python3', bot_path], check=True)\n    except subprocess.CalledProcessError as e:\n        print(f\"Error running {bot_path}: {e}\")\n\ndef scan_and_run_bots():\n    \"\"\"\n    Function to scan the bots folder and run each bot.py file\n    \"\"\"\n    for root, dirs, files in os.walk(BOTS_DIR):\n        for file in files:\n            if file == \"bot.py\":\n                bot_path = os.path.join(root, file)\n                bot_thread = threading.Thread(target=run_bot, args=(bot_path,))\n                bot_thread.start()\n\nif __name__ == \"__main__\":\n    scan_and_run_bots()\n\n```\n\n# Service to run the script at the startup\n\n```bash\nsudo nano /etc/systemd/system/run-bots.service\n```\n\nWe wait for an additional 25 seconds before running the script to ensure that the network is up and running.\n\nWrite and save this to the file (edit the various paths and usernames as needed):\n\n```bash\n[Unit]\nDescription=Run Python bots at startup\nAfter=network-online.target\nWants=network-online.target\n\n[Service]\nExecStartPre=/bin/sleep 25\nExecStart=/usr/bin/python /home/orangepi/run_bots.py\nWorkingDirectory=/home/orangepi/\nUser=username\nGroup=username\nRestart=on-failure\nRestartSec=30\nStartLimitIntervalSec=0\n\n[Install]\nWantedBy=multi-user.target\n\n```\n\nEnable the service:\n\n```bash\nsudo systemctl daemon-reload\nsudo systemctl enable run-bots.service\nsudo systemctl start run-bots.service\n```\n\nCheck the status for any error:\n\n```bash\nsudo systemctl status run-bots.service\n```\n\n# Headless\n\nDepending on your setup, the board may not work properly without a monitor connected. I'm not sure on how this works (I just found this online and it fixed the problem for me), but it seems to fix the problem:\n\n```bash\nsudo nano /boot/config.txt\n```\n\nAdd the following lines (the file may be empty, so just add these lines):\n\n```bash\n# Force HDMI even if no monitor is connected\nhdmi_force_hotplug=1\n\n# Set HDMI mode (optional but recommended for headless setups)\nhdmi_group=1\nhdmi_mode=1\n\n# Reduce resolution for headless mode if desired (optional)\n# You can set a lower resolution to reduce the load:\nhdmi_mode=16  # 1024x768 resolution\n```\n\n# Add bots\n\nJust put your bots in the `/home/orangepi/bots` folder and they will be run at the startup.\n\nRemember that the files must be named `bot.py`, and they can be in subfolders.\n\nPaths inside the code of any bot should be \"total\" and not \"relative\".\n# Run\n\nJust attach the board to the power and it will run the bots automatically.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidemodolo%2Forangepi_bot_server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavidemodolo%2Forangepi_bot_server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidemodolo%2Forangepi_bot_server/lists"}