Thibault преди 3 години
родител
ревизия
8d87d0c1d6
променени са 6 файла, в които са добавени 301 реда и са изтрити 0 реда
  1. 11 0
      Pipfile
  2. 20 0
      Pipfile.lock
  3. 163 0
      SellBot.py
  4. 83 0
      buy_bot.py
  5. 24 0
      main.py
  6. 0 0
      python

+ 11 - 0
Pipfile

@@ -0,0 +1,11 @@
+[[source]]
+url = "https://pypi.org/simple"
+verify_ssl = true
+name = "pypi"
+
+[packages]
+
+[dev-packages]
+
+[requires]
+python_version = "3.9"

+ 20 - 0
Pipfile.lock

@@ -0,0 +1,20 @@
+{
+    "_meta": {
+        "hash": {
+            "sha256": "a36a5392bb1e8bbc06bfaa0761e52593cf2d83b486696bf54667ba8da616c839"
+        },
+        "pipfile-spec": 6,
+        "requires": {
+            "python_version": "3.9"
+        },
+        "sources": [
+            {
+                "name": "pypi",
+                "url": "https://pypi.org/simple",
+                "verify_ssl": true
+            }
+        ]
+    },
+    "default": {},
+    "develop": {}
+}

+ 163 - 0
SellBot.py

@@ -0,0 +1,163 @@
+from rival_regions_wrapper.middleware import LocalAuthentication
+from rival_regions_wrapper import util
+from rival_regions_wrapper.wrapper.abstract_wrapper import AbstractWrapper
+import re
+from bs4 import BeautifulSoup
+
+
+authentication = LocalAuthentication(True)
+authentication.set_credentials("mail@gmail.com","password","google")
+
+
+class Market2(AbstractWrapper):
+
+  def info(self, resource):
+    """Get profile"""
+    if isinstance(resource, str) and resource in util.ITEM_KEYS:
+      resource = util.ITEM_KEYS[resource]
+    path = 'storage/listed/{}'.format(resource)
+    response = self.middleware.get(path)
+    soup = BeautifulSoup(response, 'html.parser')
+    offers_tree = soup.find_all(class_='list_link')
+    test = 0
+    i = 0
+    for offer_tree in offers_tree:
+      if int(re.sub(
+          r'^.*\/', '',
+          offer_tree.select_one('.results_date')['action'])) == 2000883512:
+         test = int(
+          offer_tree.select_one('.list_level.imp.small')['rat']
+        )
+      i = i+1
+    return test
+
+
+class Storage(AbstractWrapper):
+  """Wrapper class for storage"""
+  def info(self,resource):
+    """storage info"""
+    path = 'storage'
+    resource = util.ITEM_KEYS[resource]
+    response = self.middleware.get(path)
+    soup = BeautifulSoup(response, 'html.parser')
+    storage = int(
+      soup.find('span', {'urlbar': resource}).text.replace('.', ''))
+    return storage
+
+
+class Market(AbstractWrapper):
+  def info(self, resource):
+    """Get profile"""
+    if isinstance(resource, str) and resource in util.ITEM_KEYS:
+      resource = util.ITEM_KEYS[resource]
+    path = 'storage/listed/{}'.format(resource)
+    response = self.middleware.get(path)
+    soup = BeautifulSoup(response, 'html.parser')
+    offers_tree = soup.find_all(class_='list_link')
+    test = 0
+    prijs = 0
+    for offer_tree in offers_tree:
+        if test == 0:
+          test = 1
+          prijs = int(
+            float(offer_tree.select('.list_level')[1]['rat']) * 100)
+          if int(re.sub(r'^.*\/', '',offer_tree.select_one('.results_date')['action'])) == 2000883512:
+            prijs = 0
+    return prijs
+
+
+class MarketBot(AbstractWrapper):
+  def info(self,resource,minprice):
+    test = 0
+    current_price = Market(authentication).info(resource)
+    if current_price !=0:
+      op_markt = Market2(authentication).info(resource)
+      opslag = Storage(authentication).info(resource)
+      totaal = opslag + op_markt
+      mijn_prijs = (current_price - 10)/100
+      check = 0
+
+      if mijn_prijs < minprice:
+        mijn_prijs = minprice
+      if resource == "helium-3":
+        if totaal >= 153600:
+          totaal = 153600
+          check = 1
+      if resource == "liquid_oxygen":
+        if totaal >= 38400000:
+          totaal = 38400000
+          check = 1
+      if resource == "oil":
+        if totaal >= 614400000:
+          totaal = 614400000
+          check = 1
+      if resource == "ore":
+        if totaal >= 614400000:
+          totaal = 614400000
+          check = 1
+      if resource == "uranium":
+        if totaal >= 15360000:
+          totaal = 15360000
+          check = 1
+      if resource == "diamonds":
+        if totaal >= 153600:
+          totaal = 153600
+          check = 1
+      if resource == "rivalium":
+        if totaal >= 614400:
+          totaal = 614400
+          check = 1
+      if resource == "antirad":
+        if totaal >= 76800:
+          totaal = 76800
+          check = 1
+      if resource == "spacerockets":
+        if totaal >= 3840:
+          totaal = 3840
+          check = 1
+      if resource == "lss":
+        if totaal >= 15360000:
+          totaal = 15360000
+          check = 1
+      if resource == "tanks":
+        if totaal >= 4388571:
+          totaal = 4388571
+          check = 1
+      if resource == "aircrafts":
+        if totaal >= 640000:
+          totaal = 640000
+          check = 1
+      if resource == "missiles":
+        if totaal >= 256000:
+          totaal = 256000
+          check = 1
+      if resource == "bombers":
+        if totaal >= 128000:
+          totaal = 128000
+          check = 1
+      if resource == "battleships":
+        if totaal >= 128000:
+          totaal = 128000
+          check = 1
+      if resource == "laser_drones":
+        if totaal >= 256000:
+          totaal = 256000
+          check = 1
+      if resource == "moon_tanks":
+        if totaal >= 12800:
+          totaal = 12800
+          check = 1
+      if resource == "space_stations":
+        if totaal >= 1280:
+          totaal = 1280
+          check = 1
+      if (((totaal == op_markt) and (mijn_prijs == minprice)) or (minprice == 500000000)):
+        return True
+      if totaal != 0:
+        item = util.ITEM_KEYS[resource]
+        self.middleware.post(
+          'storage/sell/{}'.format(item))
+        self.middleware.post(
+          'storage/newsell/{}/{}/{}'.format(item, totaal, mijn_prijs))
+    return True
+

+ 83 - 0
buy_bot.py

@@ -0,0 +1,83 @@
+from rival_regions_wrapper.middleware import LocalAuthentication
+from rival_regions_wrapper import util
+from rival_regions_wrapper.wrapper.abstract_wrapper import AbstractWrapper
+import re
+from bs4 import BeautifulSoup
+
+
+authentication = LocalAuthentication(True)
+authentication.set_credentials("mail@gmail.com","password","google")
+
+
+class CurrentPrice(AbstractWrapper):
+  def info(self, resource):
+    """Get profile"""
+    if isinstance(resource, str) and resource in util.ITEM_KEYS:
+      resource = util.ITEM_KEYS[resource]
+    path = 'storage/listed/{}'.format(resource)
+    response = self.middleware.get(path)
+    soup = BeautifulSoup(response, 'html.parser')
+    offers_tree = soup.find_all(class_='list_link')
+    test = 0
+    prijs = 0
+    for offer_tree in offers_tree:
+        if test == 0:
+          test = 1
+          prijs = int(
+            float(offer_tree.select('.list_level')[1]['rat']) * 100
+          )
+    return prijs
+
+class Amount(AbstractWrapper):
+
+  def info(self, resource):
+    """Get profile"""
+    if isinstance(resource, str) and resource in util.ITEM_KEYS:
+      resource = util.ITEM_KEYS[resource]
+    path = 'storage/listed/{}'.format(resource)
+    response = self.middleware.get(path)
+    soup = BeautifulSoup(response, 'html.parser')
+    offers_tree = soup.find_all(class_='list_link')
+    test = 0
+    for offer_tree in offers_tree:
+        if test ==0:
+            test =1
+            amount = int(offer_tree.select_one('.list_level.imp.small')['rat'])
+    return amount
+
+
+class Profile(AbstractWrapper):
+
+  def info(self, resource):
+    """Get profile"""
+    if isinstance(resource, str) and resource in util.ITEM_KEYS:
+      resource = util.ITEM_KEYS[resource]
+    path = 'storage/listed/{}'.format(resource)
+    response = self.middleware.get(path)
+    soup = BeautifulSoup(response, 'html.parser')
+    offers_tree = soup.find_all(class_='list_link')
+    test = 0
+    profiel = 0
+    for offer_tree in offers_tree:
+        if test ==0:
+            test =1
+            profiel = int(re.sub(
+            r'^.*\/', '',
+            offer_tree.select_one('.results_date')['action']))
+    return profiel
+
+class BuyMarket(AbstractWrapper):
+    def info(self, resource,price):
+        current_price = CurrentPrice(authentication).info(resource)/100
+        if current_price < price:
+            profiel = Profile(authentication).info(resource)
+            amount = Amount(authentication).info(resource)
+            item = util.ITEM_KEYS[resource]
+            self.middleware.post(
+                'storage/buy/{}/{}/{}/{}'.format(item,profiel,amount,current_price))
+        return True
+
+
+
+
+

+ 24 - 0
main.py

@@ -0,0 +1,24 @@
+from rival_regions_wrapper.middleware import LocalAuthentication
+import time
+from datetime import datetime
+import SellBot
+import buy_bot
+
+authentication = LocalAuthentication(True)
+authentication.set_credentials("mail@gmail.com","password","google")
+
+while True:
+
+  soorten = ['oil','ore', 'uranium', 'diamonds','liquid_oxygen','helium-3','rivalium','antirad','spacerockets','lss','tanks','aircrafts','missiles','bombers','battleships','laser_drones','moon_tanks','space_stations']
+  verkoopprijs = [164,150,1999,1500000,4000,800000,500000000,500000000,500000000,500000000,500000000,500000000,500000000,500000000,500000000,500000000,500000000,19888000]
+  koopprijs = [100,100,1000,100000,2000,100000,1,1,1,1,1,1,1,1,1,1,1,1]
+  i = 0
+  for x in soorten:
+    buy_bot.BuyMarket(authentication).info(soorten[i], koopprijs[i])
+    SellBot.MarketBot(authentication).info(soorten[i], verkoopprijs[i])
+    i = i+1
+
+  now = datetime.now()
+  current_time = now.strftime("%H:%M:%S")
+  print("Current Time =", current_time)
+  time.sleep(301)

+ 0 - 0
python