public static void SendError(string errorMessage, int roomId)
        {
            var hipchatClient = new HipchatClient();

            errorMessage = "<b>Malfunction!</b><br/>" + errorMessage;
            hipchatClient.SendNotification(roomId, errorMessage, HipchatApiV2.Enums.RoomColors.Red);
        }
        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.º 3
0
 public MainWindow()
 {
     _client = new HipchatClient();
     InitializeComponent();
     PopulateRooms();
     PollNotifications();
 }
Exemplo n.º 4
0
        public ShareFileWithRoom()
        {

            HipchatApiConfig.AuthToken = TestsConfig.AuthToken;
            _client = new HipchatClient();
            _existingRoomId = TestHelpers.GetARoomId(_client, "Share File With Room Test Room");
        }
Exemplo n.º 5
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.º 6
0
        public SendRoomNotification()
        {
            HipchatApiConfig.AuthToken = TestsConfig.AuthToken;
            _client = new HipchatClient();
            _existingRoomId = _client.CreateRoom("Send Notification Test Room").Id;

        }
Exemplo n.º 7
0
        public void CanGetAllUsers()
        {
            var client = new HipchatClient();

            var users = client.GetAllUsers();
            
            Assert.NotNull(users);
        }
Exemplo n.º 8
0
        public SendRoomNotification()
        {

            HipchatApiConfig.AuthToken = TestsConfig.AuthToken;
            _client = new HipchatClient();
            _existingRoomId = TestHelpers.GetARoomId(_client,"Send Notification Test Room");

        }
Exemplo n.º 9
0
        public void CanGetAllEmoticons()
        {
            var client = new HipchatClient();

            var emoticons = client.GetAllEmoticons();

            Assert.Equal(100, emoticons.Items.Count);
        }
Exemplo n.º 10
0
        public void CanGetEmoticonByKnownShortcut()
        {
            var client = new HipchatClient();
            var emoticonByShortcut = client.GetEmoticon("allthethings");

            Assert.True(emoticonByShortcut.Height > 0);
            Assert.True(emoticonByShortcut.Width > 0);
        }
Exemplo n.º 11
0
        public GetAllWebhooksTests()
        {
            HipchatApiConfig.AuthToken = TestsConfig.AuthToken;
            _client = new HipchatClient();

            var room = _client.CreateRoom("Test Webhooks Room");
            _existingRoomId = room.Id;
        }
Exemplo n.º 12
0
 public GetRoomTests()
 {
     const string roomName = "Test GetRooms";
     HipchatApiConfig.AuthToken = TestsConfig.AuthToken;
     _client = new HipchatClient();
     var room = TestHelpers.GetARoomId(_client, roomName);
     _existingRoomId = room;
     _existingRoomName = "Test GetRooms";
 }
Exemplo n.º 13
0
        public void CanGetUserInfo()
        {
            var userId = 42494;
            var client = new HipchatClient();

            var userInfo = client.GetUserInfo(userId);

            Assert.NotNull(userInfo);
        }
Exemplo n.º 14
0
        public GetRoomTests()
        {
            const string roomName = "Test GetRooms";
            HipchatApiConfig.AuthToken = TestsConfig.AuthToken;
            _client = new HipchatClient();

            var room = _client.CreateRoom(roomName);
            _existingRoomId = room.Id;
            _existingRoomName = "Test GetRooms";
        }
Exemplo n.º 15
0
        public void CanCreateRoom()
        {
            IHipchatClient client = new HipchatClient();

            var result = client.CreateRoom(RoomName);

            Assert.NotNull(result);
            Assert.NotNull(result.Links);
            Assert.NotNull(result.Links.Self);
        }
Exemplo n.º 16
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.º 17
0
        public void CanDeleteRoom()
        {
            const string testRoomName = "Delete Me";
            var client = new HipchatClient();
            client.CreateRoom(testRoomName);

            var result = client.DeleteRoom(testRoomName);

            Assert.True(result);
        }
Exemplo n.º 18
0
        public void CanGetEmoticonByShortcut()
        {
            var client = new HipchatClient();
            var emoticons = client.GetAllEmoticons();
            var firstEmoticon = emoticons.Items[0];
            var emoticonByShortcut = client.GetEmoticon(firstEmoticon.Shortcut);

            Assert.Equal(firstEmoticon.Shortcut, emoticonByShortcut.Shortcut);
            Assert.True(emoticonByShortcut.Height > 0);
            Assert.True(emoticonByShortcut.Width > 0);
        }
Exemplo n.º 19
0
        public void CanGetEmoticonById()
        {
            var client = new HipchatClient();
            var emoticons = client.GetAllEmoticons();
            var firstEmoticon = emoticons.Items[0];
            var emoticonById = client.GetEmoticon(firstEmoticon.Id);

            Assert.Equal(firstEmoticon.Id, emoticonById.Id);
            Assert.True(emoticonById.Height > 0);
            Assert.True(emoticonById.Width > 0);
        }
Exemplo n.º 20
0
        private static void Main(string[] args)
        {
            //Setup shit
            const int roomId = 510675;
            const string postToUrl = "http://kylegobel.com/hipchatRedisRelay/message";

            var client = new HipchatClient();
            client.CreateWebHook(roomId, postToUrl, "", HipchatApiV2.Enums.RoomEvent.RoomNotification, "Botso send message hook");

            Console.ReadLine();
        }
Exemplo n.º 21
0
        public static void CreateUser(string token, string name, string email, string title, string password)
        {
            HipchatClient client = new HipchatClient(token);
            HipchatApiV2.Requests.CreateUserRequest request = new HipchatApiV2.Requests.CreateUserRequest();
            request.Name = name;
            request.MentionName = name.Replace(" ", "");
            request.Title = title;
            request.Email = email;
            request.Password = password;

            HipchatCreateUserResponse response = client.CreateUser(request);
        }
Exemplo n.º 22
0
    private static void Main()
    {
      HipchatClient hipchatClient = new HipchatClient("1KoQTmxVnWZDcHObCfPKKKvMnR9msOlX4Wn54fJG");

      var r = hipchatClient.SendNotification(2259497, new SendRoomNotificationRequest
      {
        MessageFormat = HipchatMessageFormat.Text,
        Message = "Hello :) (yey)",
        Color = RoomColors.Green,
        Notify = true
      });
    }
Exemplo n.º 23
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;
     }
 }
        //[Fact]
        public void GenerateAuthToken()
        {
            //insert your authId and auth Secret here
            const string authId = "";
            const string authSecret = "";

            var client = new HipchatClient();

            var token = client.GenerateToken(GrantType.ClientCredentials,
                new List<TokenScope> {TokenScope.SendNotification}, authId, authSecret);

            Assert.NotNull(token);
        }
Exemplo n.º 25
0
        //[Fact]
        public void GenerateAuthTokenWithUsernameAndPassword()
        {
            //insert your username and password here
            const string username = "";
            const string password = "";

            var client = new HipchatClient("YourToken");

            var token = client.GenerateToken(GrantType.Password, Enumerable.Empty<TokenScope>(),
                username, password:password);

            Assert.NotNull(token);
        }
Exemplo n.º 26
0
        public static List<string> GetAllRooms(string token)
        {
            HipchatClient client = new HipchatClient(token);
            HipchatGetAllRoomsResponse rooms = client.GetAllRooms();
            List<string> RoomNames = new List<string>();

            foreach (HipchatGetAllRoomsResponseItems room in rooms.Items)
            {
                RoomNames.Add(room.Name);
            }

            return RoomNames;
        }
Exemplo n.º 27
0
        public static List<string> GetAllUsers(string token)
        {
            HipchatClient client = new HipchatClient(token);
            HipchatGetAllUsersResponse users = client.GetAllUsers();
            List<string> UserNames = new List<string>();

            foreach (HipchatUser user in users.Items)
            {
                UserNames.Add(user.Name);
            }

            return UserNames;
        }
Exemplo n.º 28
0
        public ViewRecentRoomHistoryTests()
        {
            const string roomName = "Test ViewRecentRoomHistory";
            HipchatApiConfig.AuthToken = TestsConfig.AuthToken;
            _client = new HipchatClient();

            _existingRoomId = TestHelpers.GetARoomId(_client, roomName);
            _existingRoomName = roomName;

            // Add notifications to history
            _client.SendNotification(_existingRoomId, "First entry to history");
            _client.ShareFileWithRoom(_existingRoomId.ToString(), @"..\..\Data\RUv8sSn.png", "Second entry to history with file");
        }
Exemplo n.º 29
0
        public void GenerateTokenExample()
        {
            var client = new HipchatClient();

            var token = client.GenerateToken(GrantType.ClientCredentials,
                new List<TokenScope>
                {
                    TokenScope.SendNotification,
                },
                "", /*Auth Id*/
                "" /*Auth Secret*/);

            Assert.NotNull(token);
        }
Exemplo n.º 30
0
        public UpdateUserTests()
        {
            HipchatApiConfig.AuthToken = TestsConfig.AuthToken;
            _client = new HipchatClient();

            try
            {
                _client.GetUserInfo(UserEmail);
            }
            catch (Exception)
            {
                 _client.CreateUser(new CreateUserRequest() {Email = UserEmail, Name = UserName});
            }
        }