yihong0618 / tg_bing_dalle

Telegram bing bot DALL-E 3

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

missing 1 required positional argument: 'auth_cookie_SRCHHPGUSR'

hanwinbi opened this issue · comments

Hi yihong,

我在尝试使用 tg_bing_dalle 的时候使用命令 python3 tg_bot.py '${MY_TG_TOKEN}' '${MY_COOKIE}' 会出现形如

/Users/hanwin/Library/Python/3.9/lib/python/site-packages/urllib3/__init__.py:34: NotOpenSSLWarning: urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'LibreSSL 2.8.3'. See: https://github.com/urllib3/urllib3/issues/3020
  warnings.warn(
423604132
2023-10-28 19:52:13,869 (__init__.py:960 MainThread) ERROR - TeleBot: "Infinity polling exception: __init__() missing 1 required positional argument: 'auth_cookie_SRCHHPGUSR'"
2023-10-28 19:52:13,870 (__init__.py:962 MainThread) ERROR - TeleBot: "Exception traceback:
Traceback (most recent call last):
  File "/Users/hanwin/Library/Python/3.9/lib/python/site-packages/telebot/__init__.py", line 955, in infinity_polling
    self.polling(non_stop=True, timeout=timeout, long_polling_timeout=long_polling_timeout,
  File "/Users/hanwin/Library/Python/3.9/lib/python/site-packages/telebot/__init__.py", line 1043, in polling
    self.__threaded_polling(non_stop=non_stop, interval=interval, timeout=timeout, long_polling_timeout=long_polling_timeout,
  File "/Users/hanwin/Library/Python/3.9/lib/python/site-packages/telebot/__init__.py", line 1118, in __threaded_polling
    raise e
  File "/Users/hanwin/Library/Python/3.9/lib/python/site-packages/telebot/__init__.py", line 1074, in __threaded_polling
    self.worker_pool.raise_exceptions()
  File "/Users/hanwin/Library/Python/3.9/lib/python/site-packages/telebot/util.py", line 147, in raise_exceptions
    raise self.exception_info
  File "/Users/hanwin/Library/Python/3.9/lib/python/site-packages/telebot/util.py", line 90, in run
    task(*args, **kwargs)
  File "/Users/hanwin/Library/Python/3.9/lib/python/site-packages/telebot/__init__.py", line 6797, in _run_middlewares_and_handler
    if self._test_message_handler(handler, message):
  File "/Users/hanwin/Library/Python/3.9/lib/python/site-packages/telebot/__init__.py", line 6711, in _test_message_handler
    if not self._test_filter(message_filter, filter_value, message):
  File "/Users/hanwin/Library/Python/3.9/lib/python/site-packages/telebot/__init__.py", line 6752, in _test_filter
    return filter_value(message)
  File "/Users/hanwin/Dev/tg_bot.py", line 34, in reply_dalle_image
    i = ImageGen(bing_cookie)
TypeError: __init__() missing 1 required positional argument: 'auth_cookie_SRCHHPGUSR'

的错误

我另外尝试了直接使用python3 -m BingImageCreator -U '${MY_COOKIE}' --prompt 'hello' 可以正常的创建图片,我对cookie不是很了解,是SimpleCookie解析出错了嘛

'_IDET=MIExp=0; _EDGE_V=1; SRCHD=AF=NOFORM; 
SRCHUID=V=2&GUID=${REPLACEMENT}; 
ANON=A=81182B2CA748DD505745AB58FFFFFFFF; 
MUID=${REPLACEMENT}; MUIDB=${REPLACEMENT}; 
SnrOvr=X=rebateson; MMCASM=ID=${REPLACEMENT}; USRLOC=HS=1&ELOC=LAT=${REPLACEMENT}|LON=${REPLACEMENT}|N=${REPLACEMENT}|ELT=4|; WLS=C=804eeeaf21744e27&N=${REPLACEMENT}; _clck=1b83mx1|2|fg3|0|1390; _EDGE_S=SID=1CC1B5D2F24A6AA53B16A660F3426BD9&mkt=en-us&ui=zh-cn; 
EDGSRCHHPGUSR=udstone=Creative&udstoneopts=h3imaginative,gencontentv3,flxegctxv2; SNRHOP=I=&TS=; 
SRCHHPGUSR=${REPLACEMENT}; SRCHUSR=DOB=20230921&T=1698489169000; _Rwho=u=d; ipv6=${REPLACEMENT}

在cookie里确实存在SRCHHPGUSR字段

BR,
Hanwin

will close it if you succeed @hanwinbi

sorry, 需要安装的BingImageCreator依赖库安装之后,依然会出现相同的错误

有尝试过,这次出现了更多的错误,和您的代码无关,可能是我使用的macOS 13的关系,我手头没有可用的其他可用的系统,没法做别的尝试

Traceback (most recent call last):
  File "/Users/hanwin/Library/Python/3.9/lib/python/site-packages/telebot/__init__.py", line 955, in infinity_polling
    self.polling(non_stop=True, timeout=timeout, long_polling_timeout=long_polling_timeout,
  File "/Users/hanwin/Library/Python/3.9/lib/python/site-packages/telebot/__init__.py", line 1043, in polling
    self.__threaded_polling(non_stop=non_stop, interval=interval, timeout=timeout, long_polling_timeout=long_polling_timeout,
  File "/Users/hanwin/Library/Python/3.9/lib/python/site-packages/telebot/__init__.py", line 1118, in __threaded_polling
    raise e
  File "/Users/hanwin/Library/Python/3.9/lib/python/site-packages/telebot/__init__.py", line 1073, in __threaded_polling
    polling_thread.raise_exceptions()
  File "/Users/hanwin/Library/Python/3.9/lib/python/site-packages/telebot/util.py", line 108, in raise_exceptions
    raise self.exception_info
  File "/Users/hanwin/Library/Python/3.9/lib/python/site-packages/telebot/util.py", line 90, in run
    task(*args, **kwargs)
  File "/Users/hanwin/Library/Python/3.9/lib/python/site-packages/telebot/__init__.py", line 649, in __retrieve_updates
    updates = self.get_updates(offset=(self.last_update_id + 1),
  File "/Users/hanwin/Library/Python/3.9/lib/python/site-packages/telebot/__init__.py", line 623, in get_updates
    json_updates = apihelper.get_updates(self.token, offset, limit, timeout, allowed_updates, long_polling_timeout)
  File "/Users/hanwin/Library/Python/3.9/lib/python/site-packages/telebot/apihelper.py", line 321, in get_updates
    return _make_request(token, method_url, params=payload)
  File "/Users/hanwin/Library/Python/3.9/lib/python/site-packages/telebot/apihelper.py", line 156, in _make_request
    result = _get_req_session().request(
  File "/Users/hanwin/Library/Python/3.9/lib/python/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
  File "/Users/hanwin/Library/Python/3.9/lib/python/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
  File "/Users/hanwin/Library/Python/3.9/lib/python/site-packages/requests/adapters.py", line 501, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
"
2023-10-28 21:37:33,148 (__init__.py:960 MainThread) ERROR - TeleBot: "Infinity polling exception: HTTPSConnectionPool(host='api.telegram.org', port=443): Max retries exceeded with url: /bot6621335900:AAGT-8r8fn26tkAaadMupHe1HSy95AbBZbE/getUpdates?offset=376095882&timeout=20 (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1129)')))"
2023-10-28 21:37:33,149 (__init__.py:962 MainThread) ERROR - TeleBot: "Exception traceback:
Traceback (most recent call last):
  File "/Users/hanwin/Library/Python/3.9/lib/python/site-packages/urllib3/connectionpool.py", line 468, in _make_request
    self._validate_conn(conn)
  File "/Users/hanwin/Library/Python/3.9/lib/python/site-packages/urllib3/connectionpool.py", line 1097, in _validate_conn
    conn.connect()
  File "/Users/hanwin/Library/Python/3.9/lib/python/site-packages/urllib3/connection.py", line 642, in connect
    sock_and_verified = _ssl_wrap_socket_and_match_hostname(
  File "/Users/hanwin/Library/Python/3.9/lib/python/site-packages/urllib3/connection.py", line 783, in _ssl_wrap_socket_and_match_hostname
    ssl_sock = ssl_wrap_socket(
  File "/Users/hanwin/Library/Python/3.9/lib/python/site-packages/urllib3/util/ssl_.py", line 471, in ssl_wrap_socket
    ssl_sock = _ssl_wrap_socket_impl(sock, context, tls_in_tls, server_hostname)
  File "/Users/hanwin/Library/Python/3.9/lib/python/site-packages/urllib3/util/ssl_.py", line 515, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/ssl.py", line 1040, in _create
    self.do_handshake()
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:1129)

您可以close,我在有新的尝试之后会在下面更新。Thanks for your effort.

@hanwinbi try pyenv

Thanks for your suggestion, the problem is solved. FYI: there is a wrong error message when /prompt command with nothing.

Screenshot 2023-10-28 at 22 12 08