Skip to content

Commit 1bbcf0c

Browse files
author
Pietro Albini
committed
Fix inability to send messages to channels
I completly forgot to look at channels when I changed the way to send messages to other chats, and they were broken. This commit brings compatibility again. Sorry :( Fixes: GH-69
1 parent d884280 commit 1bbcf0c

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

botogram/bot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,5 +278,5 @@ def channel(name, api_key):
278278
"""Get a representation of a channel"""
279279
conn = api.TelegramAPI(api_key)
280280

281-
obj = objects.Chat({"id": 0, "type": "channel", "username": name}, conn)
281+
obj = conn.call("getChat", {"chat_id": name}, expect=objects.Chat)
282282
return obj

botogram/objects/mixins.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,7 @@ def _get_call_args(self, reply_to, extra, notify=True):
4545
if hasattr(reply_to, "message_id"):
4646
reply_to = reply_to.message_id
4747

48-
# Get the correct chat_id
49-
# There is an hasattr because User objects doesn't have any type
50-
if hasattr(self, "type"):
51-
chat_id = self.username if self.type == "channel" else self.id
52-
else:
53-
chat_id = self.id
54-
55-
args = {"chat_id": chat_id}
48+
args = {"chat_id": self.id}
5649
if reply_to is not None:
5750
args["reply_to_message_id"] = reply_to
5851
if extra is not None:

docs/changelog/0.3.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ Changelog of botogram 0.3.x
77

88
Here you can find all the changes in the botogram 0.3.x releases.
99

10+
.. _changelog-0.3.2:
11+
12+
botogram 0.3.2
13+
==============
14+
15+
*Bugfix release, not yet released.*
16+
17+
* Fix inability to send messages to channels (`issue 69`_)
18+
19+
.. _issue 69: https://github.com/pietroalbini/botogram/issues/69
20+
1021
.. _changelog-0.3.1:
1122

1223
botogram 0.3.1

0 commit comments

Comments
 (0)