kjfalkeiae

Omission time

May 15th, 2019
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. command /timeomission [<text>]:
  2. trigger:
  3. set {_text} to timeomission(arg 1)
  4. if {_text} is "Invalid":
  5. send "&c無効な時間形式です。"
  6. stop
  7. send "%{_text}%"
  8.  
  9. function timeomission(texttime: text) :: text:
  10. if {_texttime} does not contain "hour" or "hours" or "minute" or "minutes" or "seconds" or "second" or "tick" or "ticks" or "day" or "days":
  11. if {_texttime} contains "1" or "2" or "3" or "4" or "5" or "6" or "7" or "8" or "9" or "0":
  12. if {_texttime} contains "d" or "h" or "t" or "m" or "s":
  13. loop 9 times:
  14. replace all "d%loop-number%" with "d %loop-number%" in {_texttime}
  15. loop 9 times:
  16. replace all "h%loop-number%" with "h %loop-number%" in {_texttime}
  17. loop 9 times:
  18. replace all "t%loop-number%" with "t %loop-number%" in {_texttime}
  19. loop 9 times:
  20. replace all "m%loop-number%" with "m %loop-number%" in {_texttime}
  21. loop 9 times:
  22. replace all "s%loop-number%" with "s %loop-number%" in {_texttime}
  23. if {_texttime} starts with " ":
  24. set {_texttime} to subtext of {_texttime} from characters 2 to (length of {_texttime})
  25. replace all "d" with " day" in {_texttime}
  26. replace all "h" with " hour" in {_texttime}
  27. replace all "t" with " tick" in {_texttime}
  28. replace all "m" with " minute" in {_texttime}
  29. replace all "s" with " second" in {_texttime}
  30. set {_texttime} to {_texttime} parsed as timespan
  31. return "%{_texttime}%"
  32. stop
  33. return "Invalid"
  34. stop
  35. set {_texttime} to {_texttime} parsed as timespan
  36. return "%{_texttime}%"
Advertisement
Add Comment
Please, Sign In to add comment