Example #1
0
        public void SetUp()
        {
            var serverMock = new Mock <IDataServer>();

            server = serverMock.Object;
            logger = new Mock <ILogger>().Object;
            var optionsMock = new Mock <ICommentOptions>();

            options     = optionsMock.Object;
            siteOptions = new LineLiveSiteOptions();

            use1 = new UserTest("1");
            use2 = new UserTest("2");
            use3 = new UserTest("3");
            use4 = new UserTest("4");
            use5 = new UserTest("5");
            use6 = new UserTest("6");
            var userStoreMock = new Mock <IUserStoreManager>();

            userStoreMock.Setup(s => s.GetUser(SiteType.LineLive, "1")).Returns(use1);
            userStoreMock.Setup(s => s.GetUser(SiteType.LineLive, "2")).Returns(use2);
            userStoreMock.Setup(s => s.GetUser(SiteType.LineLive, "3")).Returns(use3);
            userStoreMock.Setup(s => s.GetUser(SiteType.LineLive, "4")).Returns(use4);
            userStoreMock.Setup(s => s.GetUser(SiteType.LineLive, "5")).Returns(use5);
            userStoreMock.Setup(s => s.GetUser(SiteType.LineLive, "6")).Returns(use6);

            userStoreManager = userStoreMock.Object;
        }
Example #2
0
 public NicoSiteContext(ICommentOptions options, IDataSource server, ILogger logger, IUserStoreManager userStoreManager)
     : base(options, userStoreManager, logger)
 {
     _options = options;
     _server  = server;
     _logger  = logger;
 }
Example #3
0
 public YouTubeLiveSiteContext(ICommentOptions options, IYouTubeLibeServer server, ILogger logger, IUserStoreManager userStoreManager)
     : base(options, userStoreManager, logger)
 {
     _options = options;
     _server  = server;
     _logger  = logger;
 }
Example #4
0
        public MirrativCommentViewModel(ICommentOptions options, IMirrativSiteOptions siteOptions, Message message, bool isFirstComment, ICommentProvider commentProvider, IUser user)
            : base(options, user, commentProvider, isFirstComment)
        {
            MessageType  = message.Type;
            _siteOptions = siteOptions;
            Id           = message.Id;
            UserId       = message.UserId;
            PostTime     = Tools.UnixTime2DateTime(message.CreatedAt).ToString("HH:mm:ss");

            var name = new List <IMessagePart> {
                MessagePartFactory.CreateMessageText(message.Username)
            };

            user.Name = name;
            var comment = message.Comment;

            if (siteOptions.NeedAutoSubNickname && message.Type == MessageType.Comment)
            {
                var nick = ExtractNickname(comment);
                if (!string.IsNullOrEmpty(nick))
                {
                    user.Nickname = nick;
                }
            }
            NameItemsInternal = name;
            MessageItems      = new List <IMessagePart> {
                MessagePartFactory.CreateMessageText(comment)
            };

            Init();
        }
Example #5
0
 protected MessageMetadataBase(ICommentOptions options, IMirrativSiteOptions siteOptions)
 {
     _options                     = options;
     _siteOptions                 = siteOptions;
     options.PropertyChanged     += Options_PropertyChanged;
     siteOptions.PropertyChanged += SiteOptions_PropertyChanged;
 }
        public IEnumerable <(string displayName, Guid guid)> LoadSitePlugins(ICommentOptions options, ILogger logger, IUserStoreManager userStoreManager)
        {
            var list = new List <ISiteContext>
            {
                new YouTubeLiveSitePlugin.Test2.YouTubeLiveSiteContext(options, new YouTubeLiveSitePlugin.Test2.YouTubeLiveServer(), logger, userStoreManager),
                new OpenrecSitePlugin.OpenrecSiteContext(options, logger, userStoreManager),
                new TwitchSitePlugin.TwitchSiteContext(options, new TwitchSitePlugin.TwitchServer(), logger, userStoreManager),
                new NicoSitePlugin.NicoSiteContext(options, new NicoSitePlugin.DataSource(), (addr, port, size, buffer) => new NicoSitePlugin.StreamSocket(addr, port, size, buffer), logger, userStoreManager),
                new TwicasSitePlugin.TwicasSiteContext(options, logger, userStoreManager),
                new LineLiveSitePlugin.LineLiveSiteContext(options, new LineLiveSitePlugin.LineLiveServer(), logger, userStoreManager),
                new WhowatchSitePlugin.WhowatchSiteContext(options, logger, userStoreManager),
                new MirrativSitePlugin.MirrativSiteContext(options, new MirrativSitePlugin.MirrativServer(), logger, userStoreManager),
                new PeriscopeSitePlugin.PeriscopeSiteContext(options, new PeriscopeSitePlugin.PeriscopeServer(), logger, userStoreManager),
                new ShowRoomSitePlugin.ShowRoomSiteContext(options, new ShowRoomSitePlugin.ShowRoomServer(), logger, userStoreManager),
                new MixerSitePlugin.MixerSiteContext(options, new MixerSitePlugin.MixerServer(), logger, userStoreManager),
                new MildomSitePlugin.MildomSiteContext(options, new MildomSitePlugin.MildomServer(), logger, userStoreManager),
#if DEBUG
                new TestSitePlugin.TestSiteContext(options),
#endif
            };

            foreach (var site in list)
            {
                site.Init();
                _dict.Add(site.Guid, site);
            }
            return(_dict.Select(kv => (kv.Value.DisplayName, kv.Key)));
        }
Example #7
0
 //ParseMessage.IMessage _message;
 //     public LineLiveCommentViewModel(ICommentOptions options, ILineLiveSiteOptions siteOptions, ParseMessage.ILove data, ParseMessage.IUser sender, IUser user, ICommentProvider cp) :
 //         base(options, user, cp, false)
 //     {
 //         MessageType = MessageType.BroadcastInfo;
 //         _siteOptions = siteOptions;
 //         _message = data;
 //         CommentProvider = cp;
 //         var msg = sender.DisplayName + "さんがハートを送りました!";
 //         MessageItems = new List<IMessagePart> { MessagePartFactory.CreateMessageText(msg) };
 //         Init();
 //     }
 //     public LineLiveCommentViewModel(ICommentOptions options, ILineLiveSiteOptions siteOptions, ParseMessage.IGiftMessage data, ParseMessage.IUser sender, IUser user, ICommentProvider cp) :
 //base(options, user, cp, false)
 //     {
 //         MessageType = MessageType.BroadcastInfo;
 //         _siteOptions = siteOptions;
 //         _message = data;
 //         CommentProvider = cp;
 //         //2018/07/13
 //         if (data.ItemId == "limited-love-gift" || string.IsNullOrEmpty(data.Url))
 //         {
 //             //{"type":"giftMessage","data":{"message":"","type":"LOVE","itemId":"limited-love-gift","quantity":1,"displayName":"limited.love.gift.item","sender":{"id":2903515,"hashedId":"715i4MKqyv","displayName":"上杉The Times","iconUrl":"https://scdn.line-apps.com/obs/0hmNs42D-0MmFOTR9H8JtNNnYQNBY3YzEpNmkpRHdEbQI3LnYxIX97UGIdaVdjKXVjd3ktVGNEP1VjenU1ew/f64x64","hashedIconId":"0hmNs42D-0MmFOTR9H8JtNNnYQNBY3YzEpNmkpRHdEbQI3LnYxIX97UGIdaVdjKXVjd3ktVGNEP1VjenU1ew","isGuest":false,"isBlocked":false},"isNGGift":false,"sentAt":1531445716,"key":"2426265.29035150000000000000","blockedByCms":false}}
 //             var msg = sender.DisplayName + "さんがハートで応援ポイントを送りました!";
 //             MessageItems = new List<IMessagePart> { MessagePartFactory.CreateMessageText(msg) };
 //         }
 //         else
 //         {
 //             var msg = sender.DisplayName + "さんが" + data.Quantity + "コインプレゼントしました!";
 //             MessageItems = new List<IMessagePart> { MessagePartFactory.CreateMessageText(msg), new MessageImage { Url = data.Url } };
 //         }
 //         Init();
 //     }
 //     public LineLiveCommentViewModel(ICommentOptions options, ILineLiveSiteOptions siteOptions, ParseMessage.IFollowStartData data, ParseMessage.IUser sender, IUser user, ICommentProvider cp) :
 //         base(options, user, cp, false)
 //     {
 //         MessageType = MessageType.BroadcastInfo;
 //         _siteOptions = siteOptions;
 //         _message = data;
 //         CommentProvider = cp;
 //         var msg = sender.DisplayName + "さんがフォローしました!";
 //         MessageItems = new List<IMessagePart> { MessagePartFactory.CreateMessageText(msg) };
 //         Init();
 //     }
 public LineLiveCommentViewModel(ICommentOptions options, ILineLiveSiteOptions siteOptions, ParseMessage.IMessageData data, ParseMessage.IUser sender, IUser user, ICommentProvider cp) :
     base(options, user, cp, false)
 {
     MessageType  = MessageType.Comment;
     _siteOptions = siteOptions;
     //_message = data;
     UserId = sender.Id.ToString();
     Id     = "";
     if (siteOptions.IsAutoSetNickname)
     {
         var nick = ExtractNickname(data.Message);
         if (!string.IsNullOrEmpty(nick))
         {
             user.Nickname = nick;
         }
     }
     SetNameItems();
     MessageItems = new List <IMessagePart> {
         MessagePartFactory.CreateMessageText(data.Message)
     };
     Thumbnail = new MessageImage {
         Url = sender.IconUrl
     };
     PostTime = Tools.FromUnixTime(data.SentAt).ToString("HH:mm:ss");
     Init();
     NameItemsInternal = new List <IMessagePart> {
         MessagePartFactory.CreateMessageText(sender.DisplayName)
     };
     User.Name = NameItemsInternal;
 }
 public EmotionMessageMetadata(INicoEmotion item, ICommentOptions options, INicoSiteOptions siteOptions, IUser user, ICommentProvider cp)
     : base(options, siteOptions)
 {
     _item           = item;
     User            = user;
     CommentProvider = cp;
 }
Example #9
0
 public TestCommentProvider(ICommentOptions options, IUserStore userStore)
 {
     _options      = options;
     _userStore    = userStore;
     CanConnect    = true;
     CanDisconnect = false;
 }
 public NicoSiteContext(ICommentOptions options, IDataSource server, Func <string, int, int, ISplitBuffer, IStreamSocket> _, ILogger logger, IUserStoreManager userStoreManager)
     : base(options, userStoreManager, logger)
 {
     _options = options;
     _server  = server;
     _logger  = logger;
 }
Example #11
0
 public ShowRoomSiteContext(ICommentOptions options, IDataServer server, ILogger logger, IUserStoreManager userStoreManager)
     : base(options, userStoreManager, logger)
 {
     _options = options;
     _server  = server;
     _logger  = logger;
 }
Example #12
0
 public YouTubeLiveSiteContext(ICommentOptions options, IYouTubeLibeServer server, ILogger logger)
 {
     _options   = options;
     _server    = server;
     _logger    = logger;
     _userStore = CreateUserStore();
 }
Example #13
0
 public WhowatchSiteContext(ICommentOptions options, ILogger logger, IUserStoreManager userStoreManager)
     : base(options, userStoreManager, logger)
 {
     _options = options;
     _server  = CreateServer();
     _logger  = logger;
 }
Example #14
0
        public TwitchCommentViewModel(ICommentOptions options, ITwitchSiteOptions siteOptions,
                                      ICommentData commentData, bool isFirstComment, ICommentProvider commentProvider, IUser user)
            : base(options, user, commentProvider, isFirstComment)
        {
            MessageType  = MessageType.Comment;
            _siteOptions = siteOptions;
            Id           = commentData.Id;
            UserId       = commentData.UserId;
            DisplayName  = commentData.DisplayName;
            PostTime     = commentData.SentAt.ToString("HH:mm:ss");

            var name = commentData.Username;

            user.Name = new List <IMessagePart> {
                MessagePartFactory.CreateMessageText(name)
            };
            var message = commentData.Message;

            if (siteOptions.NeedAutoSubNickname)
            {
                var nick = ExtractNickname(message);
                if (!string.IsNullOrEmpty(nick))
                {
                    user.Nickname = nick;
                }
            }
            NameItemsInternal = new List <IMessagePart> {
                MessagePartFactory.CreateMessageText(name)
            };
            MessageItems = Tools.GetMessageItems(commentData.Message, commentData.Emotes);

            Init();
        }
 public CommentMessageMetadata(IWhowatchMessage message, ICommentOptions options, IWhowatchSiteOptions siteOptions, IUser user, ICommentProvider cp, bool isFirstComment)
     : base(options, siteOptions, cp)
 {
     User                  = user;
     IsFirstComment        = isFirstComment;
     user.PropertyChanged += User_PropertyChanged;
 }
Example #16
0
            public override IMessageMetadata CreateMetadata(ICommentOptions options, IUser user)
            {
                var messageMock     = new Mock <IYouTubeLiveComment>();
                var siteOptionsMock = new Mock <IYouTubeLiveSiteOptions>();
                var userMock        = new Mock <IUser>();

                return(new YouTubeLiveSitePlugin.Test2.YouTubeLiveMessageMetadata(messageMock.Object, options, siteOptionsMock.Object, user, null, false));
            }
Example #17
0
            public override IMessageMetadata CreateMetadata(ICommentOptions options, IUser user)
            {
                var messageMock     = new Mock <IWhowatchComment>();
                var siteOptionsMock = new Mock <IWhowatchSiteOptions>();
                var userMock        = new Mock <IUser>();

                return(new WhowatchSitePlugin.CommentMessageMetadata(messageMock.Object, options, siteOptionsMock.Object, user, null, false));
            }
 /// <summary>
 /// 来場者数とかのような特定のユーザが出したものではない場合にこっち
 /// </summary>
 /// <param name="options"></param>
 /// <param name="message"></param>
 public BroadcastInfoCommentViewModel(ICommentOptions options, string message)
     : base(options, DefaultUser, null, false)
 {
     MessageItems = new List <IMessagePart>
     {
         MessagePartFactory.CreateMessageText(message),
     };
 }
        public CommentProviderBase(ILogger logger, ICommentOptions options)
        {
            _logger  = logger;
            _options = options;

            CanConnect    = true;
            CanDisconnect = false;
        }
 public CommentProviderInternalBase(ICommentOptions options, INicoSiteOptions siteOptions, IUserStoreManager userStoreManager, IDataSource dataSource, ILogger logger)
 {
     _options          = options;
     _siteOptions      = siteOptions;
     _userStoreManager = userStoreManager;
     _dataSource       = dataSource;
     _logger           = logger;
 }
        public static InfoMessageContext Create(InfoMessage message, ICommentOptions options)
        {
            var metadata = new InfoMessageMetadata(message, options);
            var methods  = new InfoMessageMethods();
            var context  = new InfoMessageContext(message, metadata, methods);

            return(context);
        }
 public ShowRoomCommentProvider(IDataServer server, ILogger logger, ICommentOptions options, IShowRoomSiteOptions siteOptions, IUserStoreManager userStoreManager)
     : base(logger, options)
 {
     _server           = server;
     _logger           = logger;
     _options          = options;
     _siteOptions      = siteOptions;
     _userStoreManager = userStoreManager;
 }
Example #23
0
        public ItemMessageMetadata(IMirrativItem item, ICommentOptions options, IMirrativSiteOptions siteOptions, IUser user, ICommentProvider cp)
            : base(options, siteOptions)
        {
            _item           = item;
            User            = user;
            CommentProvider = cp;

            user.PropertyChanged += User_PropertyChanged;
        }
Example #24
0
        public CommentMessageMetadata(IMirrativComment comment, ICommentOptions options, IMirrativSiteOptions siteOptions, IUser user, ICommentProvider cp, bool isFirstComment)
            : base(options, siteOptions)
        {
            User            = user;
            CommentProvider = cp;
            _isFirstComment = isFirstComment;

            user.PropertyChanged += User_PropertyChanged;
        }
 public PeriscopeCommentProvider2(IDataServer server, ILogger logger, ICommentOptions options, IPeriscopeSiteOptions siteOptions, IUserStoreManager userStoreManager)
     : base(logger, options)
 {
     _server           = server;
     _logger           = logger;
     _options          = options;
     _siteOptions      = siteOptions;
     _userStoreManager = userStoreManager;
 }
 public SystemInfoCommentViewModel(ICommentOptions options, string message, InfoType type)
     : base(options, _user, null, false)
 {
     MessageItems = new List <IMessagePart>
     {
         MessagePartFactory.CreateMessageText(message),
     };
     Type = type;
 }
 /// <summary>
 /// 投げ銭とかアイテムとかユーザを識別したい場合に使う
 /// </summary>
 /// <param name="options"></param>
 /// <param name="message"></param>
 /// <param name="user"></param>
 public BroadcastInfoCommentViewModel(ICommentOptions options, List <IMessagePart> messageItems, IUser user, ICommentProvider cp)
     : base(options, user, cp, false)
 {
     if (user == null)
     {
         throw new ArgumentNullException(nameof(user));
     }
     MessageItems = messageItems;
 }
Example #28
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="message"></param>
        /// <param name="options"></param>
        /// <param name="siteOptions"></param>
        /// <param name="user">null可</param>
        /// <param name="cp"></param>
        /// <param name="isFirstComment"></param>
        public MessageMetadataBase(ICommentOptions options, IWhowatchSiteOptions siteOptions, ICommentProvider cp)
        {
            _options        = options;
            _siteOptions    = siteOptions;
            CommentProvider = cp;

            options.PropertyChanged     += Options_PropertyChanged;
            siteOptions.PropertyChanged += SiteOptions_PropertyChanged;
        }
        public SiteContextBase(ICommentOptions options, IUserStoreManager userStoreManager, ILogger logger)
        {
            Options           = options;
            _userStoreManager = userStoreManager;
            _logger           = logger;
            var userStore = new SQLiteUserStore(options.SettingsDirPath + "\\" + "users_" + DisplayName + ".db", logger);

            userStoreManager.SetUserStore(SiteType, userStore);
        }
Example #30
0
 public LineLiveCommentProvider(IDataServer server, ILogger logger, ICommentOptions options, LineLiveSiteOptions siteOptions, IUserStoreManager userStoreManager)
 {
     _server           = server;
     _logger           = logger;
     _options          = options;
     _siteOptions      = siteOptions;
     _userStoreManager = userStoreManager;
     CanConnect        = true;
     CanDisconnect     = false;
 }