0

I am trying to run a ban event inside an async function

async def ban_function(username):
  global bot

  headers = {
    'Authorization': f'Bearer {os.environ["TMI_TOKEN"]}',
    'Client-ID': os.environ['CLIENT_ID']
  }

  response = requests.get('https://api.twitch.tv/helix/users', headers=headers)

  data = response.json()

  user_id = data['data'][0]['id']
    
  urusername= data['data'][0]['login']
  

  url = f"https://api.twitch.tv/helix/users?login={str(username)}"
    
  response = requests.get(url, headers=headers)
  data = response.json()
  ban_id = data["data"][0]["id"]
  print(data['data'][0]['login'])

  partuser = bot.create_user(user_id,str(urusername))

  await partuser.ban_user(os.environ['TMI_TOKEN'],user_id,ban_id,"banned")

However, the await event is giving me these errors:

Task exception was never retrieved future: <Task finished name='Task-3241' coro=<AsyncServer._handle_event_internal() done, defined at exception=ClientConnectorSSLError(ConnectionKey(host='api.twitch.tv', port=443, is_ssl=True, ssl=None, proxy=None, proxy_auth=None, proxy_headers_hash=None), SSLError(1, '[SSL: DECRYPTION_FAILED_OR_BAD_RECORD_MAC] decryption failed or bad record mac (_ssl.c:1129)'))>

ssl.SSLError: [SSL: DECRYPTION_FAILED_OR_BAD_RECORD_MAC] decryption failed or bad record mac (_ssl.c:1129)

The above exception was the direct cause of the following exception:

aiohttp.client_exceptions.ClientConnectorSSLError: Cannot connect to host api.twitch.tv:443 ssl:default [[SSL: DECRYPTION_FAILED_OR_BAD_RECORD_MAC] decryption failed or bad record mac (_ssl.c:1129)]

ssl.SSLError: [SSL: BAD_SIGNATURE] bad signature (_ssl.c:1129)

Any help would be greatly appreciated thanks

0 Answers0