Git Product home page Git Product logo

chatgpt-telegrambot's Introduction

Warning No longer works as of December 12th due to Cloudflare protections (see #261)

ChatGPT Telegram Bot

python-version revChatGPT-version license

A Telegram bot that integrates with OpenAI's ChatGPT to provide answers. Ready to use with minimal configuration required. Based on acheong08/ChatGPT

Screenshot

Demo

Features

  • Reply to specific messages
  • Support markdown in answers
  • Can reset conversation thread with the /reset command
  • Typing indicator while generating a response
  • Access can be restricted by specifying a list of allowed users
  • (NEW!) Docker support
  • (NEW!) Live answer updating as the bot types

Additional Features - help needed!

  • Multi-chat support (ongoing, see pull/22)
    • Idea: cache different instances of ChatGPT3Bot, one for every chat id (maybe even persist them), so that every user has their own private conversation
  • Support group chats (ongoing, see pull/17)
    • Allow the bot to be used in group chats with specific commands
  • Advanced commands
    • With premade ad-hoc prompts

PRs are always welcome!

Prerequisites

Getting started

Configuration

Customize the configuration by copying .env.example and renaming it to .env, then editing the settings as desired:

OPENAI_EMAIL="<YOUR_OPENAI_EMAIL>"
OPENAI_PASSWORD="<YOUR_OPENAI_PASSWORD>"
TELEGRAM_BOT_TOKEN="<YOUR_TELEGRAM_BOT_TOKEN>"
  • OPENAI_EMAIL,OPENAI_PASSWORD: Your OpenAI credentials (these are only sent to the OpenAI server to periodically refresh the access token and never shared). You can read more about it here
  • TELEGRAM_BOT_TOKEN: Your Telegram bot's token, obtained using BotFather (see tutorial)

Additional optional (but recommended) configuration values:

ALLOWED_TELEGRAM_USER_IDS="<USER_ID_1>,<USER_ID_2>,..." # Defaults to "*"
PROXY="<HTTP/HTTPS_PROXY>" # E.g. "http://localhost:8080", defaults to none
USE_STREAM=false # Defaults to true
DEBUG=false # Defaults to true
  • ALLOWED_TELEGRAM_USER_IDS: A comma-separated list of Telegram user IDs that are allowed to interact with the bot (use getidsbot to find your user ID). Important: by default, everyone is allowed (*)
  • PROXY: Proxy to be used when authenticating with OpenAI
  • USE_STREAM: Streams the response as the bot types. Set to false to only answer once the response is fully generated
  • DEBUG: Enable debug logging for the revChatGpt package

Installing

  1. Clone the repository and navigate to the project directory:
git clone https://github.com/n3d1117/chatgpt-telegram-bot.git
cd chatgpt-telegram-bot

From Source

  1. Create a new virtual environment with Pipenv and install the required dependencies:
pipenv install
  1. Activate the virtual environment:
pipenv shell
  1. Use the following command to start the bot:
python main.py

Using Docker Compose

  1. Run the following command to build and run the Docker image:
docker-compose up

Credits

Disclaimer

This is a personal project and is not affiliated with OpenAI in any way.

License

This project is released under the terms of the GPL 2.0 license. For more information, see the LICENSE file included in the repository.

chatgpt-telegrambot's People

Contributors

acheong08 avatar n3d1117 avatar slippersheepig avatar

Watchers

 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.