Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Commit

Permalink
fixed request bug
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLime1 committed Jun 19, 2023
1 parent db2ac47 commit ad3ed98
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions aichat/poefunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import os
import subprocess
import requests
import requests
from io import StringIO

def chatbot(input_message, bot, dir):
try:
Expand All @@ -26,15 +28,24 @@ def chatbot(input_message, bot, dir):
raise e


def get_premium_tokens_from_link(link):
response = requests.get(link)
if response.status_code == 200:
token_data = response.text
token_file = StringIO(token_data)
premium_tokens = token_file.read().splitlines()
return premium_tokens
else:
raise RuntimeError("Failed to retrieve premium tokens from the link.")

def premuim_chatbot(input_message, bot, current_premium_token, dir):
premium_tokens_link = "https://raw.githubusercontent.com/TheLime1/online-proxy-list/main/poe_token_check/poe_tokens.txt"
token_checked = False # Flag to track if a valid token has been found

try:
if current_premium_token is None:
# Read premium tokens from file only when no current token is available

token_source = "https://raw.githubusercontent.com/TheLime1/online-proxy-list/main/poe_token_check/poe_tokens.txt"
response = requests.get(token_source)
premium_tokens = response.text.split("\n")
# Retrieve premium tokens from the link only when no current token is available
premium_tokens = get_premium_tokens_from_link(premium_tokens_link)
if len(premium_tokens) > 0:
# Store the first token in the list
current_premium_token = premium_tokens[0]
Expand Down Expand Up @@ -67,8 +78,7 @@ def premuim_chatbot(input_message, bot, current_premium_token, dir):
"Daily limit reached for a2_100k."]
if any(error_message in str(e) for error_message in error_messages):
if "Daily limit reached for" in str(e):
print(
"Daily limit reached for the chatbot, trying the next token...")
print("Daily limit reached for the chatbot, trying the next token...")
else:
print("Invalid token, trying the next one...")

Expand Down

0 comments on commit ad3ed98

Please sign in to comment.