private void StartSpecificGame(User targetPlayer, string requestingPlayerId, string requestingPlayerName, string channel) { Channel ChannelInfo = APICalls.GetChannelInfo(channel); List <string> UsersInChannel = ChannelInfo.members.ToList(); if (UsersInChannel.Contains(targetPlayer.id)) { GameRound newRound = new GameRound { PlayerOne = requestingPlayerId, PlayerTwo = targetPlayer.id, Channel = channel, PlayerSpecific = true }; Sender.SendMessage(new RTMMessageOut { channel = channel, text = $"{requestingPlayerName} wants to fist bump {targetPlayer.name}" }); ConsoleMessenger.PrintSuccess($"New game started by {requestingPlayerId}"); CurrentGames.Add(newRound); } else { Sender.SendMessage(new RTMMessageOut { channel = channel, text = $"{targetPlayer.name} is not this channel" }); } }
private void StartOpenGame(GameRound newRound, string playerName) { CurrentGames.Add(newRound); Sender.SendMessage(new RTMMessageOut { channel = newRound.Channel, text = $"{playerName} is looking for a fistbump! \nType \"!FistBump\" to bump {playerName} back!" }); ConsoleMessenger.PrintSuccess($"New game started by {playerName}"); }
public static void JoinChannel(string channelName) { APICaller AC = new APICaller(); var content = new FormUrlEncodedContent(new[] { new KeyValuePair <string, string>("token", SlackConnector.AuthToken), new KeyValuePair <string, string>("name", channelName) }); AC.CallAPI(content, "https://slack.com/api/channels.join"); ConsoleMessenger.PrintSuccess("Joined Channel: " + channelName); }
public static void Load() { Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); config.AppSettings.Settings.Clear(); try { var lines = File.ReadLines(".env"); foreach (var line in lines) { var data = line.Split('='); config.AppSettings.Settings.Add(data[0], data[1]); config.Save(ConfigurationSaveMode.Modified, true); ConfigurationManager.RefreshSection("appSettings"); } } catch (FileNotFoundException) { ConsoleMessenger.PrintError("Could not locate .env file"); } catch (PathTooLongException) { ConsoleMessenger.PrintError("File path too long"); } ConsoleMessenger.PrintSuccess(".env loaded"); }
private void FinishGame(GameRound round, string requestingPlayerName = "", string requestingPlayerId = "") { if (!round.PlayerSpecific) { //finish open game round.PlayerTwo = requestingPlayerId; ArchiveGame(round); Sender.SendMessage(new RTMMessageOut { channel = round.Channel, text = $"{requestingPlayerName} Fist bumped {Users.FindUser(round.PlayerOne).name} back!" }); ConsoleMessenger.PrintSuccess("Game Finished"); } else { //finish specific game ArchiveGame(round); Sender.SendMessage(new RTMMessageOut { channel = round.Channel, text = $"{Users.FindUser(round.PlayerTwo).name} Fist bumped {Users.FindUser(round.PlayerOne).name} back!" }); } }
private static void OnOpen(object sender, EventArgs e) { ConsoleMessenger.PrintSuccess("Connected to slack websocket"); }