Exemple #1
0
        public string CreateNew(Skype4Sharp.Skype4Sharp parentSkype, string usernamesToAdd)
        {
            string usernamesJson = "";

            if (!string.IsNullOrWhiteSpace(usernamesToAdd))
            {
                string[] usernames = usernamesToAdd.Split(',');
                foreach (var name in usernames)
                {
                    usernamesJson += $",{{\"id\":\"8:{name}\",\"role\":\"User\"}}";
                }
            }
            usernamesToAdd = @"{""members"":[{""id"":""28:8b270cdf-8d2a-41e7-bdb1-9108f3c220bd"",""role"":""User""},{""id"":""8:live:bigwebapps_1"",""role"":""Admin""}" + usernamesJson + "]}";
            string         chatId           = "";
            HttpWebRequest createNewRequest = parentSkype.mainFactory.createWebRequest_POST($"https://{parentSkype.authTokens.Endpoint}/v1/threads", new string[][] { new string[] { "RegistrationToken", parentSkype.authTokens.RegistrationToken } }, Encoding.ASCII.GetBytes(usernamesToAdd), "application/json");

            try
            {
                using (HttpWebResponse webResponse = (HttpWebResponse)createNewRequest.GetResponse())
                {
                    chatId = webResponse.GetResponseHeader("Location");
                    //"https://db5-client-s.gateway.messenger.live.com/v1/threads/19:[email protected]"
                    chatId = chatId.Substring(chatId.IndexOf("threads/") + 8);
                }
            }
            catch (WebException ex)
            {
                using (var stream = ex.Response.GetResponseStream())
                    using (var reader = new StreamReader(stream))
                    {
                        chatId = reader.ReadToEnd();
                    }
            }
            return(chatId);
        }
Exemple #2
0
        public void BroadcastLunchInfo(LunchInfo info)
        {
            Skype4Sharp.Skype4Sharp mainSkype = new Skype4Sharp.Skype4Sharp(_credentials);
            mainSkype.tokenType = Skype4Sharp.Enums.SkypeTokenType.OAuth;
            mainSkype.Login();

            Chat targetChat = new Chat(mainSkype);

            targetChat.ChatLink = _chatLink;
            mainSkype.SendMessage(targetChat, info.MenuMessage);
        }
Exemple #3
0
 public Program(SkypeCredentials authCreds)
 {
     this.authCreds = authCreds;
     mainSkype      = new Skype4Sharp.Skype4Sharp(authCreds);
     Console.WriteLine("[DEBUG]: Logging in with {0}:{1}", authCreds.Username, string.Join("", Enumerable.Repeat("*", authCreds.Password.Length)));
     mainSkype.Login();
     Console.WriteLine("[DEBUG]: Login complete");
     mainSkype.messageReceived        += MainSkype_messageReceived;
     mainSkype.contactRequestReceived += MainSkype_contactRequestReceived;
     Console.WriteLine("[DEBUG]: Events set");
     mainSkype.StartPoll();
     Console.WriteLine("[DEBUG]: Poll started");
 }
Exemple #4
0
        public CSkypeRetransmitter(IAlarmable alarmer) : base(alarmer)
        {
            //TODO security !
            SkypeCredentials inAuthCreds = new SkypeCredentials("konstantin_a_arapov", "Vfieyz2011");


            authCreds = inAuthCreds;
            mainSkype = new Skype4Sharp.Skype4Sharp(inAuthCreds);
            Console.WriteLine("[DEBUG]: Logging in with {0}:{1}", inAuthCreds.Username, string.Join("", Enumerable.Repeat("*", inAuthCreds.Password.Length)));
            mainSkype.Login();
            Console.WriteLine("[DEBUG]: Login complete");
            mainSkype.messageReceived        += MainSkype_messageReceived;
            mainSkype.contactRequestReceived += MainSkype_contactRequestReceived;
            Console.WriteLine("[DEBUG]: Events set");
        }
Exemple #5
0
        public MainForm()
        {
            InitializeComponent();

            bool   loginFlag = false;
            string user      = "";

            do
            {
                // Get login info from user
                Login userLogin = new Login();

                if (userLogin.ShowDialog() != DialogResult.OK || (userLogin.user == "" || userLogin.pass == ""))
                {
                    MessageBox.Show("You need to provide credentials to use this program.", "Skype Login Error", MessageBoxButtons.OK);
                    Environment.Exit(-1);
                }

                // create credential object
                Skype4Sharp.Auth.SkypeCredentials creds = new Skype4Sharp.Auth.SkypeCredentials(userLogin.user, userLogin.pass);

                mainSkype = new Skype4Sharp.Skype4Sharp(creds);
                if (mainSkype.Login())
                {
                    loginFlag = true;
                    user      = userLogin.user;
                }
                else
                {
                    MessageBox.Show("Login failed. Please try again.", "Skype Login Error", MessageBoxButtons.OK);
                }
            } while (loginFlag == false);

            mainSkype.messageReceived += OnMessage;
            skype_botName              = user;
            chatbot            = new ChatResponse();
            conversation_users = new List <myUser>();
            mainSkype.StartPoll();
        }
Exemple #6
0
        private string CreateSkypeGroup(string topic, string skypenames, string ticket, string data)
        {
            Skype4Sharp.Skype4Sharp mainSkype;
            SkypeCredentials        authCreds = new SkypeCredentials("*****@*****.**", "BIG4web1");

            //if (string.IsNullOrEmpty(skypenames))
            //    throw new HttpError(HttpStatusCode.NotFound, "Skype names are empty");
            mainSkype = new Skype4Sharp.Skype4Sharp(authCreds);
            //mainSkype.authTokens.SkypeToken = "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IjEyIn0.eyJpYXQiOjE1MDIzNjY3NTUsImV4cCI6MTUwMjQ1MzE0Nywic2t5cGVpZCI6ImxpdmU6Ymlnd2ViYXBwc18xIiwic2NwIjo5NTgsImNzaSI6IjEiLCJjaWQiOiJkNTRiODlhNjYzY2JkYmM2IiwiYWF0IjoxNTAyMjAxMTA0fQ.BFXZgoiS7rhMLgOGgj3D71PBnUn3R4kRTK6t5NhoEwweYVHEzunI3KpoDK2ap66pX_8H2SW9GTUtswb-FYoNJ2gh_-2RnBlu2a8xDhQwTAkAxyppzwVWC_Zs1s2FBWCbPkaq5iuw9v7H8XWE_JabKW6rCjFbs7CYISGKiziXjY0WXizguYJeVVZxoEM7PZkamqGgA-eLfKGLf8Vw";
            mainSkype.authTokens.SkypeToken = GetSkypeToken(false);
            mainSkype.Login();
            Chat newChat = new Chat(mainSkype);
            //string chatId = newChat.CreateNew(skypenames);
            var chatId = CreateNew(mainSkype, "");//, skypenames);

            newChat.ID = chatId;
            if (string.IsNullOrEmpty(chatId))
            {
                throw new HttpError(HttpStatusCode.NotFound, "Cannot create group chat");
            }
            if (!chatId.StartsWith("19:"))
            {
                return(chatId);
            }
            //newChat.ID = "19:[email protected]";
            newChat.Type           = ChatType.Group;
            newChat.JoiningEnabled = true;
            newChat.Topic          = topic;
            var joinUrl = newChat.JoinUrl;

            joinUrl += "?" + chatId.Substring(3, chatId.IndexOf("@thread.skype") - 3);
            string          token    = "";
            string          new_data = "[]";
            List <UserData> users    = new List <UserData>();

            if (!string.IsNullOrWhiteSpace(data) && data.StartsWith("{"))
            {
                dynamic userdata = JsonConvert.DeserializeObject(data);
                token = (string)userdata.t;
                for (int i = 0; i < userdata.users.Count; i++)
                {
                    var user = new UserData((string)userdata.users[i].id, (string)userdata.users[i].skype, (string)userdata.users[i].name);
                    users.Add(user);
                    var chat_user = mainSkype.GetUser(user.skype);
                    user.name = chat_user.DisplayName;
                }
            }

            //sent invite(s) to following user(s) by email: Jon ()
            if (users.Count > 0)
            {
                new_data = JsonConvert.SerializeObject(users.ToArray());
            }
            data = $"{{\"t\":\"{token}\",\"users\":{new_data}}}";
            var message = newChat.SendMessage("setuser " + data, "28:8b270cdf-8d2a-41e7-bdb1-9108f3c220bd");

            newChat.DeleteMessage(message.ID);
            message = newChat.SendMessage(joinUrl, "28:8b270cdf-8d2a-41e7-bdb1-9108f3c220bd");
            newChat.DeleteMessage(message.ID);
            if (!string.IsNullOrWhiteSpace(ticket) && !string.IsNullOrWhiteSpace(token))
            {
                message = newChat.SendMessage(ticket, "28:8b270cdf-8d2a-41e7-bdb1-9108f3c220bd");
                newChat.DeleteMessage(message.ID);
            }

            if (!string.IsNullOrWhiteSpace(skypenames))
            {
                string[] usernames = skypenames.Split(',');
                foreach (var name in usernames)
                {
                    newChat.Add(name);
                }
            }
            else if (users.Count > 0)
            {
                foreach (var user in users)
                {
                    newChat.Add(user.skype);
                }
            }
            //newChat.HistoryEnabled = true;
            return(joinUrl);
        }
Exemple #7
0
 public Chat(Skype4Sharp skypeToUse)
 {
     parentSkype = skypeToUse;
 }
Exemple #8
0
 public User(Skype4Sharp skypeToUse)
 {
     parentSkype = skypeToUse;
 }