public CommandHandler(ArisaTwitchClient arisaTwitchClient) { ArisaTwitchClient = arisaTwitchClient; _commandTree = new CompactPrefixTree <ICommand>(16, 32, 32); Add(new CommandListCommand(this)); }
protected IntervalService(ArisaTwitchClient arisaTwitchClient, string serviceName) : base(arisaTwitchClient, serviceName) { Log($"starting in {PeriodAndOffset.Offset} ms"); _intervalTimer = new Timer(_ => IntervalCallback(), state: null, dueTime: PeriodAndOffset.Offset, period: PeriodAndOffset.Period); }
public CommandContext(ArisaTwitchClient arisaTwitchClient, ChatCommand chatCommand) { ArisaTwitchClient = arisaTwitchClient; ChatCommand = chatCommand; CommandName = chatCommand.CommandText; UserService = GetService <UserService>(); UserService.TryGetUserById(ChatMessage.UserId, out User); IsSelfCommand = User.Username.IgnoreCaseEquals(Constants.BotUsername); }
public UserService(ArisaTwitchClient arisaTwitchClient) : base(arisaTwitchClient, nameof(UserService)) { _usernameUserIdMap = new ConcurrentDictionary <string, string>(StringComparer.OrdinalIgnoreCase); _usersMap = new ConcurrentDictionary <string, User>(StringComparer.OrdinalIgnoreCase); _activeUsers = new ConcurrentDictionary <string, DateTime>(StringComparer.OrdinalIgnoreCase); using (var ctx = new UsersDbContext()) { foreach (var user in ctx.Users) { _usernameUserIdMap.TryAdd( user.Username, user.UserId); _usersMap.TryAdd( user.UserId, new User(this, user)); } } }
private void OnInterval() { TimeSpan?uptime = ArisaTwitchClient.TryGetStreamUptimeAsync().Result; if (uptime.HasValue) { var uptimeAsDate = new DateTime().AddMinutes(uptime.Value.TotalMinutes); Log("stream uptime is " + uptimeAsDate.ToString("dd HH:mm:ss")); int h = (int)uptime.Value.TotalHours; int m = uptime.Value.Minutes; string hString = $"{h} hour{(h > 1 ? "s" : "")}"; string mString = $"{m} minute{(m > 1 ? "s" : "")}"; string message = "You have been entertaining us for the past "; if (h == 0 && m == 0) { message += "few moments"; } else if (h > 0) { message += hString + (m > 0 ? (" and " + mString) : ""); } else { message += mString; } message += ". "; message += _hydrationMessages.PickRandom(); SendMessage(message); } else { Log("failed to get stream uptime"); } }
public HydrationService(ArisaTwitchClient arisaTwitchClient) : base(arisaTwitchClient, nameof(HydrationService)) { }
public TwitchPrimeReminderService(ArisaTwitchClient arisaTwitchClient) : base(arisaTwitchClient, nameof(TwitchPrimeReminderService)) { }
protected ServiceBase(ArisaTwitchClient arisaTwitchClient, string serviceName) { ArisaTwitchClient = arisaTwitchClient; ServiceName = serviceName; }