예제 #1
0
 private async void button71_Click(object sender, EventArgs e)
 {
     followerService = new TwitchLib.Services.FollowerService(api);
     followerService.SetChannelByChannelId(textBox68.Text);
     followerService.OnNewFollowersDetected += onFollowersDetected;
     await followerService.StartService();
 }
예제 #2
0
 public ViewerContext(MvcContext ctx)
 {
     friendService = new FriendService();
     msgService    = new MessageService();
     followService = new FollowerService();
     this.ctx      = ctx;
 }
예제 #3
0
            private async Task ConfigLiveMonitorAsync(string clientid, string access_token, string channel)
            {
                API = new TwitchAPI();

                API.Settings.ClientId    = clientid;
                API.Settings.AccessToken = access_token;

                Monitor = new LiveStreamMonitorService(API, 60);

                Monitor.SetChannelsByName(new List <string> {
                    channel
                });

                /*
                 * Monitor.OnStreamOnline += Monitor_OnStreamOnline;
                 * Monitor.OnStreamOffline += Monitor_OnStreamOffline;
                 * Monitor.OnStreamUpdate += Monitor_OnStreamUpdate;
                 *
                 * Monitor.OnServiceStarted += Monitor_OnServiceStarted;
                 * Monitor.OnChannelsSet += Monitor_OnChannelsSet;
                 */
                Service = new FollowerService(API);
                if (Program.config.format_onfollow != null)
                {
                    Service.OnNewFollowersDetected += Monitor_onNewFollowersDetected;
                }

                Service.Start();
                Monitor.Start();                 //Keep at the end!

                await Task.Delay(-1);
            }
예제 #4
0
        public async Task InitializeAsync(string userName, string oauthToken, string channel)
        {
            var credentials = new ConnectionCredentials(userName, oauthToken);

            _client = new TwitchClient();
            _client.Initialize(credentials, channel);

            _client.OnLog             += OnLog;
            _client.OnConnectionError += OnConnectionError;
            _client.OnConnected       += OnConnected;
            _client.OnJoinedChannel   += OnJoinedChannel;
            _client.OnNewSubscriber   += OnNewSubscriber;
            //_client.OnMessageReceived += OnMessageReceived;

            _twitchAPI.Settings.ClientId    = _options.TwitchClientId;
            _twitchAPI.Settings.AccessToken = _options.TwitchSecret;
            _service = new FollowerService(_twitchAPI);
            _service.SetChannelsByName(new List <string> {
                "SpyderHunter03"
            });
            _service.OnServiceStarted       += OnServiceStarted;
            _service.OnServiceTick          += OnServiceTick;
            _service.OnNewFollowersDetected += OnNewFollowersDetected;

            await Task.Run(() => _client.Connect());

            _logger.LogInformation($"Got passed Connect");
            await Task.Run(() => _service.Start());

            _logger.LogInformation($"Got passed Start");
        }
예제 #5
0
        internal void Connect()
        {
            LoadConfig();
            ConnectionCredentials credential = new ConnectionCredentials(config.BotUserName, config.BotToken);

            createSynth();

            client    = new TwitchClient();
            twitchAPI = new TwitchAPI();

            FollowerService followerService = new FollowerService(twitchAPI, 1, 25);

            client.Initialize(credential, config.ChannelName);

            Console.WriteLine("Connecting");

            client.ChatThrottler    = new MessageThrottler(client, 10, TimeSpan.FromSeconds(30));
            client.WhisperThrottler = new MessageThrottler(client, 10, TimeSpan.FromSeconds(30));

            followerService.OnNewFollowersDetected += Follow_OnNewFollowerDetected;
            client.OnLog += Client_OnLog;

            client.OnConnectionError += Client_OnConnectionError;
            client.OnMessageReceived += Client_OnMessageReceived;
            client.OnUserJoined      += Client_OnUserJoined;
            client.OnBeingHosted     += Client_OnBeingHosted;

            client.Connect();

            Console.WriteLine("Success");
            synth.Speak("Conectado");
        }
예제 #6
0
 public TwitchBotApplication(Configuration appConfig, TwitchInfoService twitchInfo, SongRequestBlacklistService songRequestBlacklist,
                             FollowerService follower, BankService bank, FollowerSubscriberListener followerListener, ManualSongRequestService manualSongRequest, PartyUpService partyUp,
                             GameDirectoryService gameDirectory, QuoteService quote, BankHeist bankHeist, TwitchChatterListener twitchChatterListener, IrcClient irc,
                             BossFight bossFight, SongRequestSettingService songRequestSetting, InGameUsernameService ign, LibVLCSharpPlayer libVLCSharpPlayer)
 {
     _appConfig    = appConfig;
     _botConfig    = appConfig.GetSection("TwitchBotConfig") as TwitchBotConfigurationSection;
     _greetedUsers = new List <string>();
     _twitchInfo   = twitchInfo;
     _follower     = follower;
     _followerSubscriberListener = followerListener;
     _bank = bank;
     _songRequestBlacklist = songRequestBlacklist;
     _manualSongRequest    = manualSongRequest;
     _gameDirectory        = gameDirectory;
     _quote                 = quote;
     _bankHeist             = bankHeist;
     _twitchChatterListener = twitchChatterListener;
     _bossFight             = bossFight;
     _songRequestSetting    = songRequestSetting;
     _ign = ign;
     _libVLCSharpPlayer = libVLCSharpPlayer;
     _irc     = irc;
     _partyUp = partyUp;
 }
예제 #7
0
        public ChatbotService(CommandHelper commandHelper, TwitchClient client, TwitchAPI api, TwitchPubSub pubsub, FollowerService followerService, VipHelper vipHelper, BytesHelper bytesHelper)
        {
            this.commandHelper   = commandHelper;
            this.client          = client;
            this.api             = api;
            this.pubsub          = pubsub;
            this.followerService = followerService;
            this.vipHelper       = vipHelper;
            this.bytesHelper     = bytesHelper;

            this.commandHelper.Init();

            client.OnJoinedChannel       += onJoinedChannel;
            client.OnChatCommandReceived += onCommandReceived;
            client.OnNewSubscriber       += onNewSub;
            client.OnReSubscriber        += onReSub;
            client.Connect();

            pubsub.OnPubSubServiceConnected += onPubSubConnected;
            pubsub.OnListenResponse         += onListenResponse;

            // followerService.OnNewFollowersDetected += onNewFollowers;

            pubsub.Connect();
        }
예제 #8
0
 public FriendController()
 {
     followService    = new FollowerService();
     friendService    = new FriendService();
     userService      = new UserService();
     blacklistService = new BlacklistService();
 }
예제 #9
0
        protected virtual void StartFollowerService()
        {
            StopFollowerService();

            _followerService = new FollowerService(_twitchAPI);
            _followerService.OnNewFollowersDetected += OnNewFollowerDetected;
        }
예제 #10
0
            public async void OnNewFollowersDetected_NotRaised_When_NoNewFollowers()
            {
                var usersFollowsResponseJson = JMock.Of <GetUsersFollowsResponse>(o =>
                                                                                  o.Follows == new[]
                {
                    Mock.Of <Follow>(f => f.FromUserId == "FromUserId")
                }
                                                                                  );

                _api = TwitchLibMock.TwitchApi(
                    ("https://api.twitch.tv/helix/users/follows", usersFollowsResponseJson)
                    );

                var eventExcecutCount = 0;

                _followerService = new FollowerService(_api);
                _followerService.SetChannelsById(Utils.CreateListWithEmptyString());
                _followerService.OnNewFollowersDetected += (sender, e) => eventExcecutCount++;

                await _followerService.UpdateLatestFollowersAsync();

                await _followerService.UpdateLatestFollowersAsync();

                Assert.Equal(1, eventExcecutCount);
            }
예제 #11
0
        public async Task GetFollowsByUserIdAsync_Should_Pass()
        {
            // Arrange
            FollowerDto followerDto1 = new FollowerDto
            {
                UserId         = 1,
                FollowerUserId = 2
            };
            FollowerDto followerDto2 = new FollowerDto
            {
                UserId         = 3,
                FollowerUserId = 2
            };
            FollowerDto followerDto3 = new FollowerDto
            {
                UserId         = 4,
                FollowerUserId = 2
            };
            await FollowerService.FollowUserAsync(followerDto1);

            await FollowerService.FollowUserAsync(followerDto2);

            await FollowerService.FollowUserAsync(followerDto3);

            // Act
            List <Follower> follows = (await FollowerRepository.FindManyByExpressionAsync(follower => follower.FollowerUserId.Equals(2))).ToList();

            // Assert
            Assert.IsTrue(follows.All(follower => follower.UserId.Equals(1) || follower.UserId.Equals(3) || follower.UserId.Equals(4)));
        }
        private async Task StartTwitchMonitoring()
        {
            var api = new TwitchLib.TwitchAPI(clientId: ClientId);

            Service = new FollowerService(api);
            Service.SetChannelByName(Channel);
            await Service.StartService();

            var v5 = new TwitchLib.Channels.V5(api);

            var follows = await v5.GetAllFollowersAsync(ChannelId);

            _CurrentFollowerCount           = follows.Count;
            Service.OnNewFollowersDetected += Service_OnNewFollowersDetected;

            var v5Stream = CreateTwitchStream(api);

            if (v5Stream == null)
            {
                await Task.Delay(2000);
                await StartTwitchMonitoring();

                return;
            }
            var myStream = await v5Stream.GetStreamByUserAsync(ChannelId);

            _CurrentViewerCount = myStream.Stream?.Viewers ?? 0;

            Logger.LogInformation($"Now monitoring Twitch with {_CurrentFollowerCount} followers and {_CurrentViewerCount} Viewers");

            _Timer = new Timer(CheckViews, v5Stream, 0, 5000);
        }
예제 #13
0
            public async void OnNewFollowersDetected_Raised_When_NewFollower()
            {
                var usersFollowsResponseFirstUserJson = JMock.Of <GetUsersFollowsResponse>(o =>
                                                                                           o.Follows == new[]
                {
                    Mock.Of <Follow>(f => f.FromUserId == "FromFirstUserId")
                }
                                                                                           );

                var mockHandler = TwitchLibMock.HttpCallHandler(("https://api.twitch.tv/helix/users/follows", usersFollowsResponseFirstUserJson));

                _api = TwitchLibMock.TwitchApi(mockHandler);

                var eventExecuteCount = 0;

                _followerService = new FollowerService(_api);
                _followerService.SetChannelsById(Utils.CreateListWithEmptyString());
                _followerService.OnNewFollowersDetected += (sender, e) => eventExecuteCount++;

                await _followerService.UpdateLatestFollowersAsync();

                var usersFollowsResponseSecondUserJson = JMock.Of <GetUsersFollowsResponse>(o =>
                                                                                            o.Follows == new[]
                {
                    Mock.Of <Follow>(f => f.FromUserId == "FromSecondUserId")
                }
                                                                                            );

                TwitchLibMock.ResetHttpCallHandlerResponses(mockHandler, ("https://api.twitch.tv/helix/users/follows", usersFollowsResponseSecondUserJson));

                await _followerService.UpdateLatestFollowersAsync();

                Assert.Equal(2, eventExecuteCount);
            }
예제 #14
0
 private void CreateFollowerService(TwitchConfiguration twitchConfiguration, TwitchAPI api)
 {
     followerService = new FollowerService(api, 10);
     followerService.SetChannelsByName(new List <string> {
         twitchConfiguration.Username
     });                                                                                   // TODO ändern!
 }
예제 #15
0
        public async Task InitializeAsync()
        {
            ApplicationDbFactory = new ApplicationDbFactory("InMemoryDatabase");
            await ApplicationDbFactory.Create().Database.EnsureDeletedAsync();

            await ApplicationDbFactory.Create().Database.EnsureCreatedAsync();

            ApplicationDbFactory.Create().ResetValueGenerators();

            ApplicationUserRepository = new UserRepository(ApplicationDbFactory.Create(), ApplicationUserValidator);
            FollowerRepository        = new FollowerRepository(ApplicationDbFactory.Create(), FollowerValidator);
            CredentialRepository      = new CredentialRepository(ApplicationDbFactory.Create(), CredentialValidator);
            CredentialTypeRepository  = new CredentialTypeRepository(ApplicationDbFactory.Create(), CredentialTypeValidator);
            RoleRepository            = new RoleRepository(ApplicationDbFactory.Create(), RoleValidator);
            UserRoleRepository        = new UserRoleRepository(ApplicationDbFactory.Create(), UserRoleValidator);
            RolePermissionRepository  = new RolePermissionRepository(ApplicationDbFactory.Create(), RolePermissionValidator);
            PermissionRepository      = new PermissionRepository(ApplicationDbFactory.Create(), PermissionValidator);
            HttpContextAccessor       = new HttpContextAccessor(); // NOTE: Don't actually use it, when using Startup it will inject the HttpContext. (here it will always be null)

            UserManager     = new UserManager(ApplicationUserRepository, CredentialTypeRepository, CredentialRepository, RoleRepository, UserRoleRepository, RolePermissionRepository, PermissionRepository, HttpContextAccessor, Hasher, SaltGenerator);
            UserService     = new UserService(UserManager, ApplicationUserRepository, FollowerRepository);
            FollowerService = new FollowerService(FollowerRepository, ApplicationUserRepository);

            // A Credential type is required for a user to be able to login or register.
            await CredentialTypeRepository.CreateAsync(new CredentialType
            {
                Code     = "Email",
                Name     = "Email",
                Position = 1
            });

            await UserService.SignUpAsync(new RegisterUserDto
            {
                Email    = "*****@*****.**",
                Password = "******",
                UserName = "******"
            });

            await UserService.SignUpAsync(new RegisterUserDto
            {
                Email    = "*****@*****.**",
                Password = "******",
                UserName = "******"
            });

            await UserService.SignUpAsync(new RegisterUserDto
            {
                Email    = "*****@*****.**",
                Password = "******",
                UserName = "******"
            });

            await UserService.SignUpAsync(new RegisterUserDto
            {
                Email    = "*****@*****.**",
                Password = "******",
                UserName = "******"
            });
        }
예제 #16
0
 // Empty constructor makes instance of Thread
 public FollowerSubscriberListener(TwitchBotConfigurationSection botConfig, TwitchInfoService twitchInfo, FollowerService follower, BankService bank)
 {
     _botConfig        = botConfig;
     _followerListener = new Thread(new ThreadStart(this.Run));
     _twitchInfo       = twitchInfo;
     _follower         = follower;
     _bank             = bank;
 }
예제 #17
0
        public ShareController()
        {
            feedService   = new FeedService();
            friendService = new FriendService();
            followService = new FollowerService();

            shareService = new ShareService();
        }
예제 #18
0
 public FriendController()
 {
     followService        = new FollowerService();
     friendService        = new FriendService();
     userService          = new UserService();
     blacklistService     = new BlacklistService();
     LayoutControllerType = typeof(MicroblogController);
 }
예제 #19
0
            public void Start_Throws_InvalidOperationException_When_ServiceAlreadyStarted()
            {
                _followerService = new FollowerService(_api);
                _followerService.SetChannelsById(Utils.CreateListWithEmptyString());
                _followerService.Start();

                AssertException.Throws <InvalidOperationException>(AlreadyStartedExceptionMessage, () => _followerService.Start());
            }
예제 #20
0
        public async Task GetFollowers_SuccessfulResult_ReturnsOkObjectResult()
        {
            var followerService = new FollowerService(new MockMapper(), new SuccessfulResultLogic());

            IActionResult result = await followerService.GetFollowers("");

            Assert.That(result.GetType() == typeof(OkObjectResult));
        }
        public MicroblogCommentsController()
        {
            microblogService = new MicroblogService();
            followService    = new FollowerService();
            commentService   = new MicroblogCommentService();

            LayoutControllerType = typeof(MicroblogController);
        }
예제 #22
0
 public WebApiTest()
 {
     _professionalService = new ProfessionalService();
     _patientService = new PatientService();
     _userService = new UserService();
     _documentService = new DocumentService();
     _followerService = new FollowerService();
 }
        internal void Connect()
        {
            Console.WriteLine("Connecting...");

            client = new TwitchClient();
            client.Initialize(credentials, TwitchInfo.ChannelName);

            //Client Events
            client.OnLog             += Client_OnLog;
            client.OnConnectionError += Client_OnConnectionError;
            client.OnMessageReceived += Client_OnMessageReceived;
            client.OnNewSubscriber   += Client_OnNewSubscriber;

            client.Connect();

            api = new TwitchAPI();
            api.Settings.ClientId    = TwitchInfo.ClientID;
            api.Settings.AccessToken = TwitchInfo.BotToken;


            //API Events
            monitor = new LiveStreamMonitorService(api, int.Parse(TwitchInfo.UpdateInterval));
            List <string> channels = new List <string>();

            channels.Add(TwitchInfo.ChannelName);
            monitor.SetChannelsByName(channels);
            monitor.OnStreamOffline += Monitor_OnStreamOffline;
            monitor.OnStreamOnline  += Monitor_OnStreamOnline;
            monitor.Start();

            fservice = new FollowerService(api, int.Parse(TwitchInfo.UpdateInterval));
            fservice.SetChannelsByName(channels);
            fservice.OnNewFollowersDetected += Fservice_OnNewFollowersDetected;
            fservice.Start();

            //Excel Stuff
            excel         = new Application();
            excel.Visible = true;
            wb            = excel.Workbooks.Open(TwitchInfo.ExcelPath);

            foreach (Worksheet sheet in wb.Sheets)
            {
                if (sheet.Name == TwitchInfo.ChannelName)
                {
                    Console.WriteLine("Found exisiting channel...");
                    ws = sheet;
                    break;
                }
            }

            if (ws == null)
            {
                //Create/copy a new worksheet from base worksheet
                Console.WriteLine("New channel detected, creating a new sheet...");
                ws      = (Worksheet)excel.Worksheets.Add();
                ws.Name = TwitchInfo.ChannelName;
            }
        }
예제 #24
0
 public StoryMaker()
 {
     this._gameMemberService = new GameMemberService();
     this._eventService      = new EventService();
     this._weatherService    = new WeatherService();
     this._followerService   = new FollowerService();
     this._dinnerService     = new DinnerService();
     this._signupService     = new SignupService();
 }
예제 #25
0
 public MicroblogController()
 {
     microblogService = new MicroblogService();
     followService    = new FollowerService();
     visitorService   = new VisitorService();
     mfService        = new MicroblogFavoriteService();
     commentService   = new OpenCommentService();
     matService       = new MicroblogAtService();
     userTagService   = new UserTagService();
 }
예제 #26
0
 public MicroblogController()
 {
     microblogService = new MicroblogService();
     followService    = new FollowerService();
     visitorService   = new VisitorService();
     mfService        = new MicroblogFavoriteService();
     commentService   = new MicroblogCommentService();
     matService       = new MicroblogAtService();
     videoSpider      = new WojiluVideoSpider();
 }
예제 #27
0
            public void OnChannelsSet_Raised_When_ChannelsSet()
            {
                var eventRaised = false;

                _followerService = new FollowerService(_api);
                _followerService.OnChannelsSet += (sender, e) => eventRaised = true;
                _followerService.SetChannelsById(Utils.CreateListWithEmptyString());

                Assert.True(eventRaised);
            }
예제 #28
0
        public BroadcasterInfo(DrakeBot bot, string id, string accessToken)
        {
            ID          = id;
            AccessToken = accessToken;
            follows     = new FollowerService(bot.Service);
            follows.SetChannelsById(new List <string>(new [] { id }));

            follows.OnNewFollowersDetected += bot.Follows_OnNewFollowersDetected;
            follows.Start();
        }
예제 #29
0
        public TwitchChatClient(TwitchClientSettings settings)
        {
            var credentials = new ConnectionCredentials(settings.TwitchUsername, settings.TwitchOAuth);

            _twitchClient    = new TwitchClient(credentials, settings.TwitchChannel);
            _twitchApi       = new TwitchAPI(settings.TwitchClientId);
            _followerService = new FollowerService(_twitchApi);
            _twitchClient.OnChatCommandReceived     += ChatCommandReceived;
            _twitchClient.OnNewSubscriber           += NewSubscriber;
            _followerService.OnNewFollowersDetected += NewFollower;
        }
예제 #30
0
        public BotController()
        {
            this._userService       = new UserService();
            this._signupService     = new SignupService();
            this._weatherService    = new WeatherService();
            this._eventService      = new EventService();
            this._gameMemberService = new GameMemberService();
            this._followerService   = new FollowerService();

            this._storyMaker = new Cores.StoryMaker();
        }
예제 #31
0
        public async Task GetFollowers_NotValidUsername_ReturnsErrorMessage()
        {
            var followerService = new FollowerService(new MockMapper(), new UserNotFoundLogic());

            IActionResult result = await followerService.GetFollowers("");

            var contentResult = (ContentResult)result;

            Assert.That(result.GetType() == typeof(ContentResult));
            Assert.That(contentResult.StatusCode == 404);
        }
예제 #32
0
        public void DeleteFollow()
        {
            using (ArchiViteContext context = new ArchiViteContext())
            {
                FollowerService _followerService = new FollowerService();
                DocumentManager dm = new DocumentManager(context);
                dm.DeleteFollowerFile(context.SelectRequest.SelectProfessional("SimonF", "SimonF").ProfessionalId, context.SelectRequest.SelectPatient("GuillaumeF", "GuillaumeF").PatientId);
                context.SuppressionRequest.FollowerSuppression(context.SelectRequest.SelectOneFollow(context.SelectRequest.SelectPatient("GuillaumeF", "GuillaumeF").PatientId, context.SelectRequest.SelectProfessional("SimonF", "SimonF").ProfessionalId));
                Assert.IsNull(context.SelectRequest.SelectOneFollow(context.SelectRequest.SelectPatient("GuillaumeF", "GuillaumeF").PatientId, context.SelectRequest.SelectProfessional("SimonF", "SimonF").ProfessionalId));

                FollowerCreation myNewFollow = new FollowerCreation(context.SelectRequest.SelectPatient("GuillaumeF", "GuillaumeF").PatientId,
                    context.SelectRequest.SelectProfessional("SimonF", "Simonf").ProfessionalId);
                _followerService.PutFollower(myNewFollow);
            }
        }