gpt4 book ai didi

flutter - 通过 Telegram Bot 发送错误消息Flutter

转载 作者:行者123 更新时间:2023-12-03 08:39:41 27 4
gpt4 key购买 nike

我尝试使用Catcher,这是我的代码

CatcherOptions debugOptions = CatcherOptions(SilentReportMode(), [
ConsoleHandler(),
HttpHandler(HttpRequestType.post,
Uri.parse("https://api.telegram.org/bot<TOKEN>/sendMessage?chat_id=-469322015&text="),
printLogs: true,
),

]);

Catcher(MyApp(), debugConfig: debugOptions, releaseConfig: releaseOptions);
一切都很好,但是我必须在此参数 /sendMessage?chat_id=-469322015&text="Here Error Message"中输入错误消息
请帮我怎么做

最佳答案

通过创建自己的ReportMode解决

class SilentReportMode extends ReportMode {
@override
void requestAction(Report report, BuildContext context) {
// no action needed, request is automatically accepted
print("HEREEEEE ======= ${report.error}");
try {
sendError(report);
} catch (e) {
}
super.onActionConfirmed(report);
}

Future sendError(Report report) async {
try {
Response response = await Dio().post('https://api.telegram.org/bot<TOKEN>/sendMessage?chat_id=-469322015&text=message: $report',
);

print("RESPONSE TELEGErammmmm ====== ${response.data}");
} catch (e) {
throw e;
}
}

@override
List<PlatformType> getSupportedPlatforms() =>
[PlatformType.Web, PlatformType.Android, PlatformType.iOS];
}

关于flutter - 通过 Telegram Bot 发送错误消息Flutter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62908513/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com