dmcallejo / ASFBot

Control your ArchiSteamFarm with Telegram
GNU General Public License v3.0
42 stars 10 forks source link

Bot won't start #19

Closed Fluffy41 closed 7 months ago

Fluffy41 commented 7 months ago

Hey,

so as seen in the Logs the Bot just won't start. Did I do anything wrong?

Thanks for any help

Logs:

Traceback (most recent call last):
  File "/bot/bot.py", line 86, in <module>
    args.proxy = args.proxy.strip()
AttributeError: 'NoneType' object has no attribute 'strip'

Compose File:

version: '3.2'
services:
  asf:
    image: justarchi/archisteamfarm
    container_name: asf
    hostname: asf
    restart: unless-stopped
    environment:
      - ASF_ARGS=--server
    ports:
      - 1242:1242
    volumes:

      - /var/lib/docker/volumes/asf/_data/ASF/config:/app/config
      - /var/lib/docker/volumes/asf/_data/ASF/plugins:/app/plugins/custom
  asfbot:
    image: ghcr.io/dmcallejo/asfbot
    container_name: asfbot
    hostname: asfbot
    restart: unless-stopped
    command: --host asf
    environment:
      - TELEGRAM_BOT_TOKEN='*'
      - TELEGRAM_USER_ALIAS='*'
      - ASF_IPC_HOST='*'
      - ASF_IPC_PORT='*'
      - ASF_IPC_PASSWORD='*'
dmcallejo commented 7 months ago

Hello, No, you didn't do anything wrong, there's a bug in the code as the proxy argument isn't required so it must be checked it is not None before using it.

I don't understand right now why this bug has not happened to me as I don't use a proxy.

Anyway, the fix should be easy, just a if args.proxy: in the previous line should do.

Feel free to apply for a PR if you like, either way it will be fixed tomorrow as it is really late in my timezone and I have to wake up early for work.

Thank you for submitting the issue! Cheers

On Wed, Jan 3, 2024, 22:07 Fluffy41 @.***> wrote:

Hey,

so as seen in the Logs the Bot just won't start. Did I do anything wrong?

Thanks for any help

Logs:

Traceback (most recent call last): File "/bot/bot.py", line 86, in args.proxy = args.proxy.strip() AttributeError: 'NoneType' object has no attribute 'strip'

Compose File:

version: '3.2' services: asf: image: justarchi/archisteamfarm container_name: asf hostname: asf restart: unless-stopped environment:

  • ASF_ARGS=--server ports:

  • 1242:1242 volumes:

  • /var/lib/docker/volumes/asf/_data/ASF/config:/app/config

  • /var/lib/docker/volumes/asf/_data/ASF/plugins:/app/plugins/custom asfbot: image: ghcr.io/dmcallejo/asfbot container_name: asfbot hostname: asfbot restart: unless-stopped command: --host asf environment:

  • TELEGRAM_BOT_TOKEN='*'

  • TELEGRAM_USER_ALIAS='*'

  • ASF_IPC_HOST='*'

  • ASF_IPC_PORT='*'

  • ASF_IPC_PASSWORD='*'

— Reply to this email directly, view it on GitHub https://github.com/dmcallejo/ASFBot/issues/19, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA4K7RJ7OASLPDOVN5PQW23YMXCCXAVCNFSM6AAAAABBL7WAKSVHI2DSMVQWIX3LMV43ASLTON2WKOZSGA3DINRUHA3DMNI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

dmcallejo commented 7 months ago

@Fluffy41 Bug should be fixed now. Please let me know if it works for you so I can close the issue! Thank you!

Fluffy41 commented 7 months ago

So that's what my Logs say now:

raceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 434, in prepare_url
    scheme, auth, host, port, path, query, fragment = parse_url(url)
  File "/usr/local/lib/python3.10/site-packages/urllib3/util/url.py", line 451, in parse_url
    raise LocationParseError(source_url) from e
urllib3.exceptions.LocationParseError: Failed to parse: http://'10.0.0.1':'1242'/Api/ASF
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/bot/IPCProtocol/__init__.py", line 36, in get
    response = self.session.get(url, params=parameters)
  File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 602, in get
    return self.request("GET", url, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 575, in request
    prep = self.prepare_request(req)
  File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 486, in prepare_request
    p.prepare(
  File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 368, in prepare
    self.prepare_url(url, params)
  File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 436, in prepare_url
    raise InvalidURL(*e.args)
requests.exceptions.InvalidURL: Failed to parse: http://'10.0.0.1':'1242'/Api/ASF
2024-01-04 16:35:27,646 - ASFBot - INFO - ASF Instance replied: Failed to parse: http://'10.0.0.1':'1242'/Api/ASF
2024-01-04 16:35:27,646 - ASFBot - WARNING - ASF Instance message was unsuccesful. {'Success': False, 'Message': "Failed to parse: http://'10.0.0.1':'1242'/Api/ASF"}
2024-01-04 16:35:27,837 - ASFBot - ERROR - A request to the Telegram API was unsuccessful. Error code: 404. Description: Not Found
Traceback (most recent call last):
  File "/bot/bot.py", line 227, in <module>
    bot.polling(none_stop=True)
  File "/usr/local/lib/python3.10/site-packages/telebot/__init__.py", line 1042, in polling
    logger.info('Starting your bot with username: [@%s]', self.user.username)
  File "/usr/local/lib/python3.10/site-packages/telebot/__init__.py", line 275, in user
    self._user = self.get_me()
  File "/usr/local/lib/python3.10/site-packages/telebot/__init__.py", line 1228, in get_me
    result = apihelper.get_me(self.token)
  File "/usr/local/lib/python3.10/site-packages/telebot/apihelper.py", line 198, in get_me
    return _make_request(token, method_url)
  File "/usr/local/lib/python3.10/site-packages/telebot/apihelper.py", line 164, in _make_request
    json_result = _check_result(method_name, result)
  File "/usr/local/lib/python3.10/site-packages/telebot/apihelper.py", line 191, in _check_result
    raise ApiTelegramException(method_name, result, result_json)
telebot.apihelper.ApiTelegramException: A request to the Telegram API was unsuccessful. Error code: 404. Description: Not Found
2024-01-04 16:35:27,847 - ASFBot - CRITICAL - A request to the Telegram API was unsuccessful. Error code: 404. Description: Not Found
dmcallejo commented 7 months ago

Looks like you're adding extra quotes to your configuration parameters.

May I see how are you using the bot and inputting its configuration? Are you using docker or standalone?

Fluffy41 commented 7 months ago

Well im using Docker (Portainer) and thats my Compose File:

version: '3.2'
services:
  asf:
    image: justarchi/archisteamfarm
    container_name: asf
    hostname: asf
    restart: unless-stopped
    environment:
      - ASF_ARGS=--server
    ports:
      - 1242:1242
    volumes:

      - /var/lib/docker/volumes/asf/_data/ASF/config:/app/config
      - /var/lib/docker/volumes/asf/_data/ASF/plugins:/app/plugins/custom
  asfbot:
    image: ghcr.io/dmcallejo/asfbot
    container_name: asfbot
    hostname: asfbot
    restart: unless-stopped
    command: --host asf
    environment:
      - TELEGRAM_BOT_TOKEN='*'
      - TELEGRAM_USER_ALIAS='*'
      - ASF_IPC_HOST='*'
      - ASF_IPC_PORT='*'
      - ASF_IPC_PASSWORD='*'

ASF seems fine: image

IPC Config:

GNU nano 7.2                                                                                          IPC.config                                                                                                    
{
        "Kestrel": {
                "Endpoints": {
                        "HTTP": {
                                "Url": "http://*:1242"
                        }
                }
        }
}

ASF.json: GNU nano 7.2 ASF.json

{
  "Headless": true,
  "IPCPassword": "1234",
  "SteamOwnerID": *,
  "SteamTokenDumperPluginEnabled": true,
  "EnableFreePackages": true,
  "IPCPrefixes": [
    "http://*:1242/"
  ]
}
dmcallejo commented 7 months ago

Sorry I didn' t see the compose file in the first comment.

Try to add the environment variables without the single quote: '

    environment:
      - TELEGRAM_BOT_TOKEN=*
      - TELEGRAM_USER_ALIAS=*
      - ASF_IPC_HOST=*
      - ASF_IPC_PORT=*
      - ASF_IPC_PASSWORD=*

You either quote the whole environment key=value or none of it. There might be a typo in the sample compose...

Fluffy41 commented 7 months ago

Docker Logs:

2024-01-04 22:45:42,758 - ASFBot - INFO - Starting up bot...
2024-01-04 22:47:58,014 - ASFBot.IPCProtocol - ERROR - Error Requesting http://10.0.0.1:1242/Api/ASF with parameters {}
2024-01-04 22:47:58,014 - ASFBot.IPCProtocol - ERROR - HTTPConnectionPool(host='10.0.0.1', port=1242): Max retries exceeded with url: /Api/ASF (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0xffff7fb66110>, 'Connection to 10.0.0.1 timed out. (connect timeout=None)'))
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 203, in _new_conn
    sock = connection.create_connection(
  File "/usr/local/lib/python3.10/site-packages/urllib3/util/connection.py", line 85, in create_connection
    raise err
  File "/usr/local/lib/python3.10/site-packages/urllib3/util/connection.py", line 73, in create_connection
    sock.connect(sa)
TimeoutError: [Errno 110] Operation timed out
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 790, in urlopen
    response = self._make_request(
  File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 496, in _make_request
    conn.request(
  File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 395, in request
    self.endheaders()
  File "/usr/local/lib/python3.10/http/client.py", line 1278, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.10/http/client.py", line 1038, in _send_output
    self.send(msg)
  File "/usr/local/lib/python3.10/http/client.py", line 976, in send
    self.connect()
  File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 243, in connect
    self.sock = self._new_conn()
  File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 212, in _new_conn
    raise ConnectTimeoutError(
urllib3.exceptions.ConnectTimeoutError: (<urllib3.connection.HTTPConnection object at 0xffff7fb66110>, 'Connection to 10.0.0.1 timed out. (connect timeout=None)')
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 486, in send
    resp = conn.urlopen(
  File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 844, in urlopen
    retries = retries.increment(
  File "/usr/local/lib/python3.10/site-packages/urllib3/util/retry.py", line 515, in increment
    raise MaxRetryError(_pool, url, reason) from reason  # type: ignore[arg-type]
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='10.0.0.1', port=1242): Max retries exceeded with url: /Api/ASF (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0xffff7fb66110>, 'Connection to 10.0.0.1 timed out. (connect timeout=None)'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/bot/IPCProtocol/__init__.py", line 36, in get
    response = self.session.get(url, params=parameters)
  File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 602, in get
    return self.request("GET", url, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 507, in send
    raise ConnectTimeout(e, request=request)
requests.exceptions.ConnectTimeout: HTTPConnectionPool(host='10.0.0.1', port=1242): Max retries exceeded with url: /Api/ASF (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0xffff7fb66110>, 'Connection to 10.0.0.1 timed out. (connect timeout=None)'))
2024-01-04 22:47:58,020 - ASFBot - ERROR - Couldn't communicate with ASF. Host: '10.0.0.1' Port: '1242' 
 expected string or bytes-like object

Maybe it's Because of ASF itself? Tried to open up the API itself and I get the 404 too: msedge_9wiVSj9kuZ

dmcallejo commented 7 months ago

The error in your screenshot looks more like a 401 because you might have your ASF api password protected.

Do you have ASF in another docker container? you might want to use the host "asf" or the service name you have given asf.

This is my configuration having ASF and ASFBot both in docker containers:

  asf:
    image: justarchi/archisteamfarm
    container_name: asf
    hostname: asf
    ports:
    - 1242:1242
    restart: unless-stopped
    environment:
    - ASF_ARGS=--server
    volumes:
    - /srv/ASF/config:/app/config

  asfbot:
    image: dmcallejo/asfbot
    container_name: asfbot
    hostname: asfbot
    depends_on: 
    - asf
    restart: unless-stopped
    environment:
    - ASF_IPC_HOST=asf
    - TELEGRAM_BOT_TOKEN=sample
    - TELEGRAM_USER_ALIAS=sample
    - ASF_IPC_PASSWORD=sample

As you can see, my ASFBot is pointing to host "asf" which is the name of the ASF instance service.

Fluffy41 commented 7 months ago

Amazing work you did there. Thanks so much, keep up the great Work. Can I somewhere donate a little to you?

You wasted my time on someone like me who doesn't know anything you deserve it :)

dmcallejo commented 7 months ago

You're very kind! No need for a donation, really. This is just a little hobby I -sometimes- do.

Thank you, you kept trying and in the end it worked and you learned something, that's a great attitude! Hope you like the bot and let me know if you find any other issue, as you already uncovered two!

Cheers and have a great weekend!