public static DiscordClient UsingAudio(this DiscordClient client, Action<AudioServiceConfigBuilder> configFunc = null)
 {
     var builder = new AudioServiceConfigBuilder();
     configFunc(builder);
     client.Services.Add(new AudioService(builder));
     return client;
 }
예제 #2
0
        public static DiscordClient UsingAudio(this DiscordClient client, Action <AudioServiceConfigBuilder> configFunc = null)
        {
            var builder = new AudioServiceConfigBuilder();

            configFunc(builder);
            client.AddService(new AudioService(builder));
            return(client);
        }
예제 #3
0
 public AudioService(AudioServiceConfigBuilder builder)
     : this(builder.Build())
 {
 }
예제 #4
0
 public AudioService(AudioServiceConfigBuilder builder)
     : this(builder.Build())
 {
 }
예제 #5
0
		public static void Main(string[] cmdArgs) {
			args = cmdArgs;
			Console.Title = "MarkovioBot";

			appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\PoyoBots\MarkovioBot";

			for (int i = 0; i < args.Length; i++) {
				if (args[i].Equals("-token") && args[i + 1] != null) {
					token = args[i + 1];
				}

				if (args[i].Equals("-test") && args[i + 1] != null) {
					token = args[i + 1];
					appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\PoyoBots\MarkovioBotTest";
				}
			}

			if (token == null) {
				Console.Write("Token: ");
				token = Console.ReadLine();
			}

			Console.Clear();

			client.MessageReceived += OnMessageReceived;
			client.Ready += OnReady;
			client.GatewaySocket.Connected += OnConnected;

			client.GatewaySocket.Disconnected += OnDisconnected;

			client.JoinedServer += OnJoinedServer;

			servers = new List<DiscordServer>();
			users = new List<DiscordUser>();

			BackupHandler.Initialize();

			foreach (String file in Directory.GetFiles(appData + @"\Server Data")) {
				string fileText = File.ReadAllText(file);
				DiscordServer deserializedServer = JsonConvert.DeserializeObject<DiscordServer>(fileText);
				servers.Add(deserializedServer);
			}

			foreach (String file in Directory.GetFiles(appData + @"\User Data")) {
				string fileText = File.ReadAllText(file);
				DiscordUser deserializedUser = JsonConvert.DeserializeObject<DiscordUser>(fileText);
				if (deserializedUser != null) {
					users.Add(deserializedUser);
				} else {
					File.Delete(file);
				}
			}

			synth = new SpeechSynthesizer();
			synth.Rate = 1;

			try {
				synth.SelectVoice("Microsoft Haruka Desktop");
			} catch (Exception) { }

			AudioServiceConfigBuilder config = new AudioServiceConfigBuilder();

			config.Mode = AudioMode.Outgoing;
			config.Bitrate = 64;
			config.BufferLength = 10000;

			client.UsingAudio(config.Build());

			client.Connect(token);

			CurrentGameHandler.Initialize();

			while (!shouldExit) {
				bool hasBackedUp = false;

				try {
					hasBackedUp = new DirectoryInfo(appData + @"\Backups\")
						.GetDirectories()
						.OrderByDescending(SortFiles)
						.First()
						.CreationTime > DateTime.Now.AddDays(-2);
				} catch (InvalidOperationException) { }

				if (!hasBackedUp) {
					BackupHandler.Backup();
				}
			}
		}