Skip to content

A telegram bot that uses the OpenAI and/or the Anthropic API for an improved user experience, with payment system integrated for you to start making money! Please consider starring the repo if you use it!

License

Notifications You must be signed in to change notification settings

FlamingoFiesta/Chatgpt-Claude_telegram_bot_with_payment_system

Repository files navigation

ChatGPT Telegram Bot : No daily limits. Special chat modes.


This repo is a fork based on Karfly's infrastructure, with some added functionalities by me. Please check his repo out, this wouldnt have been possible without him!

This repo is ChatGPT re-created as Telegram Bot, and its 95% ready for you to deploy and potentially earn money

You can deploy your own bot, or use mine: @Chatdud Bot

If you decide to clone the repo and use the bot, please consider starring the project. I would be really greatful! <3

Original features when I started the fork (02.02.2024)

  • Low latency replies (it usually takes about 3-5 seconds)
  • No request limits
  • GPT-4 and support
  • Group Chat support (/help_group_chat to get instructions)
  • DALLE 2 (choose 👩‍🎨 Artist mode to generate images)
  • Voice message recognition
  • 15 special chat modes: 👩🏼‍🎓 Assistant, 👩🏼‍💻 Code Assistant, 👩‍🎨 Artist, 🧠 Psychologist, 🚀 Elon Musk and other. You can easily create your own chat modes by editing config/chat_modes.yml
  • Support of ChatGPT API
  • List of allowed Telegram users
  • Track $ balance spent on OpenAI API

What I added

  • GPT-4 Vision is finally fully integrated and supported (inspiration taken from multiple places as I had issues)

  • GPT-4o (omni) support, faster and cheaper than GPT-4 turbo, with october 2023 knowledge cut-off date.

    • It was released two days ago (13.05.2024), so right now its only used as the text model, further testing will be required until I decide to make it the default vision model.
  • Claude 3 models from Anthropic are now supported, namely: Opus, Sonnet and Haiku.

  • 15 new chat modes: Cyber Dud (⌐■_■), ⌨️ Stenographer (Speech to text), 💻🟧 Grimoire (Advanced coding assitant), 🖥️ Bash dud (Linux Terminal), 🦆 Duck Mode, and a bunch of characters from movies and shows!

  • Transcribe voice messages (choose ⌨️ Stenographer)

  • Selectable DALL-E models and their configurations. You can choose between DALL-E 2 which allows you to generate multiple images at once and DALL-E 3 which allows you to choose the image quality. You can choose the image resolution for both models in /settings Artist model

  • Improved start and help messages

  • Improved the settings and balance menus, theyre now more user friendly and clean

  • Different user roles: admin, beta tester, friend, regular user, trial user

    • All new users start as a trial user with 1 euro balance, and are automatically upgraded to regular user after first payment
    • Special admin-only commands that can be used directly from the telegram app
  • Payment system using Stripe, updating user balance automatically after payment

  • Special donation button

  • Customizable profit margin based on roles in config/config.example.yml

    • In the form of "1.xx", xx being the percentage of profit you want
      • 1.10 for 10%, 1.05 for 5% etc.
  • Check user balance before making the API call and prompt them to top-up if it's too low. Can be turned off by changing the role deduction rates to 0

  • Tracking the balance in euros and tokens. The default is in euros, advanced users and switch to the token system, the functions are there.

  • The ability to run either the full version with the payment system, or the one without it, freeing up resources if it isnt used.


Upcoming:

  • If GPT-4o "Omni" proves to be a stable model, it will be the new default for both text and vision capabilities since OpenAI claims its better at other languages that arent english
  • Adding the posibility to view and resume past conversations
  • /menu command that displays the commands as buttons for a more seamless interaction

Bot commands

  • /new – Start new dialog
  • /retry – Regenerate last bot answer
  • /mode – Select chat mode
  • /balance – Show balance
  • /topup – Add credits to your account
  • /settings – Show settings
  • /help – Show the commands
  • /role – Show your role
  • /model - Show your current selected model
  • /admin - Display admin commands (if youre admin)

Setup

  1. Get your OpenAI API key and/or your (optional) Anthropic API key

  2. Get your Telegram bot token from @BotFather

  3. Get your Stripe secret key (optional if you dont want to use the payment system)

  4. Edit config/config.example.yml to set your tokens, stripe key (if you choose to use stripe), then run the 2 commands below (if you're advanced user, you can also edit config/config.example.env):

    mv config/config.example.yml config/config.yml
    mv config/config.example.env config/config.env
    
  5. Download and install docker, then open the app.

  6. (Optional) Setup ngrok to automatically update the users balance after payment and send them a confirmation message (ignore this if you dont want to update your balance automatically and in real time, skip to step 7)

    1. Download ngrok:

      • Go to the ngrok website.
      • Click on the download for your operating system.
      • Sign up or log in on the website to get your authentication token (will be refered to as <YOUR_AUTH_TOKEN>).
    2. Unzip the folder

    3. Connect your account

      • For MacOS:

        • Open terminal
        • Navigate to the folder where you unziped ngrok (e.g. cd Downloads).
        • Run:
          ./ngrok authtoken <YOUR_AUTH_TOKEN>
        • Keep the terminal window open
      • For Windows:

        • Open Command Prompt.

        • Open terminal and navigate to the folder where you unziped ngrok (e.g. cd Downloads).

        • Run:

          ngrok.exe authtoken <YOUR_AUTH_TOKEN> 
        • Keep the terminal window open

    4. Run ngrok

      • For MacOS:

        • Run:
          ./ngrok http 5000
        • You will see a status screen with the URL next to "Forwarding" in the format of "https://NUMBERS.ngrok-free.app", you will need it in bit
        • Keep the terminal open, ngrok will keep running as long as the terminal window is open.
      • For Windows

        • Run:
           ngrok.exe http 5000
        • You will see a status screen with the URL next to "Forwarding" in the format of "https://NUMBERS.ngrok-free.app", you will need it in bit
        • Keep the terminal open, ngrok will keep running as long as the terminal window is open.
    5. Add the webhook endpoint to the Stripe dashboard

      • Go to the webhook section in your stripe dashboard by following the link or find it under the Developers section
      • Click Add endpoint
      • In the Endpoint URL field, enter the URL you got from ngrok followed by /stripe-webhook
        • For this example it would be https://NUMBERS.ngrok-free.app/stripe-webhook
      • Click +Select events
      • Under the Checkout section, select checkout.session.completed. Now Add event then Add endpoint.
      • Click on Reveal under Signing secret and copy the webhook secret
    6. Edit config/config.yml to set your webhook secret

    7. Please note that the free plan for ngrok gives you a new URL everytime you run the service, which means that you have to keep it running all the time and update the URL in the stripe dashboard if you restart ngrok. For a static domain, you need to have the paid subscription.

    8. Now youre done setting up the payment system, good job!

  7. 🔥 And now, cd to the Chatgpt-Claude_telegram_bot_with_payment_system directory

    • If you use the payment system, run:
    docker-compose --env-file config/config.env up --build
    
    • If you dont use the payment system, run:
    docker-compose -f docker-compose_nopayment.yml --env-file config/config.env up --build
    

❤️ Top Donations

If you found my fork useful, use the topup command in my bot for any donations! Send me a message so that I know it was you who donated, you can be on this list:

  1. "." - €10, no special message, but thank you for being the first to donate!

Contributors

  • Karfly for the foundation of the code
  • FlamingoFiesta - Main contributor to this repo

References

  1. OpenAI API documentation
  2. Anthropic API documentation
  3. Stripe documentation