Ejemplo n.º 1
0
        public static async void DisableAutoLink(SoraMessage e)
        {
            QQGroupSetting data = await Database.FindAsync <QQGroupSetting>(x => x.Group == e.SourceGroup.Id);

            if (data == null || !data.SmartMinecraftLink)
            {
                await e.ReplyToOriginal("本群未启用该功能,无需禁用");

                return;
            }
            data.SmartMinecraftLink = false;
            await Database.UpdateAsync(data).ContinueWith(async x =>
            {
                if (x.Result > 0)
                {
                    await e.ReplyToOriginal("本群已成功禁用mojira智能解析功能");
                }
                else if (x.IsFaulted && x.Exception != null)
                {
                    await e.ReplyToOriginal(new StringBuilder()
                                            .AppendLine("因异常导致功能禁用失败,错误信息:")
                                            .Append(ConsoleLog.ErrorLogBuilder(x.Exception))
                                            .ToString());
                }
                else
                {
                    await e.ReplyToOriginal("因未知原因导致功能禁用失败,请稍后重试");
                }
            });
        }
Ejemplo n.º 2
0
        public static async void EnableAutoLink(SoraMessage e)
        {
            QQGroupSetting data = await Database.FindAsync <QQGroupSetting>(x => x.Group == e.SourceGroup.Id);

            if (data != null)
            {
                if (data.SmartPixivLink)
                {
                    await e.ReplyToOriginal("本群已启用该功能,无需再次启用");

                    return;
                }
                data.SmartPixivLink = true;
                await Database.UpdateAsync(data).ContinueWith(async x =>
                {
                    if (x.Result > 0)
                    {
                        await e.ReplyToOriginal("本群已成功启用pixiv智能解析功能");
                    }
                    else if (x.IsFaulted && x.Exception != null)
                    {
                        await e.ReplyToOriginal(new StringBuilder()
                                                .AppendLine("因异常导致功能启用失败,错误信息:")
                                                .Append(ConsoleLog.ErrorLogBuilder(x.Exception))
                                                .ToString());
                    }
                    else
                    {
                        await e.ReplyToOriginal("因未知原因导致功能启用失败,请稍后重试");
                    }
                });
            }
            else
            {
                await Database.InsertAsync(new QQGroupSetting()
                {
                    Group          = e.SourceGroup.Id,
                    SmartPixivLink = true
                }).ContinueWith(async x =>
                {
                    if (x.Result > 0)
                    {
                        await e.ReplyToOriginal("本群已成功启用pixiv智能解析功能");
                    }
                    else if (x.IsFaulted && x.Exception != null)
                    {
                        await e.ReplyToOriginal(new StringBuilder()
                                                .AppendLine("因异常导致功能启用失败,错误信息:")
                                                .Append(ConsoleLog.ErrorLogBuilder(x.Exception))
                                                .ToString());
                    }
                    else
                    {
                        await e.ReplyToOriginal("因未知原因导致功能启用失败,请稍后重试");
                    }
                });
            }
        }