legion_mastodon_client 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.env.sample +2 -0
- data/.gitignore +12 -0
- data/.rspec +3 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +78 -0
- data/LICENSE +21 -0
- data/README.md +26 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/legion +6 -0
- data/bin/setup +8 -0
- data/legion.gemspec +38 -0
- data/lib/legion.rb +9 -0
- data/lib/legion/legion.rb +124 -0
- data/lib/legion/mastodon.rb +72 -0
- data/lib/legion/version.rb +3 -0
- metadata +104 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a10d72d4ccffd88e27658515cae24e3091aab96d062c8455d4e307d1361126b3
|
4
|
+
data.tar.gz: e0d0c22a21ec9a7267f1d14e9282a448826014168ddbd9a43d7f85501036ae09
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b5b7e8dc3d266115920cb227b5d482f1ebc9b565d015607b018413c19337fdac29bae884851f1f3af1e65050b872ead1e8ccaf53773a596668efb9aed5a33dd9
|
7
|
+
data.tar.gz: c6d24bbf2b7b41799d88dde267bc6d9c3fcdaa29109fd3e5a33895857e3060985c91ea98d23428bda83f0df5383718f7b87105beb3a2af0b76ec27b3b7e19a89
|
data/.env.sample
ADDED
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at gamelinks007@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
4
|
+
|
5
|
+
gem 'mastodon-api', git: 'https://github.com/tootsuite/mastodon-api.git', ref: '189deb8'
|
6
|
+
gem 'dotenv'
|
7
|
+
gem "highline"
|
8
|
+
gem 'nokogiri'
|
9
|
+
gem 'rmagick'
|
10
|
+
gem 'parallel'
|
11
|
+
|
12
|
+
# Specify your gem's dependencies in legion.gemspec
|
13
|
+
gemspec
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
GIT
|
2
|
+
remote: https://github.com/tootsuite/mastodon-api.git
|
3
|
+
revision: 189deb8219ae1ce7c34386d9ad1ca7e4a5fec62c
|
4
|
+
ref: 189deb8
|
5
|
+
specs:
|
6
|
+
mastodon-api (1.2.0)
|
7
|
+
addressable (~> 2.5)
|
8
|
+
buftok
|
9
|
+
http (~> 3.0)
|
10
|
+
oj (~> 3.3)
|
11
|
+
|
12
|
+
PATH
|
13
|
+
remote: .
|
14
|
+
specs:
|
15
|
+
legion (0.1.0)
|
16
|
+
|
17
|
+
GEM
|
18
|
+
remote: https://rubygems.org/
|
19
|
+
specs:
|
20
|
+
addressable (2.5.2)
|
21
|
+
public_suffix (>= 2.0.2, < 4.0)
|
22
|
+
buftok (0.2.0)
|
23
|
+
diff-lcs (1.3)
|
24
|
+
domain_name (0.5.20180417)
|
25
|
+
unf (>= 0.0.5, < 1.0.0)
|
26
|
+
dotenv (2.4.0)
|
27
|
+
highline (1.7.10)
|
28
|
+
http (3.3.0)
|
29
|
+
addressable (~> 2.3)
|
30
|
+
http-cookie (~> 1.0)
|
31
|
+
http-form_data (~> 2.0)
|
32
|
+
http_parser.rb (~> 0.6.0)
|
33
|
+
http-cookie (1.0.3)
|
34
|
+
domain_name (~> 0.5)
|
35
|
+
http-form_data (2.1.1)
|
36
|
+
http_parser.rb (0.6.0)
|
37
|
+
mini_portile2 (2.3.0)
|
38
|
+
nokogiri (1.8.2-x86-mingw32)
|
39
|
+
mini_portile2 (~> 2.3.0)
|
40
|
+
oj (3.6.2)
|
41
|
+
parallel (1.12.1)
|
42
|
+
public_suffix (3.0.2)
|
43
|
+
rake (10.5.0)
|
44
|
+
rmagick (2.16.0)
|
45
|
+
rspec (3.7.0)
|
46
|
+
rspec-core (~> 3.7.0)
|
47
|
+
rspec-expectations (~> 3.7.0)
|
48
|
+
rspec-mocks (~> 3.7.0)
|
49
|
+
rspec-core (3.7.1)
|
50
|
+
rspec-support (~> 3.7.0)
|
51
|
+
rspec-expectations (3.7.0)
|
52
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
53
|
+
rspec-support (~> 3.7.0)
|
54
|
+
rspec-mocks (3.7.0)
|
55
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
56
|
+
rspec-support (~> 3.7.0)
|
57
|
+
rspec-support (3.7.1)
|
58
|
+
unf (0.1.4)
|
59
|
+
unf_ext
|
60
|
+
unf_ext (0.0.7.5-x86-mingw32)
|
61
|
+
|
62
|
+
PLATFORMS
|
63
|
+
x86-mingw32
|
64
|
+
|
65
|
+
DEPENDENCIES
|
66
|
+
bundler (~> 1.16)
|
67
|
+
dotenv
|
68
|
+
highline
|
69
|
+
legion!
|
70
|
+
mastodon-api!
|
71
|
+
nokogiri
|
72
|
+
parallel
|
73
|
+
rake (~> 10.0)
|
74
|
+
rmagick
|
75
|
+
rspec (~> 3.0)
|
76
|
+
|
77
|
+
BUNDLED WITH
|
78
|
+
1.16.2
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2018 S.H.
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# Legion
|
2
|
+
## 概要
|
3
|
+
Ruby/Tk を使用して制作されたMastodonクライアントアプリっぽいものです。
|
4
|
+
|
5
|
+
## 使い方
|
6
|
+
`.env.sample` を `.env` にリネームし、必要な環境変数を記入していくだけです。
|
7
|
+
|
8
|
+
```
|
9
|
+
MASTODON_URL=<インスタンスのURL>
|
10
|
+
MASTODON_TOKEN=<インスタンスで発行したアクセストークン>
|
11
|
+
```
|
12
|
+
|
13
|
+
あとは、以下のコマンドでLegionのUIを起動させるだけです。
|
14
|
+
|
15
|
+
```
|
16
|
+
ruby legion.rb
|
17
|
+
```
|
18
|
+
|
19
|
+
基本的にMastodonインスタンスはLetsencryptを使用しているので、SSL証明書を使用する端末に導入しておく必要があります。
|
20
|
+
その点だけご注意ください
|
21
|
+
|
22
|
+
## 参考
|
23
|
+
|
24
|
+
[Ruby/Tk Beginner's tutorial ](https://www.dumbo.ai.kyutech.ac.jp/nomura-ken/kajiyama/ruby_tk/contents.html)
|
25
|
+
|
26
|
+
[mastodon-api](https://github.com/tootsuite/mastodon-api)
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "legion"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/legion
ADDED
data/bin/setup
ADDED
data/legion.gemspec
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "legion/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "legion_mastodon_client"
|
8
|
+
spec.version = Legion::VERSION
|
9
|
+
spec.authors = ["S-H-GAMELINKS"]
|
10
|
+
spec.email = ["gamelinks007@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = "Mastodon Client(Ruby/Tk)"
|
13
|
+
spec.description = "Mastodon Client(Ruby/Tk)"
|
14
|
+
spec.homepage = "https://github.com/S-H-GAMELINKS/Legion"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
#if spec.respond_to?(:metadata)
|
20
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
+
#else
|
22
|
+
# raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
+
# "public gem pushes."
|
24
|
+
#end
|
25
|
+
|
26
|
+
# Specify which files should be added to the gem when it is released.
|
27
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
28
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
29
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
30
|
+
end
|
31
|
+
spec.bindir = "exe"
|
32
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
33
|
+
spec.require_paths = ["lib"]
|
34
|
+
|
35
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
36
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
37
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
38
|
+
end
|
data/lib/legion.rb
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
require 'mastodon'
|
2
|
+
require 'highline/import'
|
3
|
+
require 'dotenv'
|
4
|
+
require 'tk'
|
5
|
+
require_relative 'mastodon'
|
6
|
+
|
7
|
+
def LegionLoop
|
8
|
+
|
9
|
+
window = TkToplevel.new do #タイトルバーの表示
|
10
|
+
title( "Legion" )
|
11
|
+
end
|
12
|
+
|
13
|
+
Dotenv.load
|
14
|
+
|
15
|
+
tootFrame = TkFrame.new(window)
|
16
|
+
tootFrame.pack('side' => 'left', 'fill' => 'both')
|
17
|
+
|
18
|
+
home_timeline = TkFrame.new(window)
|
19
|
+
home_timeline.pack('side' => 'left', 'fill' => 'both')
|
20
|
+
|
21
|
+
htl_label = TkLabel.new(home_timeline, 'text' => 'ホームタイムライン', 'width' => 50)
|
22
|
+
htl_label.pack('side' => 'top', 'fill' => 'both')
|
23
|
+
|
24
|
+
htl_list = TkListbox.new(home_timeline, 'height' => 25, 'selectmode' => 'multiple')
|
25
|
+
htl_list.pack('fill' => 'both')
|
26
|
+
|
27
|
+
home_timeline_yscrollbar = TkScrollbar.new(htl_list) {orient "vertical"; command proc{|*args| htl_list.yview(*args);} }
|
28
|
+
htl_list['yscrollcommand'] = proc{|*args| home_timeline_yscrollbar.set(*args);}
|
29
|
+
home_timeline_yscrollbar.pack('side' => 'right', 'fill' => 'both', 'ipadx' => '5', 'ipady' => '170')
|
30
|
+
|
31
|
+
home_timeline_xscrollbar = TkScrollbar.new(htl_list) {orient "horizontal"; command proc{|*args| htl_list.xview(*args);} }
|
32
|
+
htl_list['xscrollcommand'] = proc{|*args| home_timeline_xscrollbar.set(*args);}
|
33
|
+
home_timeline_xscrollbar.pack('side' => 'bottom', 'fill' => 'both')
|
34
|
+
|
35
|
+
local_timeline = TkFrame.new(window)
|
36
|
+
local_timeline.pack('side' => 'left', 'fill' => 'both')
|
37
|
+
|
38
|
+
ltl_label = TkLabel.new(local_timeline, 'text' => 'ローカルタイムライン', 'width' => 50)
|
39
|
+
ltl_label.pack('side' => 'top', 'fill' => 'both')
|
40
|
+
|
41
|
+
ltl_list = TkListbox.new(local_timeline, 'height' => 25, 'selectmode' => 'multiple')
|
42
|
+
ltl_list.pack('fill' => 'both')
|
43
|
+
|
44
|
+
local_timeline_yscrollbar = TkScrollbar.new(ltl_list) {orient "vertical"; command proc{|*args| ltl_list.yview(*args);} }
|
45
|
+
ltl_list['yscrollcommand'] = proc{|*args| local_timeline_yscrollbar.set(*args);}
|
46
|
+
local_timeline_yscrollbar.pack('side' => 'right', 'fill' => 'both', 'ipadx' => '5', 'ipady' => '170')
|
47
|
+
|
48
|
+
local_timeline_xscrollbar = TkScrollbar.new(ltl_list) {orient "horizontal"; command proc{|*args| ltl_list.xview(*args);} }
|
49
|
+
ltl_list['xscrollcommand'] = proc{|*args| local_timeline_xscrollbar.set(*args);}
|
50
|
+
local_timeline_xscrollbar.pack('side' => 'bottom', 'fill' => 'both')
|
51
|
+
|
52
|
+
public_timeline = TkFrame.new(window)
|
53
|
+
public_timeline.pack('side' => 'left', 'fill' => 'both')
|
54
|
+
|
55
|
+
ftl_label = TkLabel.new(public_timeline, 'text' => '連合タイムライン', 'width' => 50)
|
56
|
+
ftl_label.pack('side' => 'top', 'fill' => 'both')
|
57
|
+
|
58
|
+
ftl_list = TkListbox.new(public_timeline, 'height' => 25, 'selectmode' => 'multiple')
|
59
|
+
ftl_list.pack('fill' => 'both')
|
60
|
+
|
61
|
+
public_timeline_yscrollbar = TkScrollbar.new(ftl_list) {orient "vertical"; command proc{|*args| ftl_list.yview(*args);} }
|
62
|
+
ftl_list['yscrollcommand'] = proc{|*args| public_timeline_yscrollbar.set(*args);}
|
63
|
+
public_timeline_yscrollbar.pack('side' => 'right', 'fill' => 'both', 'ipadx' => '5', 'ipady' => '170')
|
64
|
+
|
65
|
+
public_timeline_xscrollbar = TkScrollbar.new(ftl_list) {orient "horizontal"; command proc{|*args| ftl_list.xview(*args);} }
|
66
|
+
ftl_list['xscrollcommand'] = proc{|*args| public_timeline_xscrollbar.set(*args);}
|
67
|
+
public_timeline_xscrollbar.pack('side' => 'bottom', 'fill' => 'both')
|
68
|
+
|
69
|
+
client = Mastodon::REST::Client.new(base_url: ENV["MASTODON_URL"], bearer_token: ENV["MASTODON_TOKEN"])
|
70
|
+
mastodon = MastodonAPI.new(client)
|
71
|
+
|
72
|
+
stream = Mastodon::Streaming::Client.new(base_url: ENV["MASTODON_URL"], bearer_token: ENV["MASTODON_TOKEN"])
|
73
|
+
streaming = MastodonStreaming.new(stream)
|
74
|
+
|
75
|
+
visibility = TkVariable.new('public')
|
76
|
+
sensitive = TkVariable.new('false')
|
77
|
+
spoiler_text = TkVariable.new("")
|
78
|
+
|
79
|
+
text = TkText.new(tootFrame, 'width' => '50', 'height'=> '30')
|
80
|
+
text.pack('side' => 'top', 'fill' => 'both')
|
81
|
+
|
82
|
+
button = TkButton.new(tootFrame, 'text' => 'toot',
|
83
|
+
'command' => proc{mastodon.Toot(text.value, visibility.value, sensitive.value, spoiler_text.value);text.value=""})
|
84
|
+
button.pack('side' => 'left', 'fill' => 'both')
|
85
|
+
|
86
|
+
mediabutton = TkButton.new(tootFrame, 'text' => 'media',
|
87
|
+
'command' => proc{mastodon.MediaUpload(Tk.getOpenFile)})
|
88
|
+
mediabutton.pack('side' => 'left', 'fill' => 'both')
|
89
|
+
|
90
|
+
public_button = TkButton.new(tootFrame, 'text' => 'public',
|
91
|
+
'command' => proc{visibility.value = 'public' })
|
92
|
+
public_button.pack('side' => 'left', 'fill' => 'both')
|
93
|
+
|
94
|
+
unlisted_button = TkButton.new(tootFrame, 'text' => 'unlisted',
|
95
|
+
'command' => proc{visibility.value = 'unlisted' })
|
96
|
+
unlisted_button.pack('side' => 'left', 'fill' => 'both')
|
97
|
+
|
98
|
+
private_button = TkButton.new(tootFrame, 'text' => 'private',
|
99
|
+
'command' => proc{visibility.value = 'private' })
|
100
|
+
private_button.pack('side' => 'left', 'fill' => 'both')
|
101
|
+
|
102
|
+
direct_button = TkButton.new(tootFrame, 'text' => 'direct',
|
103
|
+
'command' => proc{visibility.value = 'direct' })
|
104
|
+
direct_button.pack('side' => 'left', 'fill' => 'both')
|
105
|
+
|
106
|
+
nsfw_button = TkButton.new(tootFrame, 'text' => 'nsfw',
|
107
|
+
'command' => proc{sensitive.value == 'true' ? sensitive.value = 'false' : sensitive.value = 'true' })
|
108
|
+
nsfw_button.pack('side' => 'left', 'fill' => 'both')
|
109
|
+
|
110
|
+
cw_button = TkButton.new(tootFrame, 'text' => 'cw',
|
111
|
+
'command' => proc{spoiler_text.value == "" ? spoiler_text.value = "Contents Warning!" : spoiler_text.value = "";
|
112
|
+
sensitive.value == 'true' ? sensitive.value = 'false' : sensitive.value = 'true' })
|
113
|
+
cw_button.pack('side' => 'left', 'fill' => 'both')
|
114
|
+
|
115
|
+
quitbutton = TkButton.new(tootFrame, 'text' => 'quit',
|
116
|
+
'command' => proc{exit})
|
117
|
+
quitbutton.pack('side' => 'right', 'fill' => 'both')
|
118
|
+
|
119
|
+
loop do
|
120
|
+
Parallel.each([[1, home_timeline, htl_list], [2, local_timeline, ltl_list], [3, public_timeline, ftl_list]], in_threads: 3) do |call|
|
121
|
+
streaming.Timeline(call)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'open-uri'
|
3
|
+
require 'rmagick'
|
4
|
+
|
5
|
+
class MastodonAPI
|
6
|
+
|
7
|
+
def initialize(client)
|
8
|
+
@client = client
|
9
|
+
@timeline = Hash.new
|
10
|
+
@avatar = Array.new
|
11
|
+
@media_id = nil
|
12
|
+
end
|
13
|
+
|
14
|
+
def MediaUpload(file_path)
|
15
|
+
|
16
|
+
if file_path != nil then
|
17
|
+
@media_id = @client.upload_media(file_path).id
|
18
|
+
else
|
19
|
+
@media_id = nil
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def Toot(message, visibility, sensitive, spoiler_text)
|
24
|
+
message += "\n #Legion"
|
25
|
+
response = @client.create_status(message.encode("UTF-8"), :media_ids => @media_id, :visibility => visibility, :sensitive => sensitive, :spoiler_text => spoiler_text)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class MastodonStreaming
|
30
|
+
|
31
|
+
def initialize(stream)
|
32
|
+
@stream = stream
|
33
|
+
end
|
34
|
+
|
35
|
+
def HomeTimeline(window, list)
|
36
|
+
@stream.user() do |toot|
|
37
|
+
message = Nokogiri::HTML.parse(toot.content, nil, nil).search('p')
|
38
|
+
list.insert('0', message.text)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def PublicTimeline(window, list)
|
43
|
+
@stream.firehose() do |toot|
|
44
|
+
message = Nokogiri::HTML.parse(toot.content, nil, nil).search('p')
|
45
|
+
list.insert('0', message.text)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def LocalTimeline(window, list)
|
50
|
+
@stream.firehose() do |toot|
|
51
|
+
if toot.uri.to_s =~ /#{ENV['MASTODON_URL'].to_s}/ then
|
52
|
+
message = Nokogiri::HTML.parse(toot.content, nil, nil).search('p')
|
53
|
+
list.insert('0', message.text)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def Timeline(timeline)
|
59
|
+
|
60
|
+
case timeline[0]
|
61
|
+
|
62
|
+
when 1
|
63
|
+
self.HomeTimeline(timeline[1], timeline[2])
|
64
|
+
|
65
|
+
when 2
|
66
|
+
self.LocalTimeline(timeline[1], timeline[2])
|
67
|
+
|
68
|
+
when 3
|
69
|
+
self.PublicTimeline(timeline[1], timeline[2])
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
metadata
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: legion_mastodon_client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- S-H-GAMELINKS
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-06-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: Mastodon Client(Ruby/Tk)
|
56
|
+
email:
|
57
|
+
- gamelinks007@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".env.sample"
|
63
|
+
- ".gitignore"
|
64
|
+
- ".rspec"
|
65
|
+
- ".travis.yml"
|
66
|
+
- CODE_OF_CONDUCT.md
|
67
|
+
- Gemfile
|
68
|
+
- Gemfile.lock
|
69
|
+
- LICENSE
|
70
|
+
- README.md
|
71
|
+
- Rakefile
|
72
|
+
- bin/console
|
73
|
+
- bin/legion
|
74
|
+
- bin/setup
|
75
|
+
- legion.gemspec
|
76
|
+
- lib/legion.rb
|
77
|
+
- lib/legion/legion.rb
|
78
|
+
- lib/legion/mastodon.rb
|
79
|
+
- lib/legion/version.rb
|
80
|
+
homepage: https://github.com/S-H-GAMELINKS/Legion
|
81
|
+
licenses:
|
82
|
+
- MIT
|
83
|
+
metadata: {}
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options: []
|
86
|
+
require_paths:
|
87
|
+
- lib
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
requirements: []
|
99
|
+
rubyforge_project:
|
100
|
+
rubygems_version: 2.7.6
|
101
|
+
signing_key:
|
102
|
+
specification_version: 4
|
103
|
+
summary: Mastodon Client(Ruby/Tk)
|
104
|
+
test_files: []
|