m1guelpf / chatgpt-telegram

Run your own GPTChat Telegram bot, with a single command!
MIT License
3.89k stars 558 forks source link

Allowing for multiple Telegram IDs #41

Closed herman925 closed 1 year ago

herman925 commented 1 year ago

I want to set this up for my family to use, and the current implementation seems to only allow a single user to use the chatbot

KingingWang commented 1 year ago

me too

D4T4R commented 1 year ago

I found the line where you can edit it :

userId := strconv.FormatInt(update.Message.Chat.ID, 10) if os.Getenv("TELEGRAM_ID") != "" && userId != os.Getenv("TELEGRAM_ID") { msg.Text = "You are not authorized to use this bot." bot.Send(msg) continue

Edit this and try, but not sure about how to decompile the release package. You need to run the https://github.com/m1guelpf/chatgpt-telegram/tree/main/src URLs orderwise.

GitHub
chatgpt-telegram/src at main · m1guelpf/chatgpt-telegram
Run your own GPTChat Telegram bot, with a single command! - chatgpt-telegram/src at main · m1guelpf/chatgpt-telegram
AkoZhu commented 1 year ago

Same question

m1guelpf commented 1 year ago

I'd be willing to accept a PR that supports adding multiple IDs separated with commas, and parses those into an array to check against.

xros commented 1 year ago

Actually I made it work well for multiple users and added logging logics.

By commenting these lines. And it works well

// msg.Text = "You are not authorized to use this bot."
// bot.Send(msg)
// continue

I'd be willing to accept a PR that supports adding multiple IDs separated with commas, and parses those into an array to check against.

I don't know much about Go language but that is a hacky way.

Btw, I was looking for logging the feed from chatgpt bot,

https://github.com/m1guelpf/chatgpt-telegram/blob/main/main.go#L90

How can I get the content in string from the object feed? I want to record what the ChatGPT replies to users.

https://github.com/m1guelpf/chatgpt-telegram/blob/main/src/chatgpt/chatgpt.go#L73

I saw this source codes, and it will return this r <- ChatResponse{Message: res.Message.Content.Parts[0]}, as if it's will return a pointer pointing to an address in the RAM. If I print it, it will show something "0x12345678".

GitHub
chatgpt-telegram/main.go at main · m1guelpf/chatgpt-telegram
Run your own GPTChat Telegram bot, with a single command! - chatgpt-telegram/main.go at main · m1guelpf/chatgpt-telegram
GitHub
chatgpt-telegram/chatgpt.go at main · m1guelpf/chatgpt-telegram
Run your own GPTChat Telegram bot, with a single command! - chatgpt-telegram/chatgpt.go at main · m1guelpf/chatgpt-telegram