mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-12 00:36:03 +00:00
Merge pull request #1258 from RockChinQ/feat/slack
feat: add slack adapter
This commit is contained in:
@@ -212,4 +212,19 @@ async def extract_b64_and_format(image_base64_data: str) -> typing.Tuple[str, st
|
||||
"""
|
||||
base64_str = image_base64_data.split(',')[-1]
|
||||
image_format = image_base64_data.split(':')[-1].split(';')[0].split('/')[-1]
|
||||
return base64_str, image_format
|
||||
return base64_str, image_format
|
||||
|
||||
|
||||
|
||||
async def get_slack_image_to_base64(pic_url:str, bot_token:str):
|
||||
headers = {"Authorization": f"Bearer {bot_token}"}
|
||||
try:
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.get(pic_url, headers=headers) as resp:
|
||||
image_data = await resp.read()
|
||||
return base64.b64encode(image_data).decode('utf-8')
|
||||
except Exception as e:
|
||||
raise(e)
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user