public RoomColors(RoomColors old)
 {
     this.Red    = old.Red;
     this.Green  = old.Green;
     this.Blue   = old.Blue;
     this.Purple = old.Purple;
     this.Gray   = old.Gray;
 }
        /// <summary>
        /// Send a message to a room
        /// </summary>
        /// <param name="roomName">The name of the room</param>
        /// <param name="message">message to send</param>
        /// <param name="backgroundColor">the background color of the message, only applicable to html format message</param>
        /// <param name="notify">if the message should notify</param>
        /// <param name="messageFormat">the format of the message</param>
        /// <returns>true if the message was sucessfully sent</returns>
        /// <remarks>
        /// Auth required with scope 'view_group'. https://www.hipchat.com/docs/apiv2/method/send_room_notification
        /// </remarks>
        public bool SendNotification(string roomName, string message, RoomColors backgroundColor = RoomColors.Yellow,
                                     bool notify = false, HipchatMessageFormat messageFormat = HipchatMessageFormat.Html)
        {
            using (JsonSerializerConfigScope())
            {
                var request = new SendRoomNotificationRequest
                {
                    Color         = backgroundColor,
                    Message       = message,
                    MessageFormat = messageFormat,
                    Notify        = notify
                };

                return(SendNotification(roomName, request));
            }
        }
            public DungeonRoomClass(DungeonRoomClass parent, int X, int Y)
            {
                this.parent   = parent;
                this.children = new DungeonRoomClass[4];

                x = X;
                y = Y;

                if (parent != null)
                {
                    this.colors = parent.colors;
                }

                intensity = 999;

                this.attributes = new List <string>();
            }
        public string SendMessage(int roomId, string message, RoomColors backgroundColor = RoomColors.Yellow,
            bool notify = false, HipchatMessageFormat messageFormat = HipchatMessageFormat.Html)
        {
            if (message.IsEmpty())
                throw new ArgumentException("Message cannot be blank", "message");
            if (message.Length > 10000)
                throw new ArgumentOutOfRangeException("message", "message length is limited to 10k characters");

            var request = new SendMessageRequest
            {
                Message = message,
                Color = backgroundColor.ToString().ToLower(),
                Notify = notify,
                Message_Format = messageFormat.ToString().ToLower()
            };
            var json = request.ToJson();

            return HipchatEndpoints.SendMessageEndpoint(roomId, _authToken).PostJsonToUrl(request);
        }
        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);
            }
               
        }
Beispiel #6
0
        public static void SendNotification(string roomName, string message, RoomColors color)
        {
retry:
            try
            {
                _hipchat.SendNotification(roomName, message, color);
            }
            catch (HipchatWebException e)
            {
                if (e.Message.Contains("Room not found"))
                {
                    _hipchat.CreateRoom(roomName, false, null, RoomPrivacy.Private);
                }
                if (e.Message.Contains("rate"))
                {
                    return;
                }
                goto retry;
            }
            catch (Exception e)
            {
                LogTo.Error("Hipchat error: {0}- {1}\r\n{2}", e.GetType().ToString(), e.Message, e.StackTrace);
            }
        }
 /// <summary>
 /// Send a message to a room
 /// </summary>
 /// <param name="roomId">The id of the room</param>
 /// <param name="message">message to send</param>
 /// <param name="backgroundColor">the background color of the message, only applicable to html format message</param>
 /// <param name="notify">if the message should notify</param>
 /// <param name="messageFormat">the format of the message</param>
 /// <returns>true if the message was sucessfully sent</returns>
 /// <remarks>
 /// Auth required with scope 'view_group'. https://www.hipchat.com/docs/apiv2/method/send_room_notification
 /// </remarks>
 public bool SendNotification(int roomId, string message, RoomColors backgroundColor = RoomColors.Yellow,
                              bool notify = false, HipchatMessageFormat messageFormat = HipchatMessageFormat.Html)
 {
     return(SendNotification(roomId.ToString(CultureInfo.InvariantCulture), message, backgroundColor, notify, messageFormat));
 }
Beispiel #8
0
        public bool SendNotification(string roomName, string message, RoomColors backgroundColor = RoomColors.Yellow,
            bool notify = false, HipchatMessageFormat messageFormat = HipchatMessageFormat.Html)
        {
            using (JsonSerializerConfigScope())
            {
                var request = new SendRoomNotificationRequest
                {
                    Color = backgroundColor,
                    Message = message,
                    MessageFormat = messageFormat,
                    Notify = notify
                };

                return SendNotification(roomName, request);
            }
        }
Beispiel #9
0
 public bool SendNotification(int roomId, string message, RoomColors backgroundColor = RoomColors.Yellow,
     bool notify = false, HipchatMessageFormat messageFormat = HipchatMessageFormat.Html)
 {
     return SendNotification(roomId.ToString(CultureInfo.InvariantCulture), message, backgroundColor, notify, messageFormat);
 }