Advertisement
Guest User

Untitled

a guest
Nov 17th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nim 0.95 KB | None | 0 0
  1. #Returns a SlackMessage object  
  2. result = self.server.apiCall(request=request, timeout=timeout, payload=payload)
  3. echo $(result.ok)
  4. echo result.text
  5.  
  6. #Save to var so we can use it inside msgTypePred's scope
  7. var r = result
  8.  
  9. #Defines predicate for any() call
  10. proc msgTypePred(x: string): bool {.inline.} = return cmpIgnoreCase(x, r.msgtype) == 0
  11.  
  12. #Check if we have any groups that need to be added
  13. if cmpIgnoreCase(result.msgtype, "im.open") == 0:
  14.   if result.ok and result.ok == true:
  15.     discard self.server.attachChannel(result.user.name, result.channel.id)
  16. #Substitute msgTypePred call for inline "proc (x: string): bool {.inline.} = return cmpIgnoreCase(x, r.msgtype) == 0" and it fails
  17. elif any(@["mpim.open", "groups.create", "groups.createchild"], msgTypePred):
  18.   if result.ok and result.ok == true:
  19.     discard self.server.attachChannel(
  20.       name=result.user.name,
  21.       user_id=result.user.id,
  22.       members=payload["group"]["members"]
  23.     )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement