GithubHelp home page GithubHelp logo

hdcola / edge-gpt-telegram-bot Goto Github PK

View Code? Open in Web Editor NEW

This project forked from scmanjarrez/edgegpt-telegram-bot

5.0 0.0 4.0 61 KB

Telegram bot using EdgeGPT unofficial API

License: MIT License

Python 99.49% Dockerfile 0.51%

edge-gpt-telegram-bot's Introduction

Description

Telegram bot using EdgeGPT unofficial API

Content:

Requirements

  • python

BotFather set up

Create a bot with @BotFather and set the following commands:

new - Start a new conversation with the bot.
settings - Change bot settings, i.e. language/voice, conversation style, etc.

Hidden commands:

/unlock <passwd> - Unlock bot functionalities with a password

Run

  • Install python dependencies

    $ pip install -r requirements.txt

    If you want to contribute, install development dependencies as well.

    $ pip install -r dev_requirements.txt
  • Create a self-signed certificate in order to communicate with telegram server using SSL

    $ openssl req -newkey rsa:2048 -sha256 -nodes -keyout config/nginx.key -x509 -days 3650 -out config/nginx.pem
  • Create a directory named config to store bot configuration files. Copy templates/config.json to config directory. Change values according to your configuration.

    $ mkdir config
    $ cp templates/config.json config/config.json

    config.json:

    • settings:

      • token - Telegram bot token, obtained from @BotFather

      • webhook: true to run the bot using webhooks. false to use polling.

      • log_level: set level of the logging module. More info: log levels

      • ip: Your server/home IP. Must be accessible from internet.

      • port: Port to receive telegram updates. Allowed ports: 443, 80, 88 and 8443

        Nginx can be used as reverse in order to use other ports. Copy templates/nginx.conf to config and change values according to your configuration.

        • <docker-host-ip> is the gateway of the containers. Looks like 172.17.0.1
        • <portX> Can be any port in the user range.
        $ cp templates/nginx.conf config/nginx.con
        $ docker run --rm --name nginx --net host -v ./config/nginx.conf:/etc/nginx/nginx.conf:ro -v ./config/nginx.key:/etc/nginx/nginx.key:ro -v ./config/nginx.pem:/etc/nginx/nginx.pem:ro nginx
      • cert: Path to your server certificate (can be self-signed)

      • admin: List of admin IDs allowed manager bot. You could put a json file update cookies.json.

      • assemblyai_token: Your AssemblyAI token, required to use ASR. More info: Supported Languages

    • chats:

      • password: Password to use with /unlock and gain access to the bot (only required for the first time)
        "password": "supersecurepassword123"
      • id: List of telegram IDs allowed in the bot, without password. Obtain if from bots like @getmyid_bot.
        "ids": [
            123123123,
            132322322
        ]
  • Run the bot.

    $ python src/edge.py

    Note: If you run the bot in port 80, it may be needed to run the bot as superuser (sudo)

Docker

Manual build

Build the image and bind config directory in the container

$ docker build . -t edgegpt-telegram-bot --rm
$ docker run -d -it --name edgegpt -v ./config:/edgegpt/config edgegpt-telegram-bot

Dockerhub image

$ docker run -d -it --name edgegpt -v ./config:/edgegpt/config scmanjarrez/edgegpt-telegram-bot

docker-compose.yml file provided.

$ docker compose up -d
  • Use Docker

Install Docker and cocker-compose, put all config file to ./edgebot and put docker-compose.yml in current folder.

docker-compose up -d

Note: Only support amd64 and arm64.

Contributing

Happy to see you willing to make the project better. In order to make a contribution, please respect the following format:

  • Imports sorted with usort
    $ usort format *py
  • Code formatted with black (line lenght 79)
    $ black -l 79 *py

If you are using flake8, ignore E203 in .flake8

[flake8]
extend-ignore = E203

VSCode project settings

VSCode should have the following settings in settings.json:

{
    "python.analysis.fixAll": [],
    "python.formatting.blackArgs": [
        "-l 79"
    ],
    "python.formatting.provider": "black",
    "isort.path": [
        "usort format"
    ],
}
"python.linting.flake8Args": [
    "--ignore=E203",
],

Contributors

License

Copyright (c) 2023 scmanjarrez. All rights reserved.
This work is licensed under the terms of the MIT license.

For a copy, see LICENSE.

edge-gpt-telegram-bot's People

Contributors

hdcola avatar scmanjarrez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

edge-gpt-telegram-bot's Issues

把cookies.json存成一个文件,交给bot

Is your feature request related to a problem? Please describe.

No response

Describe the solution you'd like

把cookies.json存成一个文件,交给bot

Describe alternatives you've considered

No response

Additional context

No response

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.