GetRoom() public method

public GetRoom ( int roomId ) : HipchatGetRoomResponse
roomId int
return HipchatGetRoomResponse
        public static void SendToRoom(string message, string roomname, string token)
        {
            try
            {
                HipchatClient client = new HipchatClient(token);
                HipchatGetRoomResponse room = client.GetRoom(roomname);

                if (room != null)
                {
                    if (message.Contains("KILL"))
                    {
                        client.SendNotification(room.Id, message, RoomColors.Green, true, HipchatMessageFormat.Text);
                    }
                    else if (message.Contains("LOSS"))
                    {
                        client.SendNotification(room.Id, message, RoomColors.Red, true, HipchatMessageFormat.Text);
                    }
                    else
                    {
                        client.SendNotification(room.Id, message, RoomColors.Random, true, HipchatMessageFormat.Text);
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            var hipApi = new HipchatClient("9MOu2XAKyDn6XRTvUQRxpc8TegMN1TiLI2fQlex8");
            var afApi = new AnytimeFitnessApiClient("http://api.anytimefitness.com", Guid.Parse("2314833F-CFC9-4C84-BB10-5574507DCB4A"));
            var room = hipApi.GetRoom("Anytimefitness");

            var lastTx = DateTime.UtcNow;
            var lastMessage = "";
            while (true)
            {
                var history = hipApi.GetRoomHistory(room.Name);

                var first = history.items[0];
                if (first.message == lastMessage)
                {
                    Thread.Sleep(30000);
                    continue;
                }
                if (first.from == "scotch_bot")
                {
                    hipApi.SendNotification(room.Id, new SendRoomNotificationRequest
                    {
                        Color = RoomColors.Purple,
                        Message = "@scotchbot I know you are, but what am I?",
                        MessageFormat = HipchatMessageFormat.Html,
                        Notify = false
                    });
                    Thread.Sleep(10000);
                }
            }
        }
Exemplo n.º 3
0
        public UpdateRoomTests()
        {
            HipchatApiConfig.AuthToken = TestsConfig.AuthToken;
            _client = new HipchatClient();
            var room = _client.CreateRoom("TestUpdateRoom");
            _createdRoomId = room.Id;

            var getRoomResponse = _client.GetRoom(_createdRoomId);
            _owner = getRoomResponse.Owner;
        }
Exemplo n.º 4
0
 public static int GetARoomId(HipchatClient client, string roomName)
 {
     try
     {
         var room = client.GetRoom(roomName);
         return room.Id;
     }
     catch (HipchatRoomNotFoundException)
     {
         var room = client.CreateRoom(roomName);
         return room.Id;
     }
 }
Exemplo n.º 5
0
        public GetAllWebhooksTests()
        {
            HipchatApiConfig.AuthToken = TestsConfig.AuthToken;
            _client = new HipchatClient();

            try
            {
                var existingRoom = _client.GetRoom("Test Webhooks Room");
                _existingRoomId = existingRoom.Id;
            }
            catch (Exception)
            {
                 var room = _client.CreateRoom("Test Webhooks Room");
                _existingRoomId = room.Id;
            }
        }