forked from david11014/photoIso
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.rb
61 lines (56 loc) · 1.16 KB
/
main.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# encoding: utf-8
require './photoIso.rb'
require './server.rb'
require './log.rb'
instance = PhotoIso.new "PhotoIso main block"
# Thread.new {
# while true
# begin
# instance.acceptAllFriends
# sleep 30
# rescue
# sleep 10
# retry
# end
# end
# }
Thread.new {
begin
log %(#{Time.now.to_s} [EVENT] Start server)
s = Server.run!
rescue
log %(#{Time.now.to_s} [ERROR] Start server some error: #{$!.to_s} \nretry it...)
sleep 10
retry
end
}
#listen channel
Thread.new {
begin
log %(#{Time.now.to_s} [EVENT] Start listen channel)
instance.listenChannel while true
rescue
log %(#{Time.now.to_s} [ERROR] listen channel has some error: #{$!.to_s} \nretry it...)
retry
end
}
# check unreadPlurk once on start
#begin
# instance.checkUnreadPlurk
#rescue
# log %(#{Time.now.to_s} [ERROR] Checking unread plurk has error: #{$!.to_s})
#end
while true
case gets.chomp
when "check"
p instance.checkUnreadPlurk
when "get"
p instance.getUnreadPlurk
when "a"
#ic = Iconv.new("utf-8","big5")
p instance.addPlurk(gets.to_s,{ qualifier: ':' })
when "close"
log %(#{Time.now.to_s} [EVENT] Close robot)
exit
end
end