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) { } }
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); } } }
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; }
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; } }
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; } }