Object of type InputMediaDocument is not JSON serializable, i tried to send file over telegram bot - python-telegram-bot

query.edit_message_text(InputMediaDocument("https://t.me/aastuchem/125"))
TypeError: Object of type InputMediaDocument is not JSON serializable

You can't add a document to a text message that didn't have a document in it before. To edit the document in a message that does have a document in it, you'll have to use query.edit_message_media and note that providing a link to a telegram message doesn't work. See also this wiki entry.

Related

Go-Mail multiple recipients and attachment

I am trying to make an email service using go-mail library and made it working. However there are few challenges that i am unable to solve
I have the struct for form data-
type SendMailBody struct {
EmailTo []string `form:"sendTo"`
Subject string `form:"subject"`
Body string `form:"body"`
}
The form data that i am sending to the API is
subject: Notification
sendTo:["abc#gmail.com", "xyz#gmail.com"]
body:You have been notified
Challenges-
If I pass a single email in "sendTO", It is working fine. But after passing the slice of emails, it is unable to send emails to the recepients. How can i make it work?
If I pass the attachment through Form data, how can I attach it with the mail. In documentation, it is mentioned that we can do it like that "m.Attach("/tmp/image.jpg")" . But how should i do it if i pass the attachment via form data in API
Please guide me through that.
Some more details are needed to help here. In particular which go-mail are you using?
For 1.)
If you refer to https://github.com/wneessen/go-mail, using Msg.To() should work fine with multiple recipient. See the documentation at: https://pkg.go.dev/github.com/wneessen/go-mail#Msg.To
If you refer to https://github.com/go-mail/mail, there is Message.SetAddressHeader() (https://pkg.go.dev/github.com/go-mail/mail?utm_source=godoc#Message.SetAddressHeader) which does not support multiple recipient addresses. You would need to use Message.SetHeaders() for the "To"-header instead (https://pkg.go.dev/github.com/go-mail/mail?utm_source=godoc#Message.SetHeaders).
For 2.)
This totally depends on how you read the attachment data (and again also on the go-mail library you are using). https://github.com/wneessen/go-mail has different ways of attaching and embedding files (i. e. from a local file, from embedFS, from an io.Reader...)

How do i get body of message when using keyword mentions in teams

in automate i have a flow. I am using "When keywords are mentioned". the keyword i entered is "test"
I Selected, the team,channel,etc... all correctly.
when someone types "the test is a success". in that channel. how do i get the full string "the test is a success"?
I have tried a few operations "get Messages", also tried a few dynamic content options and a few triggeroutput variations. all either are blank or provide a long json string with subscription,channelId,teamId,etc. but not the string I am trying to get.
The Get message details action should help you ...
In the body of the response, you'll clearly see the text that was entered to invoke the trigger.
Use Get message details, you will get message detail of that reply message. Then get your text with expression like this:
outputs('Get_message_details')?['body']['body']['plainTextContent']

How to turn message into a string

Can I turn a message into a string? I've tried just using the variable message to do that but it doesn't seem to work. I've tried...
print(message)
and all it told me was the message id and sender, and not the raw text or content.
You're looking for message.content. Just printing out message will give you the attributes and such values that you'll have access to.
If you're planning on seeing the "clean" version of the content, if it has mentions of users or channels in it, you can instead use the message.clean_content attribute.
See the references for more info on the attributes of the Message object.
References:
Message.content
Message.clean_content

Get stringified object instead of string with text in when Clicked on Quick reply in FB Messenger Channel (BotFramework v3, Nodejs)

Today, my bot stopped responding to me when clicking on quick replies in FB Messenger. Instead of getting the payload as a string, it now returns a stringified object with extra fields.
I'm using a bot with a custom dynamic dialog and creating SuggestedAction like this:
choices.push(builder.CardAction.postBack(session, "title=Name&params=Some", "Quick Reply Name"));
I used to receive the payload as a string "title=Name&params=Some" in Session object like the following:
session.message.text
But now, in session.message.text, I receive the following string:
"{\r\n \"type\": \"postBack\",\r\n \"value\": \"title=Name&params=Some\"\r\n}"
Has anybody else faced this same issue?
Is this coming from changes in Azure Bot Service? And if so, where can we follow the change log or release notes?
Since card action behavior is channel-specific it's much more likely that this relates to a change in the Facebook Messenger platform. You can view their changelog here: https://developers.facebook.com/docs/messenger-platform/changelog/
I can see there was a change on January 8th. It doesn't mention anything about postBack behavior, but it's still possible that there could be some unintended or undocumented changes that are responsible for the results you're seeing.
It looks like it should be a simple matter to deserialize the JSON and extract the value.
var payload = JSON.parse(session.message.text).value;

Is there a way to fetch the attachments of an email message?

I'm using the default net/pop class in order to fetch emails from a specific email account. From each message, I need to read all attachments and extract some data from them. But I can't find any way to achieve that! Seems like the POPMail class doesn't have a specific method to get the message's attachments.

Resources