Skip to content

Commit 8694907

Browse files
douglas-reidDouglas Reid
andauthored
fix(telegram): ensure proper bot API base (#557)
I _think_ that in the refactor in 05a8f0e the behavior of the base API for Telegram became to use a `/` in between `bot` and the supplied token. Per https://core.telegram.org/bots/api#making-requests, the API base should be: `https://api.telegram.org/bot<token>/METHOD_NAME` Note the lack of `/` between `bot` and `<token>` --------- Co-authored-by: Douglas Reid <doug@steamship.com>
1 parent c6c880d commit 8694907

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

src/steamship/agents/mixins/transports/telegram.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ def get_api_root(self) -> Optional[str]:
296296
# This is a special case for our testing pipeline -- it contains a mock Telegram server.
297297
return api_base
298298
else:
299-
return f"{api_base}{bot_token}"
299+
return f"{api_base[:-1]}{bot_token}"
300300
else:
301301
return None
302302

tests/steamship_tests/agents/transports/test_telegram.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
from steamship_tests.utils.deployables import deploy_package
66

77
from steamship import File, PackageInstance, Steamship
8+
from steamship.agents.mixins.transports.telegram import TelegramTransport, TelegramTransportConfig
9+
from steamship.agents.service.agent_service import AgentService
810

911
config_template = {
1012
"telegram_token": {"type": "string", "default": ""},
@@ -13,6 +15,17 @@
1315
}
1416

1517

18+
def test_telegram_api_base():
19+
with Steamship.temporary_workspace() as client:
20+
transport = TelegramTransport(
21+
client=client,
22+
agent_service=AgentService(client=client),
23+
config=TelegramTransportConfig(),
24+
)
25+
transport.bot_token = "TOKEN" # noqa: S105
26+
assert transport.get_api_root() == "https://api.telegram.org/botTOKEN"
27+
28+
1629
@pytest.mark.usefixtures("client")
1730
def test_telegram(client: Steamship):
1831

0 commit comments

Comments
 (0)