I have a method reportMessage:
async reportMessage(channelId: string, messageId: number, reason: ReportReason, comment?: string) {
let reasonApi: Api.TypeReportReason;
switch (reason) {
case ReportReason.SPAM:
reasonApi = new Api.InputReportReasonSpam();
break;
case ReportReason.VIOLENCE:
reasonApi = new Api.InputReportReasonViolence();
break;
case ReportReason.PORNOGRAPHY:
reasonApi = new Api.InputReportReasonPornography();
break;
case ReportReason.COPYRIGHT:
reasonApi = new Api.InputReportReasonCopyright();
break;
case ReportReason.CHILD_ABUSE:
reasonApi = new Api.InputReportReasonChildAbuse();
break;
case ReportReason.FAKE:
reasonApi = new Api.InputReportReasonFake();
break;
case ReportReason.OTHER:
default:
reasonApi = new Api.InputReportReasonOther();
break;
}
return this.handleCall(
(client) =>
client.invoke(
new Api.messages.Report({
peer: channelId,
id: [messageId],
option: reasonApi.getBytes(),
message: comment || "",
})
),
{ name: "reportMessage" }
);
}
When I try to call the method, telegram returns me an error: OPTION_INVALID
I'm not sure if I'm passing the correct value in the option field, but I can't find any information on what it should look like.
Based on the documentation I tried to provide reason field instead of option:
async reportMessage(channelId: string, messageId: number, reason: ReportReason, comment?: string) {
let reasonApi: Api.TypeReportReason;
switch (reason) {
case ReportReason.SPAM:
reasonApi = new Api.InputReportReasonSpam();
break;
case ReportReason.VIOLENCE:
reasonApi = new Api.InputReportReasonViolence();
break;
case ReportReason.PORNOGRAPHY:
reasonApi = new Api.InputReportReasonPornography();
break;
case ReportReason.COPYRIGHT:
reasonApi = new Api.InputReportReasonCopyright();
break;
case ReportReason.CHILD_ABUSE:
reasonApi = new Api.InputReportReasonChildAbuse();
break;
case ReportReason.FAKE:
reasonApi = new Api.InputReportReasonFake();
break;
case ReportReason.OTHER:
default:
reasonApi = new Api.InputReportReasonOther();
break;
}
return this.handleCall(
(client) =>
client.invoke(
new Api.messages.Report({
peer: channelId,
id: [messageId],
reason: reasonApi,
message: comment || "",
})
),
{ name: "reportMessage" }
);
}
But in this case I have an error:
I also tried to create Buffer manually but failed again
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744791517a4593943.html
评论列表(0条)