rveachkc / pymsteams

Format messages and post to Microsoft Teams.
https://pypi.org/project/pymsteams/
Apache License 2.0
426 stars 79 forks source link

Enhancement Request - Add support for message summary #13

Open orihartstein opened 6 years ago

orihartstein commented 6 years ago

In many cases a header is not needed for the message - today webhooks require either text or summary property for each message.

using summary property allows to remove the header and the summary will not be shown.

class connectorcard:

def text(self, mtext):
    self.payload["text"] = mtext

def title(self, mtitle):
    self.payload["title"] = mtitle

def summary(self,msummary):
    self.payload["summary"] = msummary
rveachkc commented 6 years ago

I tried a code modification, and could not see the summary appear on the teams card message.

image

Are you expecting to see the summary somewhere else?

>>> import pymsteams
>>> m = pymsteams.connectorcard(my_url)
>>> m.summary("test summary")
>>> m.title("test title")
>>> m.text("slkfjslkdfj ljsdflksjdf lksjdflskdjf  lksjdflksjdf  lkjsdflkjsdf lkjsdflksjdf  lskdjflskdjfsldf lkjsdflksdjflsdkjf  lkjsdflksdjf sldflkjsdf lksdjf lsdkjf sldkjf slkjf slkjf lskdjf lskj flsdkj f")
>>> m.send()
True
>>> pprint.pprint(m.payload)
{'summary': 'test summary',
 'text': 'slkfjslkdfj ljsdflksjdf lksjdflskdjf  lksjdflksjdf  lkjsdflkjsdf '
         'lkjsdflksjdf  lskdjflskdjfsldf lkjsdflksdjflsdkjf  lkjsdflksdjf '
         'sldflkjsdf lksdjf lsdkjf sldkjf slkjf slkjf lskdjf lskj flsdkj f',
 'title': 'test title'}

Source

orihartstein commented 6 years ago

I think, that text property is meant to visible as a text header for the message. if you don't want a header you can populate summary property - which is not visible.

so you fill text if you want visible and summary if you don't.

sample will give a card without header text

message.summary("this text is not visible") messageSection = pymsteams.cardsection()

messageSection.title("Section title") messageSection.activityTitle("my activity title {}".format( now )) messageSection.activitySubtitle("my activity subtitle") messageSection.activityImage("http://www.clker.com/cliparts/v/u/z/w/n/2/thumbsup-md.png") messageSection.activityText("This is my activity Text") messageSection.addFact("this", "is fine") messageSection.addFact("this is", "also fine") messageSection.text("This is my section text")

image

rveachkc commented 6 years ago

This method is now live in master. PyPI uploads are also now automated using CircleCI.

Is this good to close?