我可以使用这个打字稿功能成功地向信使用户发送消息:
import env from "env-var";
import superagent from "superagent";
import prefix from "superagent-prefix";
const PAGE_ACCESS_TOKEN = env.get("PAGE_ACCESS_TOKEN").required().asString();
const agent = superagent.agent()
.use(prefix("https://graph.facebook.com/v11.0"))
.query({access_token: PAGE_ACCESS_TOKEN})
.accept("application/json")
.type("application/json");
/**
* Sends a text message via the messenger platform.
* @param message The message text. Previews will not be shown for the URLs in this field.
* @param psid The page-scoped user ID (PSID) of the message recipient.
* @param messaging_type The messaging type of the message being sent.
*/
export async function sendTextMessage(
message: string,
psid: string,
messaging_type: MessagingType = "RESPONSE",
) {
const response = await agent
.post("/me/messages")
.send({
messaging_type: messaging_type,
recipient: {id: psid},
message: {text: message},
});
return response.body as SendAPIResponse;
}
我可以像这样使用它:
const psid = "<Page scoped id for the target user>";
const message = [
"- المرجو اختيار اللغة.",
"- Please choose a language.",
"- Veuillez choisir une langue.",
].join("\n");
void sendTextMessage(message, psid);
我的问题是,当我发送上述消息时,文本对齐混乱:
我希望阿拉伯语句子从右到左对齐,其他句子从左到右对齐。
我怎样才能做到这一点?