Class used to encapsulate core HipChat API methods. This is the core class that is used to interact with the API.
https://www.hipchat.com/docs/api
예제 #1
0
        /// <summary>
        /// Sends a message to a chat room.
        /// </summary>
        public static void SendMessage(string token, string room, string from, string message, bool notify, BackgroundColor color, MessageFormat messageFormat)
        {
            // create a local instance of HipChatClient, as then we get the validation
            var client = new HipChatClient(token, room);

            client.SendMessage(message, from, notify, color);
        }
예제 #2
0
 public void TestListRoomsAsJson()
 {
     var client = new HipChat.HipChatClient(defaultClient.Token, HipChat.HipChatClient.ApiResponseFormat.JSON);
     var json = client.ListRooms();
     // not the most scientific test, but it's sunday night
     Assert.IsTrue(json.Contains("{"));
 }
예제 #3
0
 public void TestListRoomsAsNativeObjects()
 {
     var client = new HipChat.HipChatClient(defaultClient.Token, HipChat.HipChatClient.ApiResponseFormat.XML);
     var rooms = client.ListRoomsAsNativeObjects();
     Assert.IsInstanceOfType(rooms, typeof(List<HipChat.Entities.Room>));
     Assert.IsTrue(rooms.Count > 0); //HACK: the number of rooms is variable, so just check that it's greater than 0 - bit if a hack
 }
예제 #4
0
        public void TestUserAlertingWithTextFormatMessage()
        {
            var client = new HipChat.HipChatClient(defaultClient.Token, defaultClient.RoomId.ToString(), HipChatClient.MessageFormat.text);

            client.SendMessage("@all this is a test message notifing all users in the room",
                               defaultClient.From);
        }
예제 #5
0
        public void TestSenderLengthExecption()
        {
            var client = new HipChat.HipChatClient("X");

            client.AutoTruncate = false;
            client.From         = "ABCDEFGHIJKLMNOP";
        }
예제 #6
0
        /// <summary>
        /// Sends a message to a chat room.
        /// </summary>
        public static void SendMessage(string token, int room, string from, string message, bool notify)
        {
            // create a local instance of HipChatClient, as then we get the validation
            var client = new HipChatClient(token, room);

            client.SendMessage(message, from, notify);
        }
예제 #7
0
 public void TestListRoomsAsXml()
 {
     var client = new HipChat.HipChatClient(defaultClient.Token, HipChat.HipChatClient.ApiResponseFormat.XML);
     var xml = client.ListRooms();
     // not the most scientific test, but it's sunday night
     Assert.IsTrue(xml.StartsWith("<?xml version=\"1.0\" encoding=\"utf-8\"?>"));
 }
예제 #8
0
        public void TestListRoomsAsNativeObjects()
        {
            var client = new HipChat.HipChatClient(defaultClient.Token, HipChat.HipChatClient.ApiResponseFormat.XML);
            var rooms  = client.ListRoomsAsNativeObjects();

            Assert.IsInstanceOfType(rooms, typeof(List <HipChat.Entities.Room>));
            Assert.IsTrue(rooms.Count > 0); //HACK: the number of rooms is variable, so just check that it's greater than 0 - bit if a hack
        }
예제 #9
0
        public void TestListRoomsAsXml()
        {
            var client = new HipChat.HipChatClient(defaultClient.Token, HipChat.HipChatClient.ApiResponseFormat.XML);
            var xml    = client.ListRooms();

            // not the most scientific test, but it's sunday night
            Assert.IsTrue(xml.StartsWith("<?xml version=\"1.0\" encoding=\"utf-8\"?>"));
        }
예제 #10
0
        public static void TestWindsorInstaller(TestContext context)
        {
            IWindsorContainer container = new WindsorContainer();
            container.Install(new HipChatClientInstaller());
            defaultClient = container.Resolve<HipChatClient>("ChatClient");
            defaultClient.From += defaultClient.GetHashCode().ToString();
//            defaultClient.SendMessage("TestWindsorInstaller");
        }
예제 #11
0
        public void TestGetRoomHistory()
        {
            var client = new HipChat.HipChatClient(defaultClient.Token, defaultClient.RoomId);
            var s      = client.RoomHistory(DateTime.Today);

            System.Diagnostics.Trace.WriteLine(s.Length > 50 ? s.Substring(0, 50) : s);
            Assert.IsNotNull(s);
        }
예제 #12
0
 public HipChatNotifier(IConfigurationProvider configurationProvider)
 {
     _configurationProvider = configurationProvider;
     _hipChatClient = new HipChatClient
     {
         Token = _configurationProvider.Config.HipChatToken,
     };
 }
예제 #13
0
        public void TestListRoomsAsJson()
        {
            var client = new HipChat.HipChatClient(defaultClient.Token, HipChat.HipChatClient.ApiResponseFormat.JSON);
            var json   = client.ListRooms();

            // not the most scientific test, but it's sunday night
            Assert.IsTrue(json.Contains("{"));
        }
예제 #14
0
        public void TestSendMessageTooLongException()
        {
            var client = new HipChat.HipChatClient(defaultClient.Token)
            {
                AutoTruncate = false
            };

            client.SendMessage(GetReallyLongMessage(MethodBase.GetCurrentMethod().Name, 5000), defaultClient.RoomId, defaultClient.From);
        }
예제 #15
0
 public void TestYieldRooms()
 {
     var client = new HipChat.HipChatClient(defaultClient.Token);
     var x = 0;
     foreach (HipChat.Entities.Room room in client.YieldRooms())
     {
         x++;
     }
     Assert.IsTrue(x > 0);
 }
        public void SendNotification(string sourceName, string notification)
        {
            var client = new HipChatClient(_authToken, _roomId, sourceName)
            {
                Notify = false,
                Color = HipChatClient.BackgroundColor.random
            };

            client.SendMessage(notification);
        }
예제 #17
0
        public void TestYieldRooms()
        {
            var client = new HipChat.HipChatClient(defaultClient.Token);
            var x      = 0;

            foreach (HipChat.Entities.Room room in client.YieldRooms())
            {
                x++;
            }
            Assert.IsTrue(x > 0);
        }
예제 #18
0
        public HipChatService(string setAPIKEY)
        {
            APIKEY = setAPIKEY;
            OPERATION_ACTIVE = false;
            ticker.Elapsed += new ElapsedEventHandler(getChatHistory);
            ticker.Interval = 60000;

            theClient = new HipChatClient(APIKEY, HIPCHATROOM, HIPCHATUSERNAME);

            try
            {
                Console.WriteLine(DateTime.Now + "[Chat] Initialized");
                parseRoomHistory(theClient.ListHistoryAsNativeObjects());
                // set the firstrun flag to false
                // doing so will prevent the buffer-overflow.
                FIRSTRUN = false;
                CHAT_INITERFACE_ACTIVE = true;
            }
            catch
            {
                Console.WriteLine(DateTime.Now + "[CHAT] Unable to initialize");
                CHAT_INITERFACE_ACTIVE = false;
            }
        }
예제 #19
0
        public void TestSendMessageEmptyException()
        {
            var client = new HipChat.HipChatClient(defaultClient.Token);

            client.SendMessage("", defaultClient.RoomId, defaultClient.From);
        }
예제 #20
0
        public void TestSendMessage_Message_Room_From_Notify()
        {
            var client = new HipChat.HipChatClient(defaultClient.Token);

            client.SendMessage(MethodBase.GetCurrentMethod().Name, defaultClient.RoomId, defaultClient.From, true);
        }
예제 #21
0
        public void TestSendMessage_Message_From()
        {
            var client = new HipChat.HipChatClient(defaultClient.Token, defaultClient.RoomId);

            client.SendMessage(MethodBase.GetCurrentMethod().Name, defaultClient.From);
        }
예제 #22
0
        public void TestSendMessage_Message_green_notify()
        {
            var client = new HipChat.HipChatClient(defaultClient.Token, defaultClient.RoomId, defaultClient.From);

            client.SendMessage(MethodBase.GetCurrentMethod().Name, HipChatClient.BackgroundColor.green, true);
        }
예제 #23
0
        public void TestSendMessage_UnicodeAuthorAndMessage()
        {
            var client = new HipChat.HipChatClient(defaultClient.Token, defaultClient.RoomId, "lǝʌɐd ツ");

            client.SendMessage(MethodBase.GetCurrentMethod().Name + " ಠ_ಠ");
        }
예제 #24
0
        public void TestSendMessage_HtmlMessage()
        {
            var client = new HipChat.HipChatClient(defaultClient.Token, defaultClient.RoomId, defaultClient.From);

            client.SendMessage(MethodBase.GetCurrentMethod().Name + " <a href='http://en.wikiquote.org/wiki/Pulp_Fiction#Dialogue'>Quotable &amp; questionable (?) gems from &quot;Pulp Fiction&quot;</a> =)");
        }
예제 #25
0
 public void TestAuthenticationException()
 {
     var client = new HipChatClient(){Token="XYZ", RoomId=123};
     client.ListRooms();
 }
예제 #26
0
 public void TestSendMessage_Message_green_notify()
 {
     var client = new HipChat.HipChatClient(defaultClient.Token, defaultClient.RoomId, defaultClient.From);
     client.SendMessage(MethodBase.GetCurrentMethod().Name, HipChatClient.BackgroundColor.green, true);
 }
예제 #27
0
        public void TestSenderLengthTruncate()
        {
            var client = new HipChat.HipChatClient("X");

            client.From = "ABCDEFGHIJKLMNOP";
        }
예제 #28
0
 public void TestSendMessageEmptyException()
 {
     var client = new HipChat.HipChatClient(defaultClient.Token);
     client.SendMessage("", defaultClient.RoomId, defaultClient.From);
 }
        public void Run(IIntegrationResult result)
        {
            var displayDuration = false;
            var duration = TimeSpan.Zero;
            if (result.EndTime != DateTime.MinValue)
            {
                duration = result.EndTime - result.StartTime;
                displayDuration = true;
            }
            var link = String.Format(@"<a href=""{0}"">{1}</a>", result.ProjectUrl, result.Status);

            var message = new StringBuilder();
            message.Append(result.ProjectName);
            message.Append(" ");

            if(String.IsNullOrEmpty(Message))
            {
                message.Append("build complete");
            }
            else
            {
                message.Append(Message);
            }

            message.Append(" ");

            if(displayDuration)
            {
                message.AppendFormat("(duration {0})", duration);
            }

            message.Append(". ");

            if(!HideResult)
            {
                message.AppendFormat("Result: {0}.", link);
            }

            var notify = result.Succeeded;
            var color = result.Succeeded ? HipChatClient.BackgroundColor.green : HipChatClient.BackgroundColor.red;

            if(HideResult)
            {
                color = HipChatClient.BackgroundColor.yellow;
            }

            var client = new HipChatClient(AuthToken, RoomId, From);
            client.SendMessage(message.ToString(), color, notify);
        }
예제 #30
0
 public void TestSendMessageTooLongException()
 {
     var client = new HipChat.HipChatClient(defaultClient.Token) { AutoTruncate = false };
     client.SendMessage(GetReallyLongMessage(MethodBase.GetCurrentMethod().Name, 5000), defaultClient.RoomId, defaultClient.From);
 }
예제 #31
0
 public HipChatAPI(String apiKey)
 {
     this.client = new HipChatClient(apiKey);
 }
예제 #32
0
 public void TestSenderLengthTruncate()
 {
     var client = new HipChat.HipChatClient("X");
     client.From = "ABCDEFGHIJKLMNOP";
 }
예제 #33
0
 public void TestSenderLengthExecption()
 {
     var client = new HipChat.HipChatClient("X");
     client.AutoTruncate = false;
     client.From = "ABCDEFGHIJKLMNOP";
 }
예제 #34
0
		public void TestSendMessage_UnicodeAuthorAndMessage()
		{
			var client = new HipChat.HipChatClient(defaultClient.Token, defaultClient.RoomId, "lǝʌɐd ツ");
			client.SendMessage(MethodBase.GetCurrentMethod().Name + " ಠ_ಠ");
		}
예제 #35
0
 /// <summary>
 /// Sends a message to a chat room.
 /// </summary>
 public static void SendMessage(string token, int room, string from, string message, bool notify)
 {
     // create a local instance of HipChatClient, as then we get the validation
     var client = new HipChatClient(token, room);
     client.SendMessage(message, from, notify);
 }
예제 #36
0
 public void TestSendMessage_Message()
 {
     var client = new HipChat.HipChatClient(defaultClient.Token, defaultClient.RoomId, defaultClient.From);
     client.SendMessage(MethodBase.GetCurrentMethod().Name);
 }
예제 #37
0
 public void TestGetRoomHistory()
 {
     var client = new HipChat.HipChatClient(defaultClient.Token, defaultClient.RoomId);
     var s = client.RoomHistory(DateTime.Today);
     System.Diagnostics.Trace.WriteLine(s.Length > 50 ? s.Substring(0, 50) : s);
     Assert.IsNotNull(s);
 }
예제 #38
0
		public void TestSendMessage_HtmlMessage()
		{
			var client = new HipChat.HipChatClient(defaultClient.Token, defaultClient.RoomId, defaultClient.From);
			client.SendMessage(MethodBase.GetCurrentMethod().Name + " <a href='http://en.wikiquote.org/wiki/Pulp_Fiction#Dialogue'>Quotable &amp; questionable (?) gems from &quot;Pulp Fiction&quot;</a> =)");
		}
예제 #39
0
 /// <summary>
 /// Sends a message to a chat room.
 /// </summary>
 public static void SendMessage(string token, int room, string from, string message, BackgroundColor color)
 {
     // create a local instance of HipChatClient, as then we get the validation
     var client = new HipChatClient(token, room);
     client.SendMessage(message, from, color);
 }
예제 #40
0
 public HipChatAPI(String apiKey)
 {
     this.client = new HipChatClient(apiKey);
 }
예제 #41
0
 public void TestUserAlertingWithTextFormatMessage()
 {
     var client = new HipChat.HipChatClient(defaultClient.Token, defaultClient.RoomId.ToString(),HipChatClient.MessageFormat.text);
     client.SendMessage("@all this is a test message notifing all users in the room",
         defaultClient.From);
 }