|
@@ -1,12 +1,37 @@
|
|
|
-from rival_regions_wrapper.middleware import LocalAuthentication
|
|
|
-from rival_regions_wrapper import util
|
|
|
-from rival_regions_wrapper.wrapper.abstract_wrapper import AbstractWrapper
|
|
|
+"""Buy bot"""
|
|
|
+
|
|
|
import re
|
|
|
+import os
|
|
|
+
|
|
|
from bs4 import BeautifulSoup
|
|
|
+from rival_regions_wrapper.middleware import LocalAuthentication
|
|
|
+from rival_regions_wrapper.wrapper.abstract_wrapper import AbstractWrapper
|
|
|
+from rival_regions_wrapper import util
|
|
|
+
|
|
|
+
|
|
|
+class MissingAuthenticationError(Exception):
|
|
|
+ """Error for missing authentication"""
|
|
|
+
|
|
|
+
|
|
|
+RIVAL_REGIONS_USERNAME = os.environ.get("RIVAL_REGIONS_USERNAME", None)
|
|
|
+RIVAL_REGIONS_PASSWORD = os.environ.get("RIVAL_REGIONS_PASSWORD", None)
|
|
|
+RIVAL_REGIONS_LOGIN_METHOD = os.environ.get("RIVAL_REGIONS_LOGIN_METHOD", None)
|
|
|
+CAPTCHA_KEY = os.environ.get("CAPTCHA_KEY", None)
|
|
|
|
|
|
+if None in (
|
|
|
+ RIVAL_REGIONS_USERNAME,
|
|
|
+ RIVAL_REGIONS_PASSWORD,
|
|
|
+ RIVAL_REGIONS_LOGIN_METHOD,
|
|
|
+):
|
|
|
+ raise MissingAuthenticationError(
|
|
|
+ "Load the following variables in your user environment: "
|
|
|
+ "RIVAL_REGIONS_USERNAME, RIVAL_REGIONS_PASSWORD, RIVAL_REGIONS_LOGIN_METHOD"
|
|
|
+ )
|
|
|
|
|
|
-authentication = LocalAuthentication(True)
|
|
|
-authentication.set_credentials("mail@gmail.com", "password", "google")
|
|
|
+authentication = LocalAuthentication(False, CAPTCHA_KEY)
|
|
|
+authentication.set_credentials(
|
|
|
+ RIVAL_REGIONS_USERNAME, RIVAL_REGIONS_PASSWORD, RIVAL_REGIONS_LOGIN_METHOD
|
|
|
+)
|
|
|
|
|
|
|
|
|
class CurrentPrice(AbstractWrapper):
|