determine_target: Determine whether we are sending to a room or user.

Description Usage Arguments Value Examples

View source: R/message.R

Description

If there is a @ character, we assume it is a user. Otherwise, we assume it is a room. If it consists of all numbers, we assume it is an ID. If it exists in the list of room IDs accessible to this user, (see hipchat_rooms) it is assumed to be a room ID. Otherwise, it is assumed to be a user ID.

Usage

1
determine_target(room_or_user, api_token = hipchat_api_token())

Arguments

room_or_user

character or integer

api_token

character. Optional API token. The default is hipchat:::hipchat_api_token(), which uses the environment variable HIPCHAT_API_TOKEN or the R option getOption('hipchat.api_token') if they are present.

Value

a list with two keys, target and type. The former will be an attempt to coerce the value to an ID (so that room IDs are preferred to room names). The type key will contain one of c("room", "user") according as room_or_user is determined to be a room or user.

Examples

1
2
3
4
5
6
7
stopifnot(hipchat:::determine_target('some@guy.com')$type == 'user')

## Not run: 
  stopifnot(is.numeric(hipchat:::determine_target('Some room')$target))
  # Will be a room ID, assuming "Some room" exists.

## End(Not run)

robertzk/hipchat documentation built on May 27, 2019, 10:34 a.m.