public SendNotification ( int roomId, SendRoomNotificationRequest request ) : bool | ||
roomId | int | |
request | SendRoomNotificationRequest | |
Résultat | bool |
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); }
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); } } }
private void Write(object message, Exception exception, RoomColors color) { var sb = new StringBuilder(); if (ApplicationName != null) { sb.Append("<b>Application: </b>" + ApplicationName).Append(NEW_LINE); } sb.Append(message).Append(NEW_LINE); while (exception != null) { sb.Append("Message: ").Append(exception.Message).Append(NEW_LINE) .Append("Source: ").Append(exception.Source).Append(NEW_LINE) .Append("Target site: ").Append(exception.TargetSite).Append(NEW_LINE) .Append("Stack trace: ").Append(exception.StackTrace).Append(NEW_LINE); exception = exception.InnerException; } var hipchatClient = new HipchatClient(_hipchatAuthToken); if (_hipchatAuthSecret != null && _hipchatAuthSecret != null) { var token = hipchatClient.GenerateToken(GrantType.ClientCredentials, new List<TokenScope> { TokenScope.SendNotification, }, _hipchatAuthId,/*Auth Id*/ _hipchatAuthSecret /*Auth Secret*/); HipchatApiConfig.AuthToken = token.Access_Token; hipchatClient.SendNotification(_roomName, sb.ToString(), color); } else { hipchatClient.SendNotification(_roomName, sb.ToString(), color); } }
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 }); }
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 override bool SendNotification(string roomName, string authToken, string htmlMessage, bool notify = false) { var client = new HipchatClient(authToken); return client.SendNotification(roomName, htmlMessage, RoomColors.Green, notify); }
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) { } }