Esempio n. 1
0
 async def message_pinned(self, event, channel):
     """Send a PinMessage event."""
     # Note that the pin_added event in slack doesn't have a "channel" keyword.
     return events.PinMessage(
         linked_event=event["item"],
         target=event["channel_id"],
         connector=self.connector,
         event_id=event["event_ts"],
         raw_event=event,
     )
Esempio n. 2
0
    async def message_pinned(self, event, channel):
        """Send a PinMessage event."""

        return events.PinMessage(
            linked_event=event["item"],
            target=event["channel_id"],
            connector=self.connector,
            event_id=event["event_ts"],
            raw_event=event,
        )
Esempio n. 3
0
async def test_send_pin_added(send_event, connector):
    message = events.Message(
        "An important message",
        user="******",
        user_id="U9S8JGF45",
        target="room",
        connector=connector,
        event_id="1582838099.000600",
    )

    event = events.PinMessage(target="room", linked_event=message)

    payload, response = await send_event(PINS_ADD, event)
    assert payload == {"channel": "room", "timestamp": "1582838099.000600"}
    assert response["ok"]
 async def test_send_pin_added(self):
     connector = ConnectorSlack({"token": "abc123"}, opsdroid=self.od)
     connector.slack.api_call = amock.CoroutineMock()
     await connector.send(
         events.PinMessage(
             target="an-existing-room",
             linked_event=events.Message(
                 "An important message",
                 user="******",
                 user_id="U9S8JGF45",
                 target="an-existing-room",
                 connector=connector,
                 event_id="1582838099.000600",
             ),
         ))
     connector.slack.api_call.assert_called_once_with(
         "pins.add",
         data={
             "channel": "an-existing-room",
             "timestamp": "1582838099.000600"
         },
     )
async def test_pinned_message_event(opsdroid):
    connector = ConnectorTelegram(connector_config, opsdroid=opsdroid)

    mock_request = amock.CoroutineMock()
    mock_request.json = amock.CoroutineMock()
    mock_request.json.return_value = {
        "update_id": 639974040,
        "message": {
            "message_id": 1247,
            "from": {
                "id": 6399348,
                "is_bot": False,
                "first_name": "Fabio",
                "last_name": "Rosado",
                "username": "******",
                "language_code": "en",
            },
            "chat": {
                "id": 6399348,
                "first_name": "Fabio",
                "last_name": "Rosado",
                "username": "******",
                "type": "private",
            },
            "date": 1603818326,
            "edit_date": 1603818330,
            "pinned_message": True,
        },
    }

    pinned_message = opsdroid_events.PinMessage(6399348, "Fabio", 6399348)

    await connector.telegram_webhook_handler(mock_request)

    assert "Fabio" in pinned_message.user
    assert pinned_message.target == 6399348
    assert pinned_message.user_id == 6399348