Ejemplo n.º 1
0
        private void OnDiscordRequestRejected(object source, DiscordRPC.Message.JoinRequestMessage args)
        {
            GUI.Widgets.Notification_Widget.DiscordNotify src = (GUI.Widgets.Notification_Widget.DiscordNotify)source;
            src.OnRequestAccepted -= OnDiscordRequestAccepted;
            src.OnRequestRejected -= OnDiscordRequestRejected;

            Client.Respond(args, false);

            src.Close();
        }
Ejemplo n.º 2
0
        private void OnDiscordRequestRejected(object source, DiscordRPC.Message.JoinRequestMessage args)
        {
            GUI.Widgets.Notification_Widget.DiscordNotify src = (GUI.Widgets.Notification_Widget.DiscordNotify)source;
            src.OnRequestAccepted -= OnDiscordRequestAccepted;
            src.OnRequestRejected -= OnDiscordRequestRejected;

            Client.Respond(args, false);

            App.Current.Dispatcher.Invoke(new Action(() => { src.Close(); }));
        }
Ejemplo n.º 3
0
 //This is mostly handled through the Discord overlay now, so we can always accept for now
 private void Client_OnJoinRequested(object sender, JoinRequestMessage args)
 {
     Logger.LogInfo(string.Format("User {0} asked to join lobby", args.User.Username));
     Chat.AddMessage(string.Format("Discord user {0} has asked to join your game!", args.User.Username));
     //Always let people into your game for now
     client.Respond(args, true);
 }
Ejemplo n.º 4
0
        private static void OnJoinRequested(object sender, JoinRequestMessage args)
        {
            /*
             * This is called when the Discord Client has received a request from another external Discord User to join your game.
             * You should trigger a UI prompt to your user sayings 'X wants to join your game' with a YES or NO button. You can also get
             *  other information about the user such as their avatar (which this library will provide a useful link) and their nickname to
             *  make it more personalised. You can combine this with more API if you wish. Check the Discord API documentation.
             *
             *  Once a user clicks on a response, call the Respond function, passing the message, to respond to the request.
             *  A example is provided below.
             *
             * This feature requires the RegisterURI to be true on the client.
             */

            //We have received a request, dump a bunch of information for the user
            Console.WriteLine("'{0}' has requested to join our game.", args.User.Username);
            Console.WriteLine(" - User's Avatar: {0}", args.User.GetAvatarURL(User.AvatarFormat.GIF, User.AvatarSize.x2048));
            Console.WriteLine(" - User's Descrim: {0}", args.User.Discriminator);
            Console.WriteLine(" - User's Snowflake: {0}", args.User.ID);
            Console.WriteLine();

            //Ask the user if they wish to accept the join request.
            Console.Write("Do you give this user permission to join? [Y / n]: ");
            bool accept = Console.ReadKey().Key == ConsoleKey.Y; Console.WriteLine();

            //Tell the client if we accept or not.
            DiscordRpcClient client = (DiscordRpcClient)sender;

            client.Respond(args, accept);

            //All done.
            Console.WriteLine(" - Sent a {0} invite to the client {1}", accept ? "ACCEPT" : "REJECT", args.User.Username);
        }
Ejemplo n.º 5
0
        private void Respond(ushort id, Boolean response)
        {
            var request = requests[id];

            if (request == null)
            {
                Monitor.Log("Request ID doesn't exist.", LogLevel.Error);
            }
            client.Respond(request, response);
            Monitor.Log("Responding to join request. This may fail if 30 seconds have passed.", LogLevel.Info);
            requests[id] = null;
        }
Ejemplo n.º 6
0
        private void OnJoinRequested(object sender, JoinRequestMessage args)
        {
            Debugger.Discord(
                GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_DISCORD_JOIN_REQUEST']")
                .Replace("{Username}", args.User.ToString())
                );

            Application.Current.Dispatcher.InvokeAsync(() =>
            {
                DiscordNotify discordNotify      = new DiscordNotify(args);
                discordNotify.OnRequestAccepted += (src, args) =>
                {
                    client.Respond(args, true);
                };
                discordNotify.OnRequestRejected += (src, args) =>
                {
                    client.Respond(args, false);
                };
                discordNotify.Show();
            });
        }
Ejemplo n.º 7
0
        public async Task <bool> RequestAnswer(DiscordRpcClient client, JoinRequestMessage args)
        {
            LogWriter.WriteToFile("Incoming RPC request from " + args.User.Username);
            button1.Visible = true;
            button2.Visible = true;
            ChangeLabel     = $"SDR# RPC | {args.User.Username} has requested to get Spy Server Network address.";
            while (!AnswerA || !AnswerD) // TODO: Rework
            {
                LogWriter.WriteToFile("waiting...");
                Application.DoEvents();
                await Task.Delay(200).ConfigureAwait(false);
            }
            bool tmpansw = AnswerA;

            LogWriter.WriteToFile($"Client sent an answer. {tmpansw}");
            client.Respond(args, tmpansw);
            AnswerA         = false;
            AnswerD         = false;
            button1.Visible = false;
            button2.Visible = false;
            SetDefaultTextInLabel(tmpansw);
            return(tmpansw);
        }