Beispiel #1
0
def account_SelectionForBill_card():
    card = ThumbnailCard(
        title="Account List",
        text="Please select an account from which you want to pay the bill",

        images=[CardImage(url="")],
        buttons=[
            CardAction(
                type=ActionTypes.im_back,
                title="Savings Account xxxxxxxxx4567 \n Opened date: 05/10/2010 \n Balance is $112.02",
                text="Balance is $112.02",
                display_text="Balance is $112.02",
                value="Debit from xxxxxxxxx4567",
            ),
            CardAction(
                type=ActionTypes.im_back,
                title="Current Account xxxxxxxxx4566 \n Opened date: 05/10/2012 \n Balance is $0.00",
                text="Balance is $0.00",
                display_text="Balance is $0.00",
                value="Debit from xxxxxxxxx4566",
            ),
        ],
    )

    return card
Beispiel #2
0
def accountbalance_card():
    card = ThumbnailCard(
        title="Account Details",
        text="Please select an account to see last 10 transaction details",

        # images=[CardImage(url="https://www.iconfinder.com/data/icons/infographic-bar-16/512/17-512.png")],
        buttons=[
            CardAction(
                type=ActionTypes.im_back,
                title=
                "Savings Account xxxxxxxxx4567 \n Opened date: 05/10/2010 \n Balance is $112.02",
                text="Balance is $112.02",
                display_text="Balance is $112.02",
                value="xxxxxxxxx4567",
            ),
            CardAction(
                type=ActionTypes.im_back,
                title=
                "Current Account xxxxxxxxx4566 \n Opened date: 05/10/2012 \n Balance is $0.00",
                text="Balance is $0.00",
                display_text="Balance is $0.00",
                value="xxxxxxxxx4566",
            ),
        ],
    )

    return card
Beispiel #3
0
def mobile_confirmation_card():
    card = ThumbnailCard(
                title="",
                text="Please confirm if you want to pay the bill now?",

                images=[CardImage(url="https://images.app.goo.gl/voWF7ZpTWzJocoUw5")],
                buttons=[
                    CardAction(
                        type=ActionTypes.im_back,
                        title="Confirm",
                        text="Confirm",
                        display_text="Confirm",
                        value="Confirm",
                    ),
                    CardAction(
                        type=ActionTypes.im_back,
                        title="Cancel",
                        text="Cancel",
                        display_text="Cancel",
                        value="Cancel",
                    ),
                ],
            )

    return  card
Beispiel #4
0
    def create_tweet_card(self, tweet):
        card = ThumbnailCard(
            title=tweet.user.name,
            subtitle="@" + tweet.user.screen_name,
            text=tweet.text,
            images=[CardImage(url=tweet.user.profile_image_url)])

        return CardFactory.thumbnail_card(card)
Beispiel #5
0
def create_thumbnail_card() -> Attachment:
    card = ThumbnailCard(title="BotFramework Thumbnail Card", subtitle="Your bots — wherever your users are talking",
                         text="Build and connect intelligent bots to interact with your users naturally wherever"
                              " they are, from text/sms to Skype, Slack, Office 365 mail and other popular services.",
                         images=[CardImage(url="https://sec.ch9.ms/ch9/7ff5/"
                                               "e07cfef0-aa3b-40bb-9baa-7c9ef8ff7ff5/"
                                               "buildreactionbotframework_960.jpg")],
                         buttons=[CardAction(type=ActionTypes.open_url, title="Get Started",
                                             value="https://docs.microsoft.com/en-us/azure/bot-service/")])
    return CardFactory.thumbnail_card(card)
Beispiel #6
0
 def infoPlayer(self, player):
     P = CardFactory.thumbnail_card(
         ThumbnailCard(
             title=f'Player Name : {player}',
             text='\n\n'.join([
                 f'Money : {self.Player[player]["money"]}',
                 f'Item : {self.Item[self.Player[player]["item"]]["desc"] if self.Player[player]["item"] is not None else "nothing"}',
                 f'X-coord : {self.Player[player]["xpos"]}',
                 f'Y-coord : {self.Player[player]["ypos"]}'
             ])))
     return {'response': P}
 def create_thumbnail_card(
         self, step_context: WaterfallStepContext) -> Attachment:
     card = ThumbnailCard(
         title="Reservation Confirmed",
         text="Kudos!! A reservation has been made at " +
         step_context.values["Location"] + " branch on " +
         step_context.values["Date"] + " at " + step_context.values["Time"],
         images=[
             CardImage(
                 url=
                 "https://www.freepngimg.com/thumb/green_tick/27894-7-green-tick-transparent-background.png"
             )
         ],
     )
     return CardFactory.thumbnail_card(card)
 def create_thumbnail_card(
         self, step_context: WaterfallStepContext) -> Attachment:
     card = ThumbnailCard(
         title="Insurance Renewed",
         text="Your Policy Number: " + step_context.values["PolicyNumber"] +
         " has been renewed. \n New Policy number and details will be messaged to "
         + step_context.values["MobileNumber"],
         images=[
             CardImage(
                 url=
                 "https://www.freepngimg.com/thumb/green_tick/27894-7-green-tick-transparent-background.png"
             )
         ],
     )
     return CardFactory.thumbnail_card(card)
Beispiel #9
0
    def create_tweet_card(self, tweet):
        card = ThumbnailCard(
            title=tweet.user.name,
            subtitle="@" + tweet.user.screen_name,
            text=tweet.text,
            images=[CardImage(url=tweet.user.profile_image_url)]
            # buttons=[
            #     CardAction(
            #         type=ActionTypes.open_url,
            #         title="Open Tweet",
            #         value=tweet.user.url,
            #     )
            # ]
        )

        return CardFactory.thumbnail_card(card)
Beispiel #10
0
def create_thumbnail_card(mylist) -> Attachment:
    card = ThumbnailCard(
        title=mylist[0],
        subtitle=mylist[1],
        text="Rating: {} ({} ratings) \n\n Availability: {}".format(
            mylist[3], mylist[4], mylist[2]),
        images=[CardImage(url=mylist[6])],
        buttons=[
            CardAction(
                type=ActionTypes.open_url,
                title="Get directions",
                value=mylist[5],
            )
        ],
    )
    return CardFactory.thumbnail_card(card)
 def thumbnail_card(self) -> Attachment:
     card = ThumbnailCard()
     #card.images = [CardImage(url="https://pypi.org/static/images/logo-large.72ad8bf1.svg")]
     card.images = [
         ThumbnailUrl(
             url="https://pypi.org/static/images/logo-large.72ad8bf1.svg")
     ]
     card.title = "Bot builder sample card"
     card.subtitle = "SDK Version 4.9"
     card.text = "Thumbnail card is the one of the card type in Bot Framework"
     return CardFactory.thumbnail_card(card)
Beispiel #12
0
 async def on_teams_app_based_link_query(self, turn_context: TurnContext,
                                         query: AppBasedLinkQuery):
     hero_card = ThumbnailCard(
         title="Thumnnail card",
         text=query.url,
         images=[
             CardImage(
                 url=
                 "https://raw.githubusercontent.com/microsoft/botframework-sdk/master/icon.png"
             )
         ])
     attachments = MessagingExtensionAttachment(
         content_type=CardFactory.content_types.hero_card,
         content=hero_card)
     result = MessagingExtensionResult(attachment_layout="list",
                                       type="result",
                                       attachments=[attachments])
     return MessagingExtensionResponse(compose_extension=result)
Beispiel #13
0
 def create_thumbnail_card(self):
     card = ThumbnailCard(
         title="Seattle Foundation",
         subtitle="COVID-19 Response Fund",
         text="The COVID-19 Response Fund deploys resources to organizations supporting local "
         " workers and families most impacted by the coronavirus crisis.",
         images=[
             CardImage(
                 url="https://www.seattlefoundation.org/-/media/SeaFdn/Images/Common/sf_logo.gif"
             )
         ],
         buttons=[
             CardAction(
                 type=ActionTypes.open_url,
                 title="Make a donation",
                 value="https://www.seattlefoundation.org/communityimpact/civic-leadership/covid-19-response-fund",
             )
         ],
     )
     return CardFactory.thumbnail_card(card)
Beispiel #14
0
def create_thumbnail_card(title: str, subtitle: str,
                          text: str, url: str, elements_of_button: Button = []) -> Attachment:
    if len(elements_of_button) != 0:
        button = []
        for elem in elements_of_button:
            button.append(CardAction(
                type=ActionTypes.im_back,
                title=elem.title,
                value=elem.value,
            ))
        return CardFactory.thumbnail_card(ThumbnailCard(title=title,
                                                        subtitle=subtitle,
                                                        text=text,
                                                        images=[
                                                            CardImage(
                                                                url=url,
                                                            )
                                                        ],
                                                        buttons=button,
                                                        )
                                          )
Beispiel #15
0
 def create_poi_card(self):
     card = ThumbnailCard(
         title="Seattle POI",
         subtitle="COVID-19 Open Places",
         text=
         "The COVID-19 affected many Places of Interest, here is an updated map ",
         images=[
             CardImage(
                 url=
                 "https://www.google.com/maps/d/thumbnail?mid=1bwwdAoQe6Hoq6LFIhld3ZL7-JLg&hl=en"
             )
         ],
         buttons=[
             CardAction(
                 type=ActionTypes.open_url,
                 title="Access Map",
                 value=
                 "https://www.google.com/maps/place/Seattle,+Washington,+EE.+UU./@47.6129432,-122.4821475,11z/data=!3m1!4b1!4m5!3m4!1s0x5490102c93e83355:0x102565466944d59a!8m2!3d47.6062095!4d-122.3320708",
             )
         ],
     )
     return CardFactory.thumbnail_card(card)
Beispiel #16
0
def mobile_billDue_card():
    card = ThumbnailCard(
        title="Bill Payment Reminder",
        text=
        "Hey Steve, I found your Vodafone post paid bill for XXXXXXXX90 which is due in next 2 days.\n\n Would you like to pay it now?",
        images=[CardImage(url="https://images.app.goo.gl/voWF7ZpTWzJocoUw5")],
        buttons=[
            CardAction(
                type=ActionTypes.im_back,
                title="Yes",
                text="Yes",
                display_text="Yes",
                value="Yes, pay my mobile bill",
            ),
            CardAction(
                type=ActionTypes.im_back,
                title="No",
                text="No",
                display_text="No",
                value="No not now.",
            ),
        ],
    )
    return card
Beispiel #17
0
def create_thumbnail_card(cred, ementa) -> Attachment:
    card = ThumbnailCard(title="créditos: " + str(cred), subtitle="",
                         text=ementa,
                         images=[],
                         buttons=[])
    return CardFactory.thumbnail_card(card)
def generate_reply():
    data = get_api()
    # global_card= CardFactory.thumbnail_card(ThumbnailCard(
    #     title="Cộng đồng chung tay chống COVID-19",
    #     #text="""Total cases:\t{}\r\nBeing infected:\t{}\r\nDeaths:\t{}\r\nRecovered:\t{}\r\n""".format(str(data['global']['cases']),str(data['global']['infected']),str(data['global']['deaths']),str(data['global']['recovered'])),
    #     images=[
    #         CardImage(
    #             url="https://cdn.tuoitre.vn/zoom/188_117/2020/3/21/chot-phong-dich-ngoai-1584751358708692384877-crop-15847516489591463323519.jpg"
    #         )
    #     ],
    #     buttons=[
    #         CardAction(
    #             type=ActionTypes.open_url,
    #             title="Đọc thêm",
    #             value="https://tuoitre.vn/cong-dong-chung-tay-chong-covid-19-20200321074705891.htm",
    #         )
    #     ],
    # ))
    vietnam_card = CardFactory.thumbnail_card(
        ThumbnailCard(
            title="Việt Nam",
            text=
            """Total cases:\t{}\r\nBeing infected:\t{}\r\nDeaths:\t{}\r\nRecovered: \t{}\r\n"""
            .format(str(data['vietnam']['cases']),
                    str(data['vietnam']['infected']),
                    str(data['vietnam']['deaths']),
                    str(data['vietnam']['recovered'])),
            images=[
                CardImage(
                    url=
                    "https://cdn2.iconfinder.com/data/icons/world-flag-2/30/21-512.png"
                )
            ],
            buttons=[
                CardAction(
                    type=ActionTypes.open_url,
                    title="More information",
                    value="https://corona.kompa.ai/",
                )
            ],
        ))
    # news_list = requests.get('https://s1.tuoitre.vn/Handlers/Menu.ashx?c=getdata')
    # hot=news_list.json()['Data']['3'][0][0]
    # req=requests.get('https://tuoitre.vn/'+hot['Url'])
    # soup = BeautifulSoup(req.text, "html.parser")
    # content=soup.find('h2',class_='sapo').text[6:]
    url = 'https://tuoitre.vn/phong-chong-virus-corona-e583.htm'
    req = requests.get(url)
    soup = BeautifulSoup(req.text, "html.parser")
    news = soup.find('div', class_='name-news')
    content = news.find('p').text
    news = CardFactory.thumbnail_card(
        ThumbnailCard(
            title=news.find('a').text,
            text=content[:100] + '...',
            images=[
                CardImage(url=soup.find('img', class_='img212x132').get('src'))
            ],
            buttons=[
                CardAction(
                    type=ActionTypes.open_url,
                    title="Đọc thêm",
                    value='https://tuoitre.vn/' + news.find('a').get('href'),
                )
            ],
        ))
    reply = MessageFactory().list([])
    reply.attachment_layout = 'carousel'
    reply.attachments.append(vietnam_card)
    reply.attachments.append(news)
    return (reply, data['newest'])
    def test_should_create_thumbnail_card_attachment(self):
        card = ThumbnailCard(title='test')
        attachment = CardFactory.thumbnail_card(card)

        assert_attachment(attachment, CardFactory.content_types.thumbnail_card)
        assert attachment.content.title == 'test', 'wrong title.'
Beispiel #20
0
    async def _get_auth_or_search_result(
        self,
        turn_context: TurnContext,
        query: MessagingExtensionQuery,
        search_query: str,
    ) -> MessagingExtensionResponse:
        # When the Bot Service Auth flow completes, the action.State will contain
        # a magic code used for verification.
        magic_code = ""
        if query.state is not None:
            magic_code = query.state

        token_response = await turn_context.adapter.get_user_token(
            turn_context, self.connection_name, magic_code)
        if token_response is None or token_response.token is None:
            # There is no token, so the user has not signed in yet.

            # Retrieve the OAuth Sign in Link to use in the MessagingExtensionResult Suggested Actions
            sign_in_link = await turn_context.adapter.get_oauth_sign_in_link(
                turn_context, self.connection_name)
            return MessagingExtensionResponse(
                compose_extension=MessagingExtensionResult(
                    type="auth",
                    suggested_actions=MessagingExtensionSuggestedAction(
                        actions=[
                            CardAction(
                                type="openUrl",
                                value=sign_in_link,
                                title="Bot Service OAuth",
                            )
                        ]),
                ))
        # User is signed in, so use their token to search email via the Graph Client
        client = SimpleGraphClient(token_response.token)
        search_results = await client.search_mail_inbox(search_query)

        # Here we construct a ThumbnailCard for every attachment, and provide a HeroCard which will be
        # displayed if the user selects that item.
        attachments = []
        for message_meta in search_results:
            message = message_meta["_source"]
            message_from = message["from"] if "from" in message else None
            if message_from:
                subtitle = (f"{message_from['emailAddress']['name']},"
                            f"<{message_from['emailAddress']['address']}>")
            else:
                subtitle = ""

            hero_card = HeroCard(
                title=message["subject"] if "subject" in message else "",
                subtitle=subtitle,
                text=message["bodyPreview"]
                if "bodyPreview" in message else "",
            )

            thumbnail_card = CardFactory.thumbnail_card(
                ThumbnailCard(
                    title=subtitle,
                    subtitle=message["subject"],
                    images=[
                        CardImage(
                            url=
                            "https://botframeworksamples.blob.core.windows.net/samples"
                            "/OutlookLogo.jpg",
                            alt="Outlook Logo",
                        )
                    ],
                ))
            attachment = MessagingExtensionAttachment(
                content_type=CardFactory.content_types.hero_card,
                content=hero_card,
                preview=thumbnail_card,
            )
            attachments.append(attachment)

        return MessagingExtensionResponse(
            compose_extension=MessagingExtensionResult(
                type="result",
                attachment_layout="list",
                attachments=attachments))
    async def on_teams_messaging_extension_query(
            self,
            turn_context: TurnContext,
            query: MessagingExtensionQuery,  # pylint: disable=unused-argument
    ):
        search_query = str(query.parameters[0].value).strip()

        user_configuration = await self.user_config_property.get(
            turn_context, "UserConfiguration")
        if user_configuration is not None and "email" in user_configuration:
            # When the Bot Service Auth flow completes, the action.State will contain
            # a magic code used for verification.
            magic_code = ""
            if query.state is not None:
                magic_code = query.state

            token_response = await turn_context.adapter.get_user_token(
                turn_context, self.connection_name, magic_code)
            if token_response is None or token_response.token is None:
                # There is no token, so the user has not signed in yet.

                # Retrieve the OAuth Sign in Link to use in the MessagingExtensionResult Suggested Actions
                sign_in_link = await turn_context.adapter.get_oauth_sign_in_link(
                    turn_context, self.connection_name)
                return MessagingExtensionResponse(
                    compose_extension=MessagingExtensionResult(
                        type="auth",
                        suggested_actions=MessagingExtensionSuggestedAction(
                            actions=[
                                CardAction(
                                    type="openUrl",
                                    value=sign_in_link,
                                    title="Bot Service OAuth",
                                )
                            ]),
                    ))
            # User is signed in, so use their token to search email via the Graph Client
            client = SimpleGraphClient(token_response.token)
            search_results = await client.search_mail_inbox(search_query)

            # Here we construct a ThumbnailCard for every attachment, and provide a HeroCard which will be
            # displayed if the user selects that item.
            attachments = []
            for message_meta in search_results:
                message = message_meta["_source"]
                message_from = message["from"] if "from" in message else None
                if message_from:
                    subtitle = (f"{message_from['emailAddress']['name']},"
                                f"<{message_from['emailAddress']['address']}>")
                else:
                    subtitle = ""

                hero_card = HeroCard(
                    title=message["subject"] if "subject" in message else "",
                    subtitle=subtitle,
                    text=message["bodyPreview"]
                    if "bodyPreview" in message else "",
                )

                thumbnail_card = CardFactory.thumbnail_card(
                    ThumbnailCard(
                        title=subtitle,
                        subtitle=message["subject"],
                        images=[
                            CardImage(
                                url=
                                "https://botframeworksamples.blob.core.windows.net/samples"
                                "/OutlookLogo.jpg",
                                alt="Outlook Logo",
                            )
                        ],
                    ))
                attachment = MessagingExtensionAttachment(
                    content_type=CardFactory.content_types.hero_card,
                    content=hero_card,
                    preview=thumbnail_card,
                )
                attachments.append(attachment)

            return MessagingExtensionResponse(
                compose_extension=MessagingExtensionResult(
                    type="result",
                    attachment_layout="list",
                    attachments=attachments))

        # The user configuration is NOT set to search Email.
        if search_query is None:
            turn_context.send_activity(
                MessageFactory.text(
                    "You cannot enter a blank string for the search"))
            return

        search_results = self._get_search_results(search_query)

        attachments = []
        for obj in search_results:
            hero_card = HeroCard(title=obj["name"],
                                 tap=CardAction(type="invoke", value=obj))

            attachment = MessagingExtensionAttachment(
                content_type=CardFactory.content_types.hero_card,
                content=HeroCard(title=obj["name"]),
                preview=CardFactory.hero_card(hero_card),
            )
            attachments.append(attachment)
        return MessagingExtensionResponse(
            compose_extension=MessagingExtensionResult(
                type="result",
                attachment_layout="list",
                attachments=attachments))