Commit 168d902e authored by Hermann Krumrey's avatar Hermann Krumrey

Merge branch 'develop' into 'master'


See merge request !3
parents 35d7e707 b820cfc7
V 0.3.0:
- Added Random Betting
V 0.2.0:
- Implemented basic framework
- Implemented tipico-quote based predictor
- Implemented API connection
V 0.1.0:
- Project Start
\ No newline at end of file
- Project Start
......@@ -53,18 +53,27 @@ class ApiConnection:
return {"Authorization": "Basic " + self.api_key}
def login(self):
def login(self) -> bool:
Retrieves an API Key using a username and password if no key
has been retrieved yet or if the existing key has expired
:return: None
:return: True if the login was successfulle
if not self.authorized():"Requesting new API Key")
creds = {"username": self.username, "password": self.password}
data = self.execute_api_call("key", "POST", False, creds)
api_key = data["data"]["api_key"]
self.api_key = b64encode(api_key.encode("utf-8")).decode("utf-8")
if data["status"] != "ok":
self.logger.warning("Login attempt failed")
return False
api_key = data["data"]["api_key"]
encoded = b64encode(api_key.encode("utf-8"))
self.api_key = encoded.decode("utf-8")
return True
return True
def authorized(self) -> bool:
......@@ -116,7 +125,9 @@ class ApiConnection:
:return: The response JSON
if authorization_required and endpoint != "authorize":
logged_in = self.login()
if not logged_in:
return {"status": "error"}
extras = {}
if authorization_required:
Copyright 2020 Hermann Krumrey <>
This file is part of betbot.
betbot is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
betbot is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with betbot. If not, see <>.
import random
from typing import List
from betbot.api.Bet import Bet
from betbot.api.Match import Match
from betbot.prediction.Predictor import Predictor
class RandomPredictor(Predictor):
Class that always predicts random results
def name(cls) -> str:
:return: The name of the predictor
return "random"
def predict(self, matches: List[Match]) -> List[Bet]:
Performs the prediction
:param matches: The matches to predict
:return: The predictions as Bet objects
bets = []
for match in matches:
home_goals = random.randint(0, 4)
away_goals = random.randint(0, 4)
bets.append(Bet(, home_goals, away_goals))
return bets
......@@ -20,9 +20,11 @@ LICENSE"""
from typing import Type, List
from betbot.prediction.Predictor import Predictor
from betbot.prediction.DrawPredictor import DrawPredictor
from betbot.prediction.RandomPredictor import RandomPredictor
from betbot.prediction.TipicoOddsPredictor import TipicoOddsPredictor
predictors: List[Type[Predictor]] = [
\ No newline at end of file
\ No newline at end of file
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment