soup = BeautifulSoup(response.text, 'html.parser') return [ (game.find('span', class_='suit').text, game.find('span', class_='result').text) for game in soup.find_all('div', class_='game-statistics') if (suit := game.find('span', class_='suit')) and (result := game.find('span', class_='result')) ]
def predict_suit(statistics): suit_count = {} for suit, _ in statistics: suit_count[suit] = suit_count.get(suit, 0) + 1 return max(suit_count, key=suit_count.get, default=None)
def predict_upcoming_games(statistics, count=5): predictions = [] for _ in range(count): predicted_suit = predict_suit(statistics) if predicted_suit: predictions.append(predicted_suit) statistics = [(suit, result) for suit, result in statistics if suit != predicted_suit] else: predictions.append("Неизвестно") break return predictions
# Команда /start def start(update: Update, context: CallbackContext): update.message.reply_text("Бот запущен!")
# Команда /stats def stats(update: Update, context: CallbackContext): statistics = fetch_baccarat_statistics() if statistics: most_common_suit = predict_suit(statistics) update.message.reply_text(f"Наиболее: {most_common_suit or 'Не удалось определить.'}") else: update.message.reply_text("Не удалось.")
Traceback (most recent call last): File "Тут был путь к файлу", line 84, in <module> main() ~~~~^^ File "Тут был путь к файлу", line 71, in main updater = Updater("Тут был токен", use_context=True) TypeError: Updater.__init__() got an unexpected keyword argument 'use_context'