Bladeren bron

Remove app, functions, and credential template

JoostSijm 5 jaren geleden
bovenliggende
commit
44fe624811
4 gewijzigde bestanden met toevoegingen van 0 en 177 verwijderingen
  1. 0 2
      .gitignore
  2. 0 97
      app.py
  3. 0 73
      rival_regions_wrapper/functions.py
  4. 0 5
      template_credentials.json

+ 0 - 2
.gitignore

@@ -1,5 +1,3 @@
 .venv
-*_credentials.json
-!template_credentials.json
 cookies.json
 __pycache__/

+ 0 - 97
app.py

@@ -1,97 +0,0 @@
-"""Test module"""
-
-import sys
-import json
-
-from rival_regions_wrapper import Client
-
-
-def read_credentials(filename):
-    """Read credentials from filename"""
-    with open(filename) as credential_file:
-        return json.load(credential_file)
-
-def login(credentials=None):
-    """Main method"""
-    if credentials is None:
-        credentials = {}
-        credentials['username'] = input("Username: ")
-        credentials['password'] = input("Password: ")
-        credentials['method'] = input("Login Method: ")
-
-    client = Client(show_window=True)
-    client.login(credentials)
-    print(client.var_c)
-
-    action_dict = {
-        'market': market,
-        'oil_market': oil_market,
-        'article': article,
-        'get': get,
-        'gold_exploration': gold_exploration,
-        'vote_law': vote_law,
-    }
-    print(action_dict.keys())
-    while True:
-        action = input("Action: ")
-        if action in action_dict:
-            action_dict[action](client)
-        else:
-            print('action not found')
-
-def market(client):
-    """Get all market prices"""
-    market_info = client.get_all_market_info()
-    for i in market_info:
-        print("")
-        print(i.upper())
-        print("#"*len(i))
-        for j in market_info[i]:
-            print(j.upper() + ':' + market_info[i][j])
-
-def oil_market(client):
-    """Get oil market price"""
-    print(client.market_info('oil'))
-
-def article(client):
-    """Create article"""
-    client.create_article('Nothing to see here', '')
-
-def get(client):
-    """Send get request from client"""
-    path = input('Path: ')
-    result = client.get(path)
-    print(result)
-
-def gold_exploration(client):
-    """Create gold exploration law"""
-    resoure = 0
-    data = {
-        'tmp_gov': resoure
-    }
-    result = client.post('parliament/donew/42/{}/0'.format(resoure), data)
-    print(result)
-
-def vote_law(client):
-    """Vote for a law"""
-    # p400220003260451563564814
-    # p4002 2000326045 1563564814
-    # 'parliament/votelaw/4002/2000326045/1563564814/pro'
-    # 'parliament/votelaw/4002/2000326045/1563565114/pro'
-    region_id = 4002
-    player_id = 2000326045
-    law_id = 1563565114
-    result = client.post('parliament/votelaw/{}/{}/{}/pro'.format(
-        region_id,
-        player_id,
-        law_id
-    ), {})
-    print(result)
-    
-
-if __name__ == "__main__":
-    if len(sys.argv) >= 2:
-        CREDENTIALS = read_credentials(sys.argv[1])
-        login(CREDENTIALS)
-    else:
-        login()

+ 0 - 73
rival_regions_wrapper/functions.py

@@ -1,73 +0,0 @@
-def create_article(
-        self,
-        title,
-        article,
-        article_lang="nl",
-        paper_id=0,
-        category='0',
-        region="4001"
-):
-    """Create new article"""
-    self.session.get('http://rivalregions.com/#overview')
-    response = self.session.post("http://rivalregions.com/news/post", data={
-        'c': self.var_c,
-        'newspaper': paper_id,
-        'category': category,
-        'paper': article,
-        'title': title,
-        'region': region
-    })
-
-def market_info(self, resource, r_id=False):
-    """
-    Returns a list of data about current resource market state.
-    In form price, amount selling, player id, player name string, total offers on market.
-    """
-
-    if not r_id:
-        res_id = self.resource_id[resource]
-    else:
-        res_id = resource
-    response = self.session.get(f'http://rivalregions.com/storage/market/{res_id}')
-    return self.parse_market_response(response, res_id)
-
-def get_all_market_info(self):
-    """Request all market info"""
-    session = sessions.FuturesSession(session=self.session)
-    results = {}
-    for type_ in self.resource_id:
-        if type_ == 'energy drink':
-            continue
-        results[type_] = session.get(
-            f'http://rivalregions.com/storage/market/{self.resource_id[type_]}?{self.var_c}'
-        )
-    for res in results:
-        result = results[res].result()
-        price, selling_amount, player_id, player_name, total_offers = \
-            self.parse_market_response(result, self.resource_id[res])
-        results[res] = {
-            'price': price,
-            'amount': selling_amount,
-            'player_id': player_id,
-            'player_name': player_name,
-            'total_offers':total_offers
-        }
-    return results
-
-@staticmethod
-def parse_market_response(response, res_id):
-    """Parse market response"""
-    price = re.search('<input price="(.*)" type', response.text).group(1)
-    selling_amount = re.search('<span max="(.*)" url="', response.text).group(1)
-    player_id = re.search(
-        '<span action="slide/profile/(.*)" class="storage_see pointer dot hov2', response.text
-    ).group(1)
-    player_name = re.search(
-        f'<span action="slide/profile/{player_id}" class="storage_see pointer dot hov2">(.*)</span>',
-        response.text
-    ).group(1)
-    total_offers = re.search(
-        f'Best offer out of <span action="storage/listed/{res_id}" class="storage_see pointer hov2"><span class="dot">(.*)</span></span>:',
-        response.text
-    ).group(1)
-    return price, selling_amount, player_id, player_name, total_offers

+ 0 - 5
template_credentials.json

@@ -1,5 +0,0 @@
-{
-	"login_method": "google",
-	"username": "smitj",
-	"password": "arst123"
-}