Class: ActionsNlp

Inherits:
Object
  • Object
show all
Includes:
AppRoutes
Defined in:
lib/ruby-macrodroid.rb

Instance Method Summary collapse

Constructor Details

#initializeActionsNlp

Returns a new instance of ActionsNlp.



191
192
193
194
195
196
197
# File 'lib/ruby-macrodroid.rb', line 191

def initialize()

  super()
  params = {}
  actions(params)

end

Instance Method Details

#actions(params) ⇒ Object



199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
# File 'lib/ruby-macrodroid.rb', line 199

def actions(params) 

  # e.g. message popup: hello world!
  get /^message popup: (.*)/i do |msg|
    [ToastAction, {msg: msg}]
  end

  # e.g. Popup Message 'hello world!'
  get /^Popup[ _]Message ['"]([^'"]+)/i do |msg|
    [ToastAction, {msg: msg}]
  end
  
  # e.g. say current time
  get /^say current[ _]time/i do
    [SayTimeAction, {}]
  end    
  
  get /^Torch :?(.*)/i do |onoffstate|
    state = onoffstate.downcase == 'on' ? 0 : 1
    [CameraFlashLightAction, {state: state}]
  end    
  
  get /^Take Picture/i do
    [TakePictureAction, {}]
  end
  
  get /^take_picture/i do
    [TakePictureAction, {}]
  end           
      
  # e.g. Display Notification: Hi there: This is the body of the message
  get /^Display Notification: ([^:]+): [^$]+$/i do |subject, text|
    [NotificationAction, {subject: subject, text: text}]
  end           
  
  
  # e.g. Enable Wifi
  get /^(Enable|Disable) Wifi$/i do |raw_state|
    
    state = raw_state.downcase.to_sym == :enable ? 0 : 1
    [SetWifiAction, {state: state}]
    
  end    
  
  # e.g. Play: Altair
  get /^Play: (.*)$/i do |name|

    [PlaySoundAction, {file_path: name}]
    
  end     
  
  # e.g. Launch Settings
  get /^Launch (.*)$/i do |application|

    h = {
      application_name: application,
      package_to_launch: 'com.android.' + application.downcase
    }
    [LaunchActivityAction, h]
    
  end
  
  # e.g. HTTP GET http://someurl.com/something
  get /^HTTP GET ([^$]+)$/i do |url|

    [OpenWebPageAction, url_to_open: url]
    
  end
  
  # e.g. webhook entered_kitchen
  #
  get /webhook|HTTP GET/i do
    [OpenWebPageAction, {}]
  end       


end