lib/groupme/cli/session.rb in groupme-cli-0.1.0 vs lib/groupme/cli/session.rb in groupme-cli-0.2.0

- old
+ new

@@ -16,20 +16,26 @@ @current_chat_id = nil @new_msgs = Array.new @last_msg_id = 0 end + # Lists the names of all the groups that the user is part of. + def get_groups + @client.groups + end + # "Open" a chat with the specified name. This means that the CLI will display live messages from the # chat, and any messages you write will go to that chat as well. # Returns true if it succeeds and false otherwise. def open_chat name group = @client.groups.select {|g| g[:name] == name}[0] if group.nil? return false else @current_chat_id = group[:id] + @last_msg_id = 0 return true end end # Send a message to the current chat. @@ -39,10 +45,10 @@ # process image attachments unless image.nil? url = make_img_url image attachments << {type: "image", url: url} end - + @client.create_message(@current_chat_id, msg, attachments) end end # Fetch messages from the currently open group that haven't been fetched yet.