예제 #1
0
        public SkypeNotifier(string jsonInitFilePath)
        {
            string  rawJson     = File.ReadAllText(jsonInitFilePath);
            dynamic decodedJSON = JsonConvert.DeserializeObject(rawJson);

            _credentials = new SkypeCredentials(decodedJSON.user.ToString(), decodedJSON.password.ToString());
            _chatLink    = decodedJSON.chatLink;
        }
예제 #2
0
 public Skype4Sharp(SkypeCredentials loginData, WebProxy loginProxy = null)
 {
     authInfo          = loginData;
     mainProxy         = loginProxy;
     mainFactory       = new WebRequestFactory(mainProxy, new CookieContainer());
     mainPoll          = new Poller(this);
     selfProfile       = new User(this);
     mainUserModule    = new UserModule(this);
     mainAuthModule    = new AuthModule(this);
     mainMessageModule = new MessageModule(this);
     mainContactModule = new ContactModule(this);
 }
예제 #3
0
 public Skype4Sharp(SkypeCredentials loginData)
 {
     authInfo          = loginData;
     mainCookies       = new CookieContainer();
     mainFactory       = new HttpRequestFactory();
     mainPoll          = new Poller(this);
     selfProfile       = new User(this);
     mainUserModule    = new UserModule(this);
     mainAuthModule    = new AuthModule(this);
     mainMessageModule = new MessageModule(this);
     mainContactModule = new ContactModule(this);
 }
예제 #4
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");
 }
예제 #5
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");
        }
예제 #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);
        }