Module: GroupMe::Bots

Included in:
Client
Defined in:
lib/groupme/bots.rb

Instance Method Summary collapse

Instance Method Details

#bot_post(id, text, options = {}) ⇒ Boolean

Post a message from a bot.

Parameters:

  • id (String, Integer)

    ID of the bot

  • text (String)

    Text to send to the group

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :picture_url (String)

    Picture URL from image service

Returns:

  • (Boolean)

    Success/Failure

See Also:



22
23
24
25
26
27
28
29
# File 'lib/groupme/bots.rb', line 22

def bot_post(id, text, options = {})
  data = {
    :bot_id => id,
    :text => text
  }
  data[:options] = options if options.any?
  post('/bots/post', data).status == 202
end

#botsArray<Hashie::Mash> Also known as: list_bots

List the authenticated user’s bots.

Examples:

client = GroupMe::Client.new
client.bots

Returns:

  • (Array<Hashie::Mash>)

    Array of hashes representing bots.

See Also:



10
11
12
# File 'lib/groupme/bots.rb', line 10

def bots
  get('/bots')
end

#create_bot(name, group_id, options = {}) ⇒ Hashie::Mash

Create a new bot.

Parameters:

  • name (String)

    Name for the new bot

  • group_id (String, Integer)

    ID of the group

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :avatar_url (String)

    Avatar image URL for the bot

  • :callback_url (String)

    Callback URL for the bot

Returns:

  • (Hashie::Mash)

    Hash representing the bot.

See Also:



39
40
41
42
43
44
# File 'lib/groupme/bots.rb', line 39

def create_bot(name, group_id, options = {})
  data = {
    :bot => options.merge(:name => name, :group_id => group_id)
  }
  post('/bots', data)
end

#destroy_bot(id) ⇒ Boolean

Remove a bot.

Parameters:

  • id (String, Integer)

    ID of the bot

Returns:

  • (Boolean)

    Success/Failure

See Also:



51
52
53
54
55
56
# File 'lib/groupme/bots.rb', line 51

def destroy_bot(id)
  data = {
    :bot_id => id
  }
  post('/bots/destroy', data).status == 200
end