Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add users via chat #108

Open
MBudkin opened this issue Mar 24, 2023 · 10 comments
Open

Add users via chat #108

MBudkin opened this issue Mar 24, 2023 · 10 comments
Labels
enhancement New feature or request

Comments

@MBudkin
Copy link

MBudkin commented Mar 24, 2023

Is it possible to add users via chat from the administrator?
So that you can quickly add a user and specify the necessary parameters for him.
It would also be cool if you could add users without restarting the server.

@AlexHTW
Copy link
Contributor

AlexHTW commented Mar 24, 2023

I really like this idea (as well as further admin commands that allow changing settings during run time).

Additionaly I want to suggest a "/getaccess" command for unallowed users that notifies the admin and gives him the option to add the user to allowed users and set up the budget(s). That would really streamline the process of adding new users.

@MBudkin
Copy link
Author

MBudkin commented Mar 24, 2023

Additionaly I want to suggest a "/getaccess"

This is a great idea!

@ivanmilov
Copy link
Contributor

ivanmilov commented Apr 25, 2023

We already have everything we need for the feature.
First, remove COPY . . from Dockerfile as we want mutable .env file.
In docker-compose we already using

    volumes:
      - .:/app

so, .env file is being used without copying

this snippet loads and updates a key in .env:

    import dotenv
    dotenv_file = dotenv.find_dotenv()
    dotenv.load_dotenv(dotenv_file)

    print(os.environ["MY_KEY"]) 
    os.environ["MY_KEY"] = "bar"
    print(os.environ['MY_KEY']) 

    # Write changes to .env file.
    dotenv.set_key(dotenv_file, "MY_KEY", os.environ["MY_KEY"])

@n3d1117, @AlexHTW what do you think?

@AlexHTW
Copy link
Contributor

AlexHTW commented Apr 25, 2023

Hi @ivanmilov, thanks for the input. I think the main issue is that docker run doesn't allow for a mutable .env because you have to pass the file in the initial command. Would it work with your suggestion or do you have any other ideas how to solve that?

@ivanmilov
Copy link
Contributor

Would it work with your suggestion or do you have any other ideas how to solve that?

run docker like this:
docker run -v .:/app

@ivanmilov
Copy link
Contributor

Build the image
docker build -t my-test .

run with mutable files
docker run -it --rm -v `pwd`:/app my-test

@ivanmilov
Copy link
Contributor

@n3d1117 @AlexHTW take a look at this POC:
https://github.com/ivanmilov/chatgpt-telegram-bot/tree/add_user

works with python3 bot/main.py, docker run ... and docker compose up

I can continue in this direction, but I am not a Python dev, so there could be some code quality issues :)

@s190263274
Copy link

I believe will be better if we add the users after they subscribe, integrated with Telegram Bot Payments https://core.telegram.org/bots/payments

@khanfar
Copy link

khanfar commented Dec 11, 2023

Screenshot_20231212_001558_TurboTel~2
i sucsess do admin panel bot to edit env from here : https://github.com/khanfar/controlenvbot

@khanfar
Copy link

khanfar commented Dec 11, 2023

use v 4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants