Skip to content

Commit

Permalink
[feat] default language to zh when using ESI_CHINA
Browse files Browse the repository at this point in the history
  • Loading branch information
a-tal committed Oct 2, 2018
1 parent 77a2c34 commit 333be0c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion esi_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,13 @@ def command(func=None, **kwargs):
def do_request(url, return_response=False):
"""Make a GET request, return the status code and json response."""

if url.startswith(ESI_CHINA) and "language" not in url:
headers = {"Accept-Language": "zh"}
else:
headers = {}

try:
res = SESSION.get(url)
res = SESSION.get(url, headers=headers)
except Exception as error:
LOG.warning("failed to request %s: %r", url, error)
return 499, "failed to request {}".format(url)
Expand Down
2 changes: 1 addition & 1 deletion esi_bot/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ def item(msg):

start = time.time()

if len(msg.args) != 1:
if not msg.args:
return "usage: !esi {} <id>".format(msg.command)

item_id = msg.args[0]
Expand Down

0 comments on commit 333be0c

Please sign in to comment.