public static RotationResponse FindRotation(GOPContext db, decimal channelId, DateTimeZone zone) { var rotation = db.Rotations .Include(r => r.RotationUsers) .ThenInclude(ru => ru.User) .FirstOrDefault(r => r.ChannelId == channelId && r.Timezone == zone.ToString()); if (rotation == null) { return new RotationResponse { TimezoneValid = true, Timezone = zone, ErrorMessage = Responses.UnknownRotationResponse(zone.ToString()) } } ; return(new RotationResponse { TimezoneValid = true, Timezone = zone, Rotation = rotation }); }
public string Compute(GOPContext db, SocketMessage message) { _db = db; _message = message; var channelId = message.Channel.Id; var zoneText = message.Content.Split(" ").Last(); var zone = DateTimeZoneProviders.Tzdb.GetZoneOrNull(zoneText); if (zone == null) { return(Responses.InvalidTimeZoneResponse(zoneText)); } var response = RotationHelpers.FindRotation(db, channelId, zone); if (response.Rotation == null) { return(response.ErrorMessage); } db.Rotations.Remove(response.Rotation); db.SaveChanges(); return($"{zone} successfully removed."); }
public string Compute(GOPContext db, SocketMessage message) { return($"**Galaxy-of-payouts** is a bot designed to help arena shards in organizing rotation based payouts." + Environment.NewLine + $"You can create rotations, which will automatically post a ranking list in the specified timezone at 5pm." + Environment.NewLine + $"After the scheduled posting, it will automatically rotate the payout to the next in line." + Environment.NewLine + $"In order to get help with the various subcommands of !rotation, type **!help <commandName>**" + Environment.NewLine + $"The list of commands available currently are *create, get, delete, add, remove, and arrange.*"); }
public DiscordNetNotifications(ILogger <DiscordNetLogger> logger, GOPContext db, NotificationTimerElapsed notificationTimerElapsed) { _logger = logger; _db = db; _notificationTimerElapsed = notificationTimerElapsed; RegisterObservers(); }
public NotificationObserver(GOPContext db, IObservable <DiscordSocketClient> provider) { _db = db; if (provider.IsNotNull()) { _unsubscriber = provider.Subscribe(this); } }
public HelpObserver(GOPContext db, IObservable <SocketMessage> provider) { _db = db; if (provider.IsNotNull()) { _unsubscriber = provider.Subscribe(this); } }
public DiscordNetHostedService(AppConfig config, ILogger <DiscordNetHostedService> logger, LogMessageFactory messageFactory, GOPContext db, DiscordSocketClient client, DiscordNetLogger discordLogger, DiscordNetNotifications discordNotifications, MessageReceived messageReceived) { _config = config; _logger = logger; _db = db; _messageFactory = messageFactory; _client = client; _discordLogger = discordLogger; _discordNotifications = discordNotifications; _messageReceived = messageReceived; SetClientEvents(); }
public string Compute(GOPContext db, SocketMessage message) { _db = db; _message = message; var channelId = message.Channel.Id; var zoneText = message.Content.Split(" ").Last(); var zone = DateTimeZoneProviders.Tzdb.GetZoneOrNull(zoneText); if (zone == null) return GetAll(channelId); var response = RotationHelpers.FindRotation(db, channelId, zone); if (response.Rotation == null) return response.ErrorMessage; return response.Rotation.ToFormattedMessage(); }
public string Compute(GOPContext db, SocketMessage message) { _db = db; _message = message; var channelId = message.Channel.Id; var zoneText = message.Content.Split(" ")[1]; var zone = DateTimeZoneProviders.Tzdb.GetZoneOrNull(zoneText); if (zone == null) { return(Responses.InvalidTimeZoneResponse(zoneText)); } var response = RotationHelpers.FindRotation(db, channelId, zone); if (response.Rotation == null) { return(response.ErrorMessage); } if (response.Rotation.RotationUsers.Count == 0) { return($"You must add players to this rotation before you can arrange them."); } var split = message.Content.Split(" ").Skip(3); var players = string.Join(" ", split); if (players == string.Empty) { return($"You must supply a player or list of players in the order they should appear in the ranks."); } var playerList = players.Split(',').ToList(); var usersResult = RotationHelpers.GetDiscordUsers(message, playerList); if (usersResult.Failure) { return(usersResult.Message); } ArrangeUsersInRotation(response.Rotation, usersResult.Value); return(RotationHelpers.GetRotation(db, response.Rotation.Id).ToFormattedMessage()); }
public string Compute(GOPContext db, SocketMessage message) { _db = db; _message = message; var channelId = message.Channel.Id; var zoneText = message.Content.Split(" ")[1]; var zone = DateTimeZoneProviders.Tzdb.GetZoneOrNull(zoneText); if (zone == null) { return(Responses.InvalidTimeZoneResponse(zoneText)); } var response = RotationHelpers.FindRotation(db, channelId, zone); if (response.Rotation == null) { return(response.ErrorMessage); } var split = message.Content.Split(" ").Skip(3); var players = string.Join(" ", split); if (players == string.Empty) { return($"You must supply a player or list of players to remove."); } if (response.Rotation.RotationUsers.Count == 0) { return($"The rotation for {zone} does not have any players to remove."); } var playerList = players.Split(',').ToList(); var usersResult = RotationHelpers.GetDiscordUsers(message, playerList); if (usersResult.Failure) { return(usersResult.Message); } RemovePlayersFromRotation(response.Rotation, usersResult.Value); return(RotationHelpers.GetRotation(db, response.Rotation.Id).ToFormattedMessage()); }
public string RunCommand(GOPContext db, SocketMessage message) { var command = default(ICommand); if (message.Content.StartsWith("!help", StringComparison.OrdinalIgnoreCase)) { return(_commands[message.Content.ToLower()].Compute(db, message)); } if (!message.Content.StartsWith("!rotation", StringComparison.OrdinalIgnoreCase)) { return(string.Empty); } if (message.Content.Contains("create", StringComparison.OrdinalIgnoreCase)) { command = _commands["!rotation create"]; } if (message.Content.Contains("delete", StringComparison.OrdinalIgnoreCase)) { command = _commands["!rotation delete"]; } if (message.Content.Contains("get", StringComparison.OrdinalIgnoreCase)) { command = _commands["!rotation get"]; } if (message.Content.Contains("add", StringComparison.OrdinalIgnoreCase)) { command = _commands["!rotation add"]; } if (message.Content.Contains("remove", StringComparison.OrdinalIgnoreCase)) { command = _commands["!rotation remove"]; } if (message.Content.Contains("arrange", StringComparison.OrdinalIgnoreCase)) { command = _commands["!rotation arrange"]; } if (command.IsNull()) { command = _commands["!rotation"]; } return(command.Compute(db, message)); }
public string Compute(GOPContext db, SocketMessage message) { _db = db; _message = message; var channelId = message.Channel.Id; var zoneText = message.Content.Split(" ").Last(); var zone = DateTimeZoneProviders.Tzdb.GetZoneOrNull(zoneText); if (zone == null) { return(Responses.InvalidTimeZoneResponse(zoneText)); } var response = RotationHelpers.FindRotation(db, channelId, zone); if (!response.TimezoneValid) { return(response.ErrorMessage); } if (response.Rotation != null) { return($"There is already a rotation saved for {zone}"); } var rotation = new Rotations(); rotation.ChannelId = channelId; rotation.Timezone = zone.ToString(); db.Rotations.Add(rotation); db.SaveChanges(); return($"Successfully created a new rotation for {zone}."); }
public NotificationBehavior(GOPContext db, DiscordSocketClient client) { _db = db; _client = client; }
public string Compute(GOPContext db, SocketMessage message) { return($"**!rotation create <timezone>:** This will create a new rotation in the designated timezone." + Environment.NewLine + $"Timezones are based off of the standard IANA Timezones which you can find here: http://www.joda.org/joda-time/timezones.html"); }
public string Compute(GOPContext db, SocketMessage message) { return($"**!rotation <timezone> add <comma separated list of player(s)>:** This will arrange the player(s) in the specified timezone." + Environment.NewLine + $"Player(s) will be moved to the top of the ranks in the order they appear in the specified list."); }
public string Compute(GOPContext db, SocketMessage message) { return($"**!rotation <timezone> add <comma separated list of player(s)>:** This will add the player(s) to the specified timezone." + Environment.NewLine + $"Player(s) will be added in the order they appear in the specified list, and if you use valid discord names, it will use mentions in the scheduled posting."); }
public static Rotations GetRotation(GOPContext db, int rotationId) { return(db.Rotations .Include(r => r.RotationUsers).ThenInclude(ru => ru.User) .FirstOrDefault(r => r.Id == rotationId)); }
public string Compute(GOPContext db, SocketMessage message) { return($"**!rotation get <timezone or all>:** This will display one of or all of the stored rotations for the channel."); }
public HelpBehavior(GOPContext db, SocketMessage message) { _db = db; _message = message; }
public CommandBehavior(GOPContext db, SocketMessage message) { _db = db; _message = message; }
public string Compute(GOPContext db, SocketMessage message) { return($"**!rotation <timezone> remove <comma separated list of player(s)>:** This will remove the player(s) from the specified timezone." + Environment.NewLine + $"Leftover players will be moved up in ranks, but remain in the order they were in before removing other players."); }
public string Compute(GOPContext db, SocketMessage message) { return($"**!rotation delete <timezone>:** This will remove the designated rotation."); }