+10
app/tootify.rb
+10
app/tootify.rb
···
4
4
require_relative 'mastodon_account'
5
5
6
6
class Tootify
7
+
attr_accessor :check_interval
8
+
7
9
def initialize
8
10
@bluesky = BlueskyAccount.new
9
11
@mastodon = MastodonAccount.new
12
+
@check_interval = 60
10
13
end
11
14
12
15
def login_bluesky(handle)
···
51
54
post_to_mastodon(record['value'])
52
55
53
56
@bluesky.delete_record_at(like_uri)
57
+
end
58
+
end
59
+
60
+
def watch
61
+
loop do
62
+
sync
63
+
sleep @check_interval
54
64
end
55
65
end
56
66
+15
-5
tootify
+15
-5
tootify
···
3
3
require 'bundler/setup'
4
4
require_relative 'app/tootify'
5
5
6
-
$app = Tootify.new
7
-
8
6
def run(argv)
9
7
options, args = argv.partition { |x| x.start_with?('-') }
8
+
9
+
app = Tootify.new
10
+
11
+
options.each do |o|
12
+
if o.start_with?('--interval=')
13
+
app.check_interval = o.split('=')[1].to_i
14
+
end
15
+
end
10
16
11
17
case args.first
12
18
when 'login'
13
19
login(args[1])
14
20
when 'check'
15
-
$app.sync
21
+
app.sync
22
+
when 'watch'
23
+
app.watch
16
24
else
17
25
print_help
18
26
end
···
25
33
end
26
34
27
35
def login(name)
36
+
app = Tootify.new
37
+
28
38
if name =~ /\A[^@]+@[^@]+\z/
29
-
$app.login_mastodon(name)
39
+
app.login_mastodon(name)
30
40
elsif name =~ /\A@[^@]+\z/
31
-
$app.login_bluesky(name)
41
+
app.login_bluesky(name)
32
42
elsif name.nil?
33
43
print_help
34
44
else