def test_get_user_from_forwarded_message(opsdroid): response = { "update_id": 639974077, "message": { "message_id": 31, "from": { "id": 100000, "is_bot": False, "first_name": "Telegram" }, "chat": { "id": -10014170000, "title": "Opsdroid-test Chat", "type": "supergroup", }, "date": 1603827368, "forward_from_chat": { "id": -10014740000, "title": "Opsdroid-test", "type": "channel", }, "forward_from_message_id": 15, "forward_signature": "Fabio Rosado", "forward_date": 1603827365, "text": "hi", }, } connector = ConnectorTelegram(connector_config, opsdroid=opsdroid) user, user_id = connector.get_user(response, "Opsdroid!") assert user == "Fabio Rosado" assert user_id == 100000
def test_get_user_from_username(opsdroid): response = { "update_id": 639974077, "message": { "message_id": 31, "from": { "id": 100000, "is_bot": False, "username": "******" }, "chat": { "id": -10014170000, "title": "Opsdroid-test Chat", "type": "supergroup", }, "date": 1603827368, "text": "hi", }, } connector = ConnectorTelegram(connector_config, opsdroid=opsdroid) user, user_id = connector.get_user(response, "") assert user == "FabioRosado" assert user_id == 100000
def test_get_user_from_channel_without_signature(opsdroid): response = { "update_id": 639974076, "channel_post": { "message_id": 16, "chat": { "id": -1001474700000, "title": "Opsdroid-test", "type": "channel" }, "date": 1603827365, "text": "hi", }, } connector = ConnectorTelegram(connector_config, opsdroid=opsdroid) user, user_id = connector.get_user(response, "Opsdroid!") assert user == "Opsdroid!" assert user_id == 16