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)
            {
            }
        }
示例#3
0
 public MainWindow()
 {
     _client = new HipchatClient();
     InitializeComponent();
     PopulateRooms();
     PollNotifications();
 }
示例#4
0
        public ShareFileWithRoom()
        {

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

        }
示例#7
0
        public void CanGetAllUsers()
        {
            var client = new HipchatClient();

            var users = client.GetAllUsers();
            
            Assert.NotNull(users);
        }
示例#8
0
        public SendRoomNotification()
        {

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

        }
示例#9
0
        public void CanGetAllEmoticons()
        {
            var client = new HipchatClient();

            var emoticons = client.GetAllEmoticons();

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

            Assert.True(emoticonByShortcut.Height > 0);
            Assert.True(emoticonByShortcut.Width > 0);
        }
示例#11
0
        public GetAllWebhooksTests()
        {
            HipchatApiConfig.AuthToken = TestsConfig.AuthToken;
            _client = new HipchatClient();

            var room = _client.CreateRoom("Test Webhooks Room");
            _existingRoomId = room.Id;
        }
示例#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";
 }
示例#13
0
        public void CanGetUserInfo()
        {
            var userId = 42494;
            var client = new HipchatClient();

            var userInfo = client.GetUserInfo(userId);

            Assert.NotNull(userInfo);
        }
示例#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";
        }
示例#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);
        }
示例#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;
        }
示例#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);
        }
示例#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);
        }
示例#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);
        }
示例#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();
        }
        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);
        }
示例#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
      });
    }
示例#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);
        }
示例#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);
        }
        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;
        }
        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;
        }
        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");
        }
        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);
        }
示例#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});
            }
        }