From f2029a484eaebb89a18e49a03fa9b38654b5ed5e Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 3 Apr 2021 18:38:22 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20dispenser=20key=20selectio?= =?UTF-8?q?n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 2 +- royalnet_telethon/pda.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 9ffe0238..15f7f793 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "royalnet-telethon" -version = "0.1.4" +version = "0.1.5" description = "A Telethon-based frontend for the royalnet.engineer module." authors = ["Stefano Pigozzi "] license = "AGPL-3.0-or-later" diff --git a/royalnet_telethon/pda.py b/royalnet_telethon/pda.py index aa253ce0..4d862b61 100644 --- a/royalnet_telethon/pda.py +++ b/royalnet_telethon/pda.py @@ -87,11 +87,17 @@ class TelethonPDA: if self.mode == TelethonPDAMode.GLOBAL: return None elif self.mode == TelethonPDAMode.USER: - return event.from_id.user_id + if event.from_id: + return event.from_id.user_id + else: + return event.peer_id.user_id elif self.mode == TelethonPDAMode.CHAT: return event.chat_id elif self.mode == TelethonPDAMode.CHAT_USER: - return event.chat_id, event.from_id.user_id + if event.from_id: + return event.chat_id, event.from_id.user_id + else: + return event.chat_id, event.peer_id.user_id else: raise TypeError("Invalid mode")