Exemplo n.º 1
0
        public async void RemoveNicknameCommand(AcceptedMessage message, string[] args)
        {
            var vtuber = await GetVtuberAsync(args[2]);

            if (vtuber == null)
            {
                await SendingService.SendGroupMessageAsync(message.FromGroup, "未找到Vtuber");

                return;
            }
            if (vtuber.NickNames.All(v => !v.EqualsIgnoreCase(args[3])))
            {
                await SendingService.SendGroupMessageAsync(message.FromGroup, "已存在该昵称");

                return;
            }
            vtuber.NickNames.RemoveAll(v => v.EqualsIgnoreCase(args[3]));
            await _vtuberCollection.ReplaceOneAsync(v => v.Id == vtuber.Id, vtuber,
                                                    new UpdateOptions()
            {
                IsUpsert = true
            });

            await SendingService.SendGroupMessageAsync(message.FromGroup, "删除完成");
        }
Exemplo n.º 2
0
 public Globals(IDiscordClient client, IGuild guild, IMongoDatabase database, SendingService sender)
 {
     Client   = client;
     Guild    = guild;
     Database = database;
     Sender   = sender;
 }
Exemplo n.º 3
0
 public async void VtuberListCommand(AcceptedMessage message, string[] args)
 {
     //var vtubers = (await _vtuberCollection.FindAsync(v => true)).ToList();
     //var str = "当前机器人的单推名单:\r\n" + string.Join(",", vtubers.OrderBy(v => v.Group).Select(v => v.OriginalName));
     //await SendingService.SendGroupMessageAsync(message.FromGroup, str);
     await SendingService.SendGroupMessageAsync(message.FromGroup,
                                                "由于单推太多,发出来会被腾讯当作垃圾信息拦截\r\n请前往https://api.vtb.wiki/webapi/vtuber/list?html=1查看");
 }
Exemplo n.º 4
0
 public override void Process(AcceptedMessage message)
 {
     if (message.FromUser != 1844812067)
     {
         SendingService.SendGroupMessageAsync(message.FromGroup, "您没有权限执行这个命令.").GetAwaiter().GetResult();
         return;
     }
     base.Process(message);
 }
Exemplo n.º 5
0
        public UserJoined(IServiceProvider provider) : base(provider)
        {
            _logger   = provider.GetRequiredService <LoggingService>();
            _sender   = provider.GetRequiredService <SendingService>();
            _dbGuilds = provider.GetRequiredService <IMongoCollection <Guild> >();
            _dbMutes  = provider.GetRequiredService <IMongoCollection <Mute> >();

            _client.UserJoined += OnUserJoinedAsync;
        }
Exemplo n.º 6
0
Arquivo: Global.cs Projeto: Lunerr/FFA
 public Globals(IDiscordClient client, IGuild guild, IMongoDatabase database, SendingService sender, RulesService rulesService,
                ReputationService reputationService)
 {
     Client            = client;
     Guild             = guild;
     Database          = database;
     Sender            = sender;
     RulesService      = rulesService;
     ReputationService = reputationService;
 }
Exemplo n.º 7
0
 public override async void ShowHelpMessage(AcceptedMessage message, string[] args)
 {
     var str = "使用方法:\r\n" +
               "!Vtuber add <Vtuber日文名>  -添加Vtuber\r\n" +
               "!Vtuber list  -查看数据库中的Vtuber列表\r\n" +
               "!Vtuber 设置中文名 <Vtuber日文名> <中文名> -给Vtuber设置中文名\r\n" +
               "!Vtuber 设置B站 <Vtuber名字> <B站UID/B站昵称>  -设置Vtuber的B站搬运组\r\n" +
               "!Vtuber 添加昵称 <Vtuber名字> <昵称>  -给Vtuber添加昵称\r\n" +
               "!Vtuber 删除昵称 <Vtuber名字> <昵称>  -删除Vtuber的这个昵称";
     await SendingService.SendGroupMessageAsync(message.FromGroup, str);
 }
Exemplo n.º 8
0
        public Context(IDiscordClient client, IUserMessage msg, IServiceProvider provider)
        {
            _sender   = provider.GetRequiredService <SendingService>();
            _dbUsers  = provider.GetRequiredService <IMongoCollection <User> >();
            _dbGuilds = provider.GetRequiredService <IMongoCollection <Guild> >();

            Client      = client;
            Message     = msg;
            Channel     = msg.Channel;
            TextChannel = msg.Channel as ITextChannel;
            Guild       = TextChannel?.Guild;
            User        = msg.Author;
            GuildUser   = User as IGuildUser;
        }
Exemplo n.º 9
0
        public async void ReloadPluginCommand(AcceptedMessage message, string[] args)
        {
            var plugin = PluginManager.Manager.GetPlugin(args[2]);

            if (plugin == null)
            {
                await SendingService.SendGroupMessageAsync(message.FromGroup, "Plugin not found.");

                return;
            }
            PluginManager.Manager.UnloadPlugin(plugin);
            PluginManager.Manager.LoadPlugin(plugin.DllPath, Observer);
            await SendingService.SendGroupMessageAsync(message.FromGroup, "Success.");
        }
Exemplo n.º 10
0
        public override async void ShowHelpMessage(AcceptedMessage message, string[] args)
        {
            var str = "=== Vtuber天狗机器人使用指南 === (指令中的参数如果需要空格请使用%代替空格)\r\n";

            str += string.Join("\r\n",
                               Observer.Processors.Where(v => v != this && !string.IsNullOrEmpty(v.HelpMessage))
                               .Select(v => v.HelpMessage));
            str += "\r\n机器人进入维护状态,将不会增加新功能,如有问题请使用!留言 告知";
            if (message.IsGroupMessage)
            {
                await SendingService.SendGroupMessageAsync(message.FromGroup, str);
            }
            else
            {
                await SendingService.SendPrivateMessageAsync(message.FromUser, str);
            }
        }
Exemplo n.º 11
0
        public async void SetChineseNameCommand(AcceptedMessage message, string[] args)
        {
            var vtuber = await GetVtuberAsync(args[2]);

            if (vtuber == null)
            {
                await SendingService.SendGroupMessageAsync(message.FromGroup, "未找到Vtuber.");

                return;
            }
            vtuber.ChineseName = args[3];
            await _vtuberCollection.ReplaceOneAsync(v => v.Id == vtuber.Id, vtuber,
                                                    new UpdateOptions()
            {
                IsUpsert = true
            });

            await SendingService.SendGroupMessageAsync(message.FromGroup, "设置完成.");

            try
            {
                var uploader = (await BilibiliApi.SearchBilibiliUsersAsync(vtuber.ChineseName))
                               .OrderByDescending(v => v.Follower).FirstOrDefault(v => v.IsUploader);
                if (uploader != null && vtuber.BilibiliUserId == 0)
                {
                    vtuber.BilibiliUserId = uploader.Id;
                    await _vtuberCollection.ReplaceOneAsync(v => v.Id == vtuber.Id, vtuber,
                                                            new UpdateOptions()
                    {
                        IsUpsert = true
                    });

                    await SendingService.SendGroupMessageAsync(message.FromGroup, $"已根据中文名自动查找B站搬运组:" +
                                                               $"\r\n用户名: {uploader.Username}" +
                                                               $"\r\n主页: https://space.bilibili.com/{uploader.Id}" +
                                                               $"\r\n粉丝数: {uploader.Follower}");

                    await SendingService.SendGroupMessageAsync(message.FromGroup, "可使用!Vtuber 设置B站 <Vtuber名字> <B站空间ID或搬运组名称> 来修改");
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error("Search bilibili uploader error.", ex: ex);
            }
        }
Exemplo n.º 12
0
        public async void VtuberProfileCommand(AcceptedMessage message, string[] args)
        {
            var vtuber = await GetVtuberAsync(args[1]);

            if (vtuber == null)
            {
                await SendingService.SendGroupMessageAsync(message.FromGroup, "数据库中不存在" + args[1]);

                return;
            }
            await SendingService.SendGroupMessageAsync(message.FromGroup, $"Vtuber详细资料:" +
                                                       $"\r\n原名: {vtuber.OriginalName}" +
                                                       $"\r\n中文名: {vtuber.ChineseName}" +
                                                       $"\r\n昵称: {string.Join(',', vtuber.NickNames)}" +
                                                       $"\r\nYoutube频道: https://www.youtube.com/channel/{vtuber.YoutubeChannelId}" +
                                                       $"\r\n推特主页: https://twitter.com/{vtuber.TwitterProfileId}" +
                                                       $"\r\nB站搬运: https://space.bilibili.com/{vtuber.BilibiliUserId}");
        }
Exemplo n.º 13
0
        public async void ShowSubscribeList(AcceptedMessage message, string[] args)
        {
            var config = Config.DefaultConfig.GroupConfigs.FirstOrDefault(v => v.GroupId == message.FromGroup);

            if (config == null)
            {
                await SendingService.SendGroupMessageAsync(message.FromGroup, "本群未订阅任何事件");

                return;
            }
            var str = "本群订阅列表:\r\n";

            str += string.Join(",",
                               config.PublishConfigs
                               .Where(v => v.YoutubeUploadVideo || v.YoutubeBeginLive || v.BilibiliBeginLive ||
                                      v.BilibiliPublishDynamic || v.BilibiliUploadVideo || v.PublishTweet || v.ReplyTweet ||
                                      v.Retweeted).Select(v => v.VtuberName));
            await SendingService.SendGroupMessageAsync(message.FromGroup, str);
        }
Exemplo n.º 14
0
        public async void PrePublishSetting(AcceptedMessage message, string[] args)
        {
            var config = Config.DefaultConfig.GroupConfigs.FirstOrDefault(v => v.GroupId == message.FromGroup);

            if (config == null)
            {
                Config.DefaultConfig.GroupConfigs.Add(new GroupConfig()
                {
                    GroupId        = message.FromGroup,
                    PrePublish     = true,
                    PublishConfigs = new List <VtuberPublishConfig>()
                });
                Config.SaveToDefaultFile(Config.DefaultConfig);
                await SendingService.SendGroupMessageAsync(message.FromGroup, "设置完成: 已开启预推送");

                return;
            }

            config.PrePublish = !config.PrePublish;
            Config.SaveToDefaultFile(Config.DefaultConfig);
            await SendingService.SendGroupMessageAsync(message.FromGroup,
                                                       "设置完成: 已" + (config.PrePublish ? "开启" : "关闭") + "预推送");
        }
Exemplo n.º 15
0
        public override void Process(AcceptedMessage message)
        {
            if (_vtuberCollection == null)
            {
                _vtuberCollection = Observer.Database.GetCollection <VtuberEntity>("vtubers");
            }
            var args = message.Content.Split(' ');

            if (args.Length >= 3)
            {
                var vtuberName = args[1] == "查看" ? args[2] : args[3];
                var vtuber     = (_vtuberCollection.FindAsync(v =>
                                                              v.OriginalName == vtuberName || v.ChineseName == vtuberName || v.NickNames.Any(n => n == vtuberName)).GetAwaiter().GetResult()).ToList();
                if (!vtuber.Any())
                {
                    SendingService.SendGroupMessageAsync(message.FromGroup, "未知Vtuber");
                    return;
                }
                vtuberName = vtuber.First().OriginalName;
                var config = Config.DefaultConfig.GroupConfigs.FirstOrDefault(v => v.GroupId == message.FromGroup);
                if (config == null)
                {
                    Config.DefaultConfig.GroupConfigs.Add(new GroupConfig()
                    {
                        GroupId        = message.FromGroup,
                        PublishConfigs = new List <VtuberPublishConfig>()
                    });
                    Config.SaveToDefaultFile(Config.DefaultConfig);
                    config = Config.DefaultConfig.GroupConfigs.First(v => v.GroupId == message.FromGroup);
                }
                if (config.PublishConfigs.All(v => v.VtuberName != vtuberName))
                {
                    config.PublishConfigs.Add(new VtuberPublishConfig()
                    {
                        VtuberName = vtuberName
                    });
                }

                var vtuberConfig = config.PublishConfigs.First(v => v.VtuberName == vtuberName);
                if (args[1] == "查看")
                {
                    SendingService.SendGroupMessageAsync(message.FromGroup,
                                                         $"==== 本群{vtuberConfig.VtuberName}订阅状态 ====\r\n" +
                                                         $"推特发推: {vtuberConfig.PublishTweet}\r\n" +
                                                         $"推特转推: {vtuberConfig.Retweeted}\r\n" +
                                                         $"推特回推: {vtuberConfig.ReplyTweet}\r\n" +
                                                         $"油管上传: {vtuberConfig.YoutubeUploadVideo}\r\n" +
                                                         $"油管开播: {vtuberConfig.YoutubeBeginLive}\r\n" +
                                                         $"油管评论: {vtuberConfig.YoutubeComment}\r\n" +
                                                         $"B站开播: {vtuberConfig.BilibiliBeginLive}\r\n" +
                                                         $"B站上传: {vtuberConfig.BilibiliUploadVideo}\r\n" +
                                                         $"B站动态: {vtuberConfig.BilibiliPublishDynamic}").GetAwaiter().GetResult();
                    return;
                }

                if (args[1] == "添加")
                {
                    switch (args[2].ToLower())
                    {
                    case "发推":
                        vtuberConfig.PublishTweet = true;
                        break;

                    case "转推":
                        vtuberConfig.Retweeted = true;
                        break;

                    case "回推":
                        vtuberConfig.ReplyTweet = true;
                        break;

                    case "油管开播":
                        vtuberConfig.YoutubeBeginLive = true;
                        break;

                    case "油管上传":
                        vtuberConfig.YoutubeUploadVideo = true;
                        break;

                    case "油管评论":
                        vtuberConfig.YoutubeComment = true;
                        break;

                    case "b站开播":
                        if (vtuber.First().BilibiliUserId == default(long))
                        {
                            SendingService.SendGroupMessageAsync(message.FromGroup, "该Vtuber未绑定B站搬运,请使用!Vtuber 设置中文名 来绑定").GetAwaiter().GetResult();
                            return;
                        }

                        vtuberConfig.BilibiliBeginLive = true;
                        break;

                    case "b站上传":
                        if (vtuber.First().BilibiliUserId == default(long))
                        {
                            SendingService.SendGroupMessageAsync(message.FromGroup, "该Vtuber未绑定B站搬运,请使用!Vtuber 设置中文名 来绑定");
                            return;
                        }

                        vtuberConfig.BilibiliUploadVideo = true;
                        break;

                    case "b站动态":
                        if (vtuber.First().BilibiliUserId == default(long))
                        {
                            SendingService.SendGroupMessageAsync(message.FromGroup, "该Vtuber未绑定B站搬运,请使用!Vtuber 设置中文名 来绑定");
                            return;
                        }
                        vtuberConfig.BilibiliPublishDynamic = true;
                        break;

                    default:
                        SendingService.SendGroupMessageAsync(message.FromGroup, $"未知订阅");
                        return;
                    }
                    SendingService.SendGroupMessageAsync(message.FromGroup, $"成功订阅");
                    Config.SaveToDefaultFile(Config.DefaultConfig);
                    return;
                }

                if (args[1] == "取消")
                {
                    switch (args[2].ToLower())
                    {
                    case "发推":
                        vtuberConfig.PublishTweet = false;
                        break;

                    case "转推":
                        vtuberConfig.Retweeted = false;
                        break;

                    case "回推":
                        vtuberConfig.ReplyTweet = false;
                        break;

                    case "油管开播":
                        vtuberConfig.YoutubeBeginLive = false;
                        break;

                    case "油管上传":
                        vtuberConfig.YoutubeUploadVideo = false;
                        break;

                    case "油管评论":
                        vtuberConfig.YoutubeComment = false;
                        break;

                    case "b站开播":
                        vtuberConfig.BilibiliBeginLive = false;
                        break;

                    case "b站上传":
                        vtuberConfig.BilibiliUploadVideo = false;
                        break;

                    case "b站动态":
                        vtuberConfig.BilibiliPublishDynamic = false;
                        break;

                    default:
                        SendingService.SendGroupMessageAsync(message.FromGroup, $"未知订阅").GetAwaiter().GetResult();
                        return;
                    }
                    SendingService.SendGroupMessageAsync(message.FromGroup, $"成功取消").GetAwaiter().GetResult();
                    Config.SaveToDefaultFile(Config.DefaultConfig);
                    return;
                }
            }
            base.Process(message);
        }
Exemplo n.º 16
0
        public async void AddVtuberCommand(AcceptedMessage message, string[] args)
        {
            try
            {
                var vtuberName = string.Join(" ", args.Skip(2));
                var vtuber     = await GetVtuberAsync(vtuberName);

                if (vtuber != null)
                {
                    await SendingService.SendGroupMessageAsync(message.FromGroup, "已存在 " + vtuberName);

                    return;
                }

                await SendingService.SendGroupMessageAsync(message.FromGroup, "正在搜索, 这可能需要一段时间.");

                var streamers = HiyokoApi.SearchStreamer(vtuberName);
                if (streamers.Count == 0)
                {
                    await SendingService.SendGroupMessageAsync(message.FromGroup, "无法找到: " + vtuberName);

                    return;
                }

                var streamer        = streamers.First();
                var bilibiliChannel = streamer.Channels.FirstOrDefault(v => v.ChannelType == 6)?.ChannelId?
                                      .Replace("BL_", string.Empty);
                if (await GetVtuberAsync(streamer.Name) != null)
                {
                    await SendingService.SendGroupMessageAsync(message.FromGroup, "已存在 " + vtuberName);

                    return;
                }
                var entity = new VtuberEntity()
                {
                    OriginalName     = streamer.Name,
                    TwitterProfileId = streamer.TwitterId,
                    YoutubeChannelId = streamer.Channels.FirstOrDefault(v => v.ChannelType == 1)?.ChannelId,
                    HiyokoProfileId  = streamer.Name,
                    BilibiliUserId   = string.IsNullOrEmpty(bilibiliChannel) ? 0 : long.Parse(bilibiliChannel)
                };
                var userlocalVtuber = (await UserlocalApi.SearchAsync(vtuberName).Retry(5))
                                      .Select(v => UserlocalApi.GetVtuberInfoAsync(v.Id).Retry(5).GetAwaiter().GetResult()).FirstOrDefault(
                    v =>
                {
                    if (v.ChannelLink.EndsWith("/"))
                    {
                        v.ChannelLink = v.ChannelLink.Substring(0, v.ChannelLink.Length - 1);
                    }
                    return(v.ChannelLink.Split('/').Last() == entity.YoutubeChannelId);
                });
                if (userlocalVtuber != null)
                {
                    entity.Group            = userlocalVtuber.OfficeName;
                    entity.UserlocalProfile = userlocalVtuber.Id;
                }

                await _vtuberCollection.InsertOneAsync(entity);

                await SendingService.SendGroupMessageAsync(message.FromGroup,
                                                           "已根据互联网相关资料添加: " + vtuberName + "\r\n可使用!Vtuber set修改");

                await SendingService.SendGroupMessageAsync(message.FromGroup, $"Vtuber相关信息: \r\n" +
                                                           $"原名: {streamer.Name}\r\n" +
                                                           $"推特主页: https://twitter.com/{streamer.TwitterId}\r\n" +
                                                           $"Youtube频道: https://www.youtube.com/channel/{streamer.Channels.FirstOrDefault(v => v.ChannelType == 1)?.ChannelId}\r\n" +
                                                           $"B站主页: https://space.bilibili.com/{entity.BilibiliUserId}\r\n" +
                                                           $"所属团体: {entity.Group}");
            }
            catch (Exception ex)
            {
                await SendingService.SendGroupMessageAsync(message.FromGroup, "添加vtuber时出现错误, 请重试或反馈, 错误信息: " + ex.Message);
            }
        }
Exemplo n.º 17
0
 public async void EnablePluginCommand(AcceptedMessage message, string[] args)
 {
     var pluginFolder = Path.Combine(Directory.GetCurrentDirectory(), "Plugins");
     var plugin       = PluginManager.Manager.LoadPlugin(Path.Combine(pluginFolder, args[2]), Observer);
     await SendingService.SendGroupMessageAsync(message.FromGroup, plugin == null? "Failed." : "Success.");
 }
Exemplo n.º 18
0
        public virtual void Process(AcceptedMessage message)
        {
            if (!message.IsGroupMessage)
            {
                SendingService.SendPrivateMessageAsync(message.FromUser, "暂不支持私聊互动");
                return;
            }
            var methods = GetType().GetMethods().Where(v => v.IsDefined(typeof(BotCommandAttribute), false));
            var atts    = methods.Select(v =>
                                         v.GetCustomAttributes(false).First(att => att.GetType() == typeof(BotCommandAttribute)))
                          .Select(v => (BotCommandAttribute)v);
            var handled = false;
            var args    = message.Content.Trim().Split(' ').Select(v => v.Replace("%", " ")).ToArray();

            foreach (var method in methods)
            {
                var attr              = method.GetCustomAttributes(false);
                var commandAttr       = attr.FirstOrDefault(v => v.GetType() == typeof(BotCommandAttribute));
                var commandPermission = attr.FirstOrDefault(v => v.GetType() == typeof(CommandPermissionsAttribute));
                if (commandAttr != null)
                {
                    var info = (BotCommandAttribute)commandAttr;
                    if (args.Length == info.ProcessLength || info.ProcessLength == 0)
                    {
                        if (!string.IsNullOrEmpty(info.SubCommandName))
                        {
                            if (args.Length <= info.SubCommandOffset)
                            {
                                continue;
                            }
                            if (!args[info.SubCommandOffset].EqualsIgnoreCase(info.SubCommandName))
                            {
                                continue;
                            }
                        }
                        else
                        {
                            if (atts.Any(v => !string.IsNullOrEmpty(v.SubCommandName) && args.Length > v.SubCommandOffset && args[v.SubCommandOffset] == v.SubCommandName))
                            {
                                continue;
                            }
                        }
                        try
                        {
                            handled = true;
                            if (commandPermission != null)
                            {
                                var config =
                                    Config.DefaultConfig.GroupConfigs.FirstOrDefault(
                                        v => v.GroupId == message.FromGroup);
                                var permissionInfo = (CommandPermissionsAttribute)commandPermission;
                                if (config == null || permissionInfo.Permissions.Any(v => config.Permissions.Contains(v)))
                                {
                                    SendingService.SendGroupMessageAsync(message.FromGroup, $"您没有权限执行这个操作.")
                                    .GetAwaiter().GetResult();
                                    return;
                                }
                            }
                            method.Invoke(this, new object[]
                            {
                                message,
                                args
                            });
                        }
                        catch (Exception ex)
                        {
                            LogHelper.Error("处理消息时出现未知异常 包名:" + GetType() + " 函数名: " + method.Name, true, ex);
                            SendingService.SendGroupMessageAsync(message.FromGroup, $"处理请求时出现未知异常,处理函数: {method.Name}");
                        }
                    }
                }
            }
            if (!handled)
            {
                ShowHelpMessage(message, args);
            }
        }
Exemplo n.º 19
0
 public override async void ShowHelpMessage(AcceptedMessage message, string[] args)
 {
     var live = "当前直播列表: \r\n" +
                string.Join("\r\n", Observer.LiveList.Select(v => v.Key + " 在 " + v.Value + " 直播中"));
     await SendingService.SendGroupMessageAsync(message.FromGroup, live);
 }
Exemplo n.º 20
0
 public async void DestroyPluginCommand(AcceptedMessage message, string[] args)
 {
     PluginManager.Manager.UnloadPlugin(args[2]);
     await SendingService.SendGroupMessageAsync(message.FromGroup, "Success.");
 }
Exemplo n.º 21
0
        public async void UpdateBilibiliProfileCommand(AcceptedMessage message, string[] args)
        {
            var vtuber = await GetVtuberAsync(args[2]);

            if (vtuber == null)
            {
                await SendingService.SendGroupMessageAsync(message.FromGroup, "未找到相关Vtuber");

                return;
            }
            if (long.TryParse(args[3], out var uid))
            {
                var userInfo = await BilibiliApi.GetBilibiliUserAsync(uid);

                if (userInfo == null)
                {
                    await SendingService.SendGroupMessageAsync(message.FromGroup, "未找到UID: " + uid);

                    return;
                }
                vtuber.BilibiliUserId = uid;
                await _vtuberCollection.ReplaceOneAsync(v => v.Id == vtuber.Id, vtuber,
                                                        new UpdateOptions()
                {
                    IsUpsert = true
                });

                await SendingService.SendGroupMessageAsync(message.FromGroup, $"保存完成:" +
                                                           $"\r\n用户名: {userInfo.Username}" +
                                                           $"\r\n主页: https://space.bilibili.com/{uid}" +
                                                           $"\r\n粉丝数: {userInfo.Follower}");

                return;
            }
            try
            {
                var uploader = (await BilibiliApi.SearchBilibiliUsersAsync(args[3]))
                               .OrderByDescending(v => v.Follower).FirstOrDefault(v => v.IsUploader);
                if (uploader != null)
                {
                    vtuber.BilibiliUserId = uploader.Id;
                    await _vtuberCollection.ReplaceOneAsync(v => v.Id == vtuber.Id, vtuber,
                                                            new UpdateOptions()
                    {
                        IsUpsert = true
                    });

                    await SendingService.SendGroupMessageAsync(message.FromGroup, $"保存完成:" +
                                                               $"\r\n用户名: {uploader.Username}" +
                                                               $"\r\n主页: https://space.bilibili.com/{uploader.Id}" +
                                                               $"\r\n粉丝数: {uploader.Follower}");

                    return;
                }
                await SendingService.SendGroupMessageAsync(message.FromGroup, "未找到 " + args[3]);
            }
            catch (Exception ex)
            {
                LogHelper.Error("Search bilibili uploader error.", ex: ex);
            }
        }
Exemplo n.º 22
0
 public override async void ShowHelpMessage(AcceptedMessage message, string[] args)
 {
     var str = "使用方法: \r\n!订阅 <添加/查看/取消> <发推/转推/回推/油管开播/油管上传/油管评论/B站开播/B站上传/B站动态>  <Vtuber名字> -设置订阅状态" +
               "\r\n!订阅 预告  -设置或取消距离开播还剩10分钟时的预告";
     await SendingService.SendGroupMessageAsync(message.FromGroup, str);
 }