ruboty-jobcan 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ruboty/actions/jobcan.rb +21 -4
- data/lib/ruboty/handlers/jobcan.rb +20 -0
- data/lib/ruboty/jobcan/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56f732325b542a73278f169be504638eec2e63b3
|
4
|
+
data.tar.gz: 560c033f3d6a14bd87988b4acc23dc1cd51c5ba9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42bdd99cf2618c0a17e426bddee6a9b6ee6875a5c8722fec208ef0d577ed32dc2b2b79ba0e35df55f74791e3d0541bcd18bcb0b35448f0b5dd60fa422c68d09e
|
7
|
+
data.tar.gz: 97a11cb46f5ce519e0b1ed6961d939667a32d4f15458d12861e8fe9c6da001fab56a6edc943566f5d7a1c0eda2142d996e09ef2005401f16dbd24f56d57574ec
|
@@ -22,7 +22,7 @@ module Ruboty
|
|
22
22
|
message.reply("I remember.")
|
23
23
|
end
|
24
24
|
|
25
|
-
def punch_clock
|
25
|
+
def punch_clock(in_out = :auto)
|
26
26
|
unless (code = user_data["code"])
|
27
27
|
message.reply("I don't know your JOBCAN code.")
|
28
28
|
return
|
@@ -31,7 +31,7 @@ module Ruboty
|
|
31
31
|
message.reply("I don't know your JOBCAN group ID.")
|
32
32
|
return
|
33
33
|
end
|
34
|
-
client = JobcanClient.new(code, group_id)
|
34
|
+
client = JobcanClient.new(code, group_id, in_out)
|
35
35
|
client.authenticate!
|
36
36
|
status = client.punch_clock!
|
37
37
|
message.reply("OK, your current status is #{status}.")
|
@@ -39,6 +39,14 @@ module Ruboty
|
|
39
39
|
message.reply("Error: #{$!}")
|
40
40
|
end
|
41
41
|
|
42
|
+
def clock_in
|
43
|
+
punch_clock(:in)
|
44
|
+
end
|
45
|
+
|
46
|
+
def clock_out
|
47
|
+
punch_clock(:out)
|
48
|
+
end
|
49
|
+
|
42
50
|
private
|
43
51
|
|
44
52
|
def user_data
|
@@ -47,9 +55,10 @@ module Ruboty
|
|
47
55
|
end
|
48
56
|
|
49
57
|
class JobcanClient
|
50
|
-
def initialize(code, group_id)
|
58
|
+
def initialize(code, group_id, in_out)
|
51
59
|
@code = code
|
52
60
|
@group_id = group_id
|
61
|
+
@in_out = in_out
|
53
62
|
end
|
54
63
|
|
55
64
|
def authenticate!
|
@@ -96,7 +105,15 @@ module Ruboty
|
|
96
105
|
end
|
97
106
|
|
98
107
|
def punch_clock_request_body
|
99
|
-
{ is_yakin: "0", adit_item:
|
108
|
+
{ is_yakin: "0", adit_item: adit_item, adit_group_id: @group_id, notice: "" }
|
109
|
+
end
|
110
|
+
|
111
|
+
def adit_item
|
112
|
+
case @in_out
|
113
|
+
when :auto then "DEF"
|
114
|
+
when :in then "work_start"
|
115
|
+
when :out then "work_end"
|
116
|
+
end
|
100
117
|
end
|
101
118
|
end
|
102
119
|
end
|
@@ -19,6 +19,18 @@ module Ruboty
|
|
19
19
|
name: "punch_clock",
|
20
20
|
)
|
21
21
|
|
22
|
+
on(
|
23
|
+
/clock in\z/,
|
24
|
+
description: "Clock in on JOBCAN",
|
25
|
+
name: "clock_in",
|
26
|
+
)
|
27
|
+
|
28
|
+
on(
|
29
|
+
/clock out\z/,
|
30
|
+
description: "Clock out on JOBCAN",
|
31
|
+
name: "clock_out",
|
32
|
+
)
|
33
|
+
|
22
34
|
def remember_code(message)
|
23
35
|
Ruboty::Actions::Jobcan.new(message).remember_code
|
24
36
|
end
|
@@ -30,6 +42,14 @@ module Ruboty
|
|
30
42
|
def punch_clock(message)
|
31
43
|
Ruboty::Actions::Jobcan.new(message).punch_clock
|
32
44
|
end
|
45
|
+
|
46
|
+
def clock_in(message)
|
47
|
+
Ruboty::Actions::Jobcan.new(message).clock_in
|
48
|
+
end
|
49
|
+
|
50
|
+
def clock_out(message)
|
51
|
+
Ruboty::Actions::Jobcan.new(message).clock_out
|
52
|
+
end
|
33
53
|
end
|
34
54
|
end
|
35
55
|
end
|