This is a telegram bot which uses EdgeGPT to post queries and get the response. This bot cannot be shared publicly since its uses your browser cookies to authenticate you as bing needs you to be logged in. So you should have your own bot using own browser cookie.
Credit goes to the developers of EdgeGPT, who ingeniously reverse-engineered Bing Chat using browser cookies.
IndexOutofBoundException
, restart your python script. If is still not working, export the cookies again and update the cookie.json file.Clone or download this code to a any directory.
git clone https://github.com/amazingpaddy/chatgpt-telegram-bot.git
install EdgeGPT package
python3 -m pip install EdgeGPT --upgrade
pip install pyTelegramBotAPI
install Cookie Editor extension in Edge browser.
Navigate to the Bing Chat webpage where you can post queries and receive responses.
Ensure that you have not reached the chat limit, then export your cookie using the Cookie Editor extension.
The cookie JSON string will be copied to your clipboard. Save the cookie JSON in a file, for example, "cookie.json". Ideally, save the "cookie.json" file in the same directory where you cloned the code.
Follow this blog - How to Generate a Token for Telegram Bot API to generate a create a bot and generate token to use it in the code. If you are unable to read the blog in normal mode, use the incognito mode of your browser.
Update the token in the code, BOT_TOKEN. And also update the cookie.json with correct path in the code. After updating the details, run the python script - bingbot.py using an IDE or command prompt.
Update your telegram id in the authorized_id list in the code.
authorized_id = ['<your telegram username without @>']
. You can give access to your closed ones by adding their id to the list. But its not recommended.
For example, if my telegram userid is @exampleuserid, then update the list like authorized_id = ['exampleuserid']
Use the below command to run bot code
python bingbot.py
Test the code using bot. If you follow the steps to create telegram bot, you might have got the bot link from botFather, Use the link to open the bot and click start.
Use /ask <your query>
to post a query and send it. The response will not have any reference links.
if you want the response with reference, use /askref <your query>
Wait 2 to 3 mins to recieve response. You need to keep running the server in your laptop or cloud for bot to be working.