Ejemplo n.º 1
0
        public NiconicoChatService(
            NiconicoChatServiceSettings settings, ChannelDatabase channelDatabase,
            string jikkyouIdTableFilePath, string liveIdTableFilePath
            )
        {
            this.settings       = settings;
            this.jkIdResolver   = new NiconicoUtils.JkIdResolver(channelDatabase, new NiconicoUtils.JkIdTable(jikkyouIdTableFilePath));
            this.liveIdResolver = new NiconicoUtils.LiveIdResolver(channelDatabase, new NiconicoUtils.LiveIdTable(liveIdTableFilePath));

            try
            {
                if (!string.IsNullOrWhiteSpace(UserId) && !string.IsNullOrWhiteSpace(UserPassword))
                {
                    SetUser(UserId, UserPassword).Wait();
                }
            }
            catch (AggregateException e)
                when(e.InnerExceptions.Count == 1 && e.InnerExceptions[0] is NiconicoUtils.NiconicoLoginSessionException)
                {
                }

            ChatCollectServiceEntries = new ChatCollectServiceEntry.IChatCollectServiceEntry[] {
                new ChatCollectServiceEntry.NewNiconicoJikkyouChatCollectServiceEntry(this, this.liveIdResolver, this.loginSession),
                new ChatCollectServiceEntry.NiconicoLiveChatCollectServiceEntry(this, this.loginSession),
                new ChatCollectServiceEntry.TsukumijimaJikkyoApiChatCollectServiceEntry(this, this.jkIdResolver),
            };
            ChatTrendServiceEntries = new IChatTrendServiceEntry[0];
        }
Ejemplo n.º 2
0
 public TsukumijimaJikkyoApiChatCollectService(
     ChatCollectServiceEntry.IChatCollectServiceEntry serviceEntry,
     NiconicoUtils.JkIdResolver jkIdResolver
     ) : base(TimeSpan.FromSeconds(10))
 {
     this.ServiceEntry = serviceEntry;
     this.jkIdResolver = jkIdResolver;
 }
 public PastNichanChatCollectService(
     ChatCollectServiceEntry.IChatCollectServiceEntry chatCollectServiceEntry,
     NichanUtils.INichanBoardSelector boardSelector,
     TimeSpan backTime
     ) : base(TimeSpan.FromSeconds(10))
 {
     this.ServiceEntry  = chatCollectServiceEntry;
     this.boardSelector = boardSelector;
     this.backTime      = backTime;
 }
Ejemplo n.º 4
0
        public NiconicoLogChatCollectService(ChatCollectServiceEntry.IChatCollectServiceEntry serviceEntry, NiconicoUtils.JkIdResolver jkIdResolver, NiconicoUtils.NiconicoLoginSession session) : base(new TimeSpan(0, 0, 10))
        {
            this.ServiceEntry = serviceEntry;
            this.jkIdResolver = jkIdResolver;
            this.session      = session;

            var handler = new HttpClientHandler();

            client = new HttpClient(handler);
            handler.CookieContainer.Add(session.Cookie);
        }
Ejemplo n.º 5
0
 public void AddService(ChatCollectServiceEntry.IChatCollectServiceEntry serviceEntry, ChatCollectServiceEntry.IChatCollectServiceCreationOption creationOption)
 {
     try
     {
         registeredServices.Add(serviceEntry.GetNewService(creationOption));
     }
     catch (ChatCollectServiceEntry.ChatCollectServiceCreationException e)
     {
         ErrorOccurredInServiceCreation?.Invoke(serviceEntry, e.Message);
     }
 }
Ejemplo n.º 6
0
        public PastNichanChatCollectService(
            ChatCollectServiceEntry.IChatCollectServiceEntry chatCollectServiceEntry,
            NichanUtils.INichanThreadSelector threadSelector,
            TimeSpan threadSelectionUpdateInterval
            ) : base(TimeSpan.FromSeconds(10))
        {
            this.ServiceEntry   = chatCollectServiceEntry;
            this.threadSelector = threadSelector;
            this.threadSelectionUpdateInterval = threadSelectionUpdateInterval;

            this.resCollectLoopTask = Task.Run(() => this.ResCollectLoop(this.resCollectLoopTaskCancellation.Token));
        }
Ejemplo n.º 7
0
        public NichanChatService(
            NichanChatServiceSettings settings, ChannelDatabase channelDatabase,
            string threadSettingFilePath
            )
        {
            this.settings = settings;

            // 設定構造変更に伴い設定値を移行
            if (settings.HmKey != null)
            {
                settings.GochanApi.HmKey = settings.HmKey;
                settings.HmKey           = null;
            }
            if (settings.AppKey != null)
            {
                settings.GochanApi.AppKey = settings.AppKey;
                settings.AppKey           = null;
            }
            if (settings.UserId != null)
            {
                settings.GochanApi.UserId = settings.UserId;
                settings.UserId           = null;
            }
            if (settings.Password != null)
            {
                settings.GochanApi.Password = settings.Password;
                settings.Password           = null;
            }

            var boardSetting = NichanUtils.ThreadSettingFileParser.Parse(threadSettingFilePath);

            boardDatabase  = new NichanUtils.BoardDatabase(boardSetting.BoardEntries, boardSetting.ThreadMappingRuleEntries);
            threadResolver = new NichanUtils.ThreadResolver(channelDatabase, boardDatabase);

            this.resCollectInterval.Value   = settings.ThreadUpdateInterval;
            this.threadSearchInterval.Value = settings.ThreadListUpdateInterval;
            this.nichanApiClient.Value      = new Nichan.ApiClient(
                settings.GochanApi.HmKey, settings.GochanApi.AppKey,
                settings.GochanApi.UserId, settings.GochanApi.Password,
                settings.GochanApi.AuthUserAgent, settings.GochanApi.AuthX2chUA, settings.GochanApi.UserAgent
                );
            this.pastCollectServiceBackTime.Value = settings.PastCollectServiceBackTime;

            ChatCollectServiceEntries = new ChatCollectServiceEntry.IChatCollectServiceEntry[] {
                new ChatCollectServiceEntry.DATNichanChatCollectServiceEntry(this, resCollectInterval, threadSearchInterval, threadResolver, nichanApiClient),
                new ChatCollectServiceEntry.PastNichanChatCollectServiceEntry(this, threadResolver, pastCollectServiceBackTime),
            };
            ChatTrendServiceEntries = new IChatTrendServiceEntry[0];

            BoardList = boardDatabase.BoardList.Select(x => new BoardInfo(x.Title, x.Uri));
        }
        public NiconicoChatCollectService(ChatCollectServiceEntry.IChatCollectServiceEntry serviceEntry, NiconicoUtils.JkIdResolver jkIdResolver, NiconicoUtils.NiconicoLoginSession session)
        {
            ServiceEntry      = serviceEntry;
            this.jkIdResolver = jkIdResolver;

            if (session != null)
            {
                var handler = new HttpClientHandler();
                handler.CookieContainer.Add(session.Cookie);
                httpClient = new HttpClient(handler);
                CanPost    = true;
            }
            else
            {
                httpClient = new HttpClient();
                CanPost    = false;
            }
            httpClient.BaseAddress = new Uri("http://jk.nicovideo.jp");
        }
        public NewNiconicoJikkyouChatCollectService(
            ChatCollectServiceEntry.IChatCollectServiceEntry serviceEntry,
            NiconicoUtils.LiveIdResolver liveIdResolver,
            NiconicoUtils.NiconicoLoginSession niconicoLoginSession
            )
        {
            this.ServiceEntry   = serviceEntry;
            this.liveIdResolver = liveIdResolver;

            var assembly = Assembly.GetExecutingAssembly().GetName();
            var ua       = assembly.Name + "/" + assembly.Version.ToString(3);

            var handler = new HttpClientHandler();

            handler.CookieContainer.Add(niconicoLoginSession.Cookie);
            this.httpClient = new HttpClient(handler);
            this.httpClient.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", ua);

            this.commentReceiver = new NiconicoUtils.NicoLiveCommentReceiver(niconicoLoginSession);
            this.commentSender   = new NiconicoUtils.NicoLiveCommentSender(niconicoLoginSession);
        }
        public NiconicoLiveChatCollectService(
            ChatCollectServiceEntry.IChatCollectServiceEntry serviceEntry, string liveId,
            NiconicoUtils.NiconicoLoginSession session
            )
        {
            this.ServiceEntry   = serviceEntry;
            this.originalLiveId = liveId;

            var assembly = Assembly.GetExecutingAssembly().GetName();
            var ua       = assembly.Name + "/" + assembly.Version.ToString(3);

            var handler = new HttpClientHandler();

            handler.CookieContainer.Add(session.Cookie);
            this.httpClient = new HttpClient(handler);
            this.httpClient.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", ua);

            this.commentReceiver = new NiconicoUtils.NicoLiveCommentReceiver(session);
            this.commentSender   = new NiconicoUtils.NicoLiveCommentSender(session);

            this.chatCollectTask = this.collectChat(this.cancel.Token);
        }
Ejemplo n.º 11
0
 public void AddCreationPreset(string name, ChatCollectServiceEntry.IChatCollectServiceEntry serviceEntry, ChatCollectServiceEntry.IChatCollectServiceCreationOption creationOption)
 {
     creationPresets.Add(new ChatCollectServiceCreationPreset(name, serviceEntry, creationOption));
 }
Ejemplo n.º 12
0
 public ChatCollectServiceCreationPreset(string name, ChatCollectServiceEntry.IChatCollectServiceEntry serviceEntry, ChatCollectServiceEntry.IChatCollectServiceCreationOption creationOption)
 {
     this.Name           = name;
     this.ServiceEntry   = serviceEntry;
     this.CreationOption = creationOption;
 }
Ejemplo n.º 13
0
 public void SetSourceService(ChatCollectServiceEntry.IChatCollectServiceEntry sourceService)
 {
     this.SourceService = sourceService;
 }
Ejemplo n.º 14
0
 public FileChatService()
 {
     ChatCollectServiceEntries = new ChatCollectServiceEntry.IChatCollectServiceEntry[1] {
         new ChatCollectServiceEntry.FileChatCollectServiceEntry(this)
     };
 }