Beispiel #1
0
        private void LoadZulipRCasString(string ZulipRCPath)
        {
            string line = "";

            if (File.Exists(ZulipRCPath))
            {
                using (var zuliprc = new StreamReader(ZulipRCPath)) {
                    if (ZulipRCIsValid(ZulipRCPath))
                    {
                        while ((line = zuliprc.ReadLine()) != null)
                        {
                            if (line.Contains("="))
                            {
                                var KeyValPair = line.Split('=');
                                switch (KeyValPair[0])
                                {
                                case "email":
                                    Username = KeyValPair[1];
                                    break;

                                case "key":
                                    UserSecret = KeyValPair[1];
                                    break;

                                case "site":
                                    ServerURL = KeyValPair[1];
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        throw new InvalidZulipRCFileException("Invalid .zuliprc file.");
                    }
                }
            }
            else
            {
                throw new FileNotFoundException(ZulipRCPath + "could not be found.");
            }

            Server    = new ZulipServer(ServerURL);
            ZulipAuth = new ZulipAuthentication(Username, UserSecret);
        }
Beispiel #2
0
 /// <summary>
 /// Requires two objects that together enable the API user authentication.
 /// </summary>
 /// <param name="Server"></param>
 /// <param name="ZulipAuth"></param>
 public ZulipClient(ZulipServer Server, ZulipAuthentication ZulipAuth)
 {
     this.Server         = Server;
     this.Authentication = ZulipAuth;
 }
Beispiel #3
0
 public ZulipClient(string serverUrl, string userEmail, string password)
 {
     Server         = new ZulipServer(serverUrl);
     Authentication = new ZulipAuthentication(userEmail, password, true);
 }