legion_mastodon_client 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rspec +3 -3
- data/.travis.yml +5 -5
- data/CODE_OF_CONDUCT.md +74 -74
- data/README.md +2 -1
- data/Rakefile +6 -6
- data/bin/console +14 -14
- data/bin/setup +8 -8
- data/legion.gemspec +38 -38
- data/lib/legion.rb +9 -9
- data/lib/legion/legion.rb +33 -8
- data/lib/legion/mastodon.rb +26 -14
- data/lib/legion/ui.rb +35 -24
- data/lib/legion/version.rb +3 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 46cefd68e3d8830be77cc9ec41e55d537be8a9d0
|
4
|
+
data.tar.gz: ed7f14a8ba5639fd6f64f515152e7f8fd06a36ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3185f4810a105772036eb1d5997392eaa72738ce53a990e1a11620f70e3c55211da239663d036b07a3252a668e405803b06229d525d49a081a6e5712941d23c4
|
7
|
+
data.tar.gz: 1d0f730c0704cd02a331a2c9e36d963fbab3e4e1d1f10c62f5b030659fe4975aba2729af96166658bb76ae3db451a429d89ea76440e7f53a1c0071d942537501
|
data/.rspec
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
--format documentation
|
2
|
-
--color
|
3
|
-
--require spec_helper
|
1
|
+
--format documentation
|
2
|
+
--color
|
3
|
+
--require spec_helper
|
data/.travis.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
sudo: false
|
2
|
-
language: ruby
|
3
|
-
rvm:
|
4
|
-
- 2.3.3
|
5
|
-
before_install: gem install bundler -v 1.16.2
|
1
|
+
sudo: false
|
2
|
+
language: ruby
|
3
|
+
rvm:
|
4
|
+
- 2.3.3
|
5
|
+
before_install: gem install bundler -v 1.16.2
|
data/CODE_OF_CONDUCT.md
CHANGED
@@ -1,74 +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/
|
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/README.md
CHANGED
@@ -26,7 +26,7 @@ Gemfile
|
|
26
26
|
``` ruby:Gemfile
|
27
27
|
source "https://rubygems.org"
|
28
28
|
|
29
|
-
gem 'legion_mastodon_client', '~> 0.1.
|
29
|
+
gem 'legion_mastodon_client', '~> 0.1.1'
|
30
30
|
gem 'mastodon-api', git: 'https://github.com/tootsuite/mastodon-api.git', ref: '189deb8'
|
31
31
|
gem 'dotenv'
|
32
32
|
gem "highline"
|
@@ -42,6 +42,7 @@ bundle install
|
|
42
42
|
```
|
43
43
|
|
44
44
|
後は、`.env` を作成し、必要な環境変数を記入していくだけです。
|
45
|
+
なお、マルチポスト/マルチアカウント対応をされたい方は , で区切ってURLとトークンを貼り付けてください
|
45
46
|
|
46
47
|
``` :.env
|
47
48
|
MASTODON_URL=<インスタンスのURL>
|
data/Rakefile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
2
|
-
require "rspec/core/rake_task"
|
3
|
-
|
4
|
-
RSpec::Core::RakeTask.new(:spec)
|
5
|
-
|
6
|
-
task :default => :spec
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rspec/core/rake_task"
|
3
|
+
|
4
|
+
RSpec::Core::RakeTask.new(:spec)
|
5
|
+
|
6
|
+
task :default => :spec
|
data/bin/console
CHANGED
@@ -1,14 +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__)
|
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/setup
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
set -euo pipefail
|
3
|
-
IFS=$'\n\t'
|
4
|
-
set -vx
|
5
|
-
|
6
|
-
bundle install
|
7
|
-
|
8
|
-
# Do any other automated setup that you need to do here
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
set -euo pipefail
|
3
|
+
IFS=$'\n\t'
|
4
|
+
set -vx
|
5
|
+
|
6
|
+
bundle install
|
7
|
+
|
8
|
+
# Do any other automated setup that you need to do here
|
data/legion.gemspec
CHANGED
@@ -1,38 +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
|
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
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
require "legion/version"
|
2
|
-
require "legion/mastodon"
|
3
|
-
require "legion/legion"
|
4
|
-
|
5
|
-
module Legion
|
6
|
-
def self.exec
|
7
|
-
LegionLoop()
|
8
|
-
end
|
9
|
-
end
|
1
|
+
require "legion/version"
|
2
|
+
require "legion/mastodon"
|
3
|
+
require "legion/legion"
|
4
|
+
|
5
|
+
module Legion
|
6
|
+
def self.exec
|
7
|
+
LegionLoop()
|
8
|
+
end
|
9
|
+
end
|
data/lib/legion/legion.rb
CHANGED
@@ -5,22 +5,47 @@ require 'tk'
|
|
5
5
|
require_relative 'mastodon'
|
6
6
|
require_relative 'ui'
|
7
7
|
|
8
|
+
def ClientInit
|
9
|
+
Dotenv.load
|
10
|
+
|
11
|
+
client = Array.new
|
12
|
+
|
13
|
+
url = ENV["MASTODON_URL"].split(",")
|
14
|
+
token = ENV["MASTODON_TOKEN"].split(",")
|
15
|
+
|
16
|
+
for i in 0...url.count do
|
17
|
+
client[i] = Mastodon::REST::Client.new(base_url: url[i], bearer_token: token[i])
|
18
|
+
end
|
19
|
+
|
20
|
+
mastodon = MastodonAPI.new(client)
|
21
|
+
end
|
22
|
+
|
23
|
+
def StreamInit
|
24
|
+
Dotenv.load
|
25
|
+
|
26
|
+
stream = Array.new
|
27
|
+
|
28
|
+
url = ENV["MASTODON_URL"].split(",")
|
29
|
+
token = ENV["MASTODON_TOKEN"].split(",")
|
30
|
+
|
31
|
+
for i in 0...url.count do
|
32
|
+
stream[i] = Mastodon::Streaming::Client.new(base_url: url[i], bearer_token: token[i])
|
33
|
+
end
|
34
|
+
|
35
|
+
streaming = MastodonStreaming.new(stream, url)
|
36
|
+
end
|
37
|
+
|
8
38
|
def LegionLoop
|
9
39
|
|
10
40
|
window = TkRoot.new do #タイトルバーの表示
|
11
41
|
title( "Legion" )
|
12
42
|
end
|
13
43
|
|
14
|
-
|
15
|
-
|
16
|
-
client = Mastodon::REST::Client.new(base_url: ENV["MASTODON_URL"], bearer_token: ENV["MASTODON_TOKEN"])
|
17
|
-
mastodon = MastodonAPI.new(client)
|
18
|
-
|
19
|
-
stream = Mastodon::Streaming::Client.new(base_url: ENV["MASTODON_URL"], bearer_token: ENV["MASTODON_TOKEN"])
|
20
|
-
streaming = MastodonStreaming.new(stream)
|
44
|
+
mastodon = ClientInit()
|
45
|
+
streaming = StreamInit()
|
21
46
|
|
22
47
|
tootFrame = TootFrame.new(window, mastodon)
|
23
|
-
tootFrame.set
|
48
|
+
tootFrame.set(window, streaming)
|
24
49
|
|
25
50
|
home_timeline = Timeline.new(window, "ホームタイムライン")
|
26
51
|
home_timeline.set
|
data/lib/legion/mastodon.rb
CHANGED
@@ -7,50 +7,62 @@ class MastodonAPI
|
|
7
7
|
def initialize(client)
|
8
8
|
@client = client
|
9
9
|
@timeline = Hash.new
|
10
|
-
@
|
11
|
-
@media_id = nil
|
10
|
+
@media_id = Array.new
|
12
11
|
end
|
13
12
|
|
14
13
|
def MediaUpload(file_path)
|
15
14
|
|
16
15
|
if file_path != nil then
|
17
|
-
|
16
|
+
for i in 0...@client.count do
|
17
|
+
@media_id[i] = @client[i].upload_media(file_path).id
|
18
|
+
end
|
18
19
|
else
|
19
|
-
@media_id
|
20
|
+
@media_id.clear
|
20
21
|
end
|
21
22
|
end
|
22
23
|
|
23
|
-
def Toot(message,
|
24
|
+
def Toot(message, options)
|
24
25
|
message += "\n #Legion"
|
25
|
-
|
26
|
+
|
27
|
+
for i in 0...@client.count do
|
28
|
+
response = @client[i].create_status(message.encode("UTF-8"), :media_ids => @media_id[i],
|
29
|
+
:visibility => options[:visibility], :sensitive => options[:sensitive],
|
30
|
+
:spoiler_text => options[:spoiler_text])
|
31
|
+
end
|
32
|
+
|
33
|
+
@media_id.clear
|
26
34
|
end
|
27
35
|
end
|
28
36
|
|
29
37
|
class MastodonStreaming
|
38
|
+
attr_accessor :stream, :num
|
30
39
|
|
31
|
-
def initialize(stream)
|
40
|
+
def initialize(stream, url)
|
32
41
|
@stream = stream
|
42
|
+
@url = url
|
43
|
+
@num = 0
|
33
44
|
end
|
34
45
|
|
35
46
|
def HomeTimeline(window, list)
|
36
|
-
@stream.user() do |toot|
|
47
|
+
@stream[@num].user() do |toot|
|
37
48
|
message = Nokogiri::HTML.parse(toot.content, nil, nil).search('p')
|
38
|
-
list.insert('0', message.text)
|
49
|
+
list.insert('0', "#{toot.account.display_name} さん : #{message.text}")
|
39
50
|
end
|
40
51
|
end
|
41
52
|
|
42
53
|
def PublicTimeline(window, list)
|
43
|
-
@stream.firehose() do |toot|
|
54
|
+
@stream[@num].firehose() do |toot|
|
44
55
|
message = Nokogiri::HTML.parse(toot.content, nil, nil).search('p')
|
45
|
-
list.insert('0', message.text)
|
56
|
+
list.insert('0', "#{toot.account.display_name} さん : #{message.text}")
|
46
57
|
end
|
47
58
|
end
|
48
59
|
|
49
60
|
def LocalTimeline(window, list)
|
50
|
-
@stream.firehose() do |toot|
|
51
|
-
|
61
|
+
@stream[@num].firehose() do |toot|
|
62
|
+
puts @url[@num]
|
63
|
+
if toot.uri.to_s =~ /#{@url[@num]}/ then
|
52
64
|
message = Nokogiri::HTML.parse(toot.content, nil, nil).search('p')
|
53
|
-
list.insert('0', message.text)
|
65
|
+
list.insert('0', "#{toot.account.display_name} さん : #{message.text}")
|
54
66
|
end
|
55
67
|
end
|
56
68
|
end
|
data/lib/legion/ui.rb
CHANGED
@@ -31,18 +31,13 @@ class TootFrame
|
|
31
31
|
|
32
32
|
def initialize(window, mastodon)
|
33
33
|
@tootFrame = TkFrame.new(window)
|
34
|
-
@
|
35
|
-
@
|
36
|
-
@spoiler_text = TkVariable.new("")
|
34
|
+
@options = Hash[:visibility => "public", :sensitive => 'false', :spoiler_text => '']
|
35
|
+
@visibility = ['public', 'unlisted', 'private', 'direct']
|
37
36
|
@text = text = TkText.new(@tootFrame, 'width' => '50', 'height'=> '30')
|
38
|
-
@button = TkButton.new(@tootFrame, 'text' => 'toot', 'command' => proc{mastodon.Toot(@text.value, @
|
37
|
+
@button = TkButton.new(@tootFrame, 'text' => 'toot', 'command' => proc{mastodon.Toot(@text.value, @options);@text.value=""})
|
39
38
|
@mediabutton = TkButton.new(@tootFrame, 'text' => 'media', 'command' => proc{mastodon.MediaUpload(Tk.getOpenFile)})
|
40
|
-
@
|
41
|
-
@
|
42
|
-
@private_button = TkButton.new(@tootFrame, 'text' => 'private', 'command' => proc{@visibility.value = 'private' })
|
43
|
-
@direct_button = TkButton.new(@tootFrame, 'text' => 'direct', 'command' => proc{@visibility.value = 'direct' })
|
44
|
-
@nsfw_button = TkButton.new(@tootFrame, 'text' => 'nsfw', 'command' => proc{@sensitive.value == 'true' ? @sensitive.value = 'false' : @sensitive.value = 'true' })
|
45
|
-
@cw_button = TkButton.new(@tootFrame, 'text' => 'cw', 'command' => proc{@spoiler_text.value == "" ? @spoiler_text.value = "Contents Warning!" : @spoiler_text.value = ""; @sensitive.value == 'true' ? @sensitive.value = 'false' : @sensitive.value = 'true' })
|
39
|
+
@nsfw_button = TkButton.new(@tootFrame, 'text' => 'nsfw', 'command' => proc{@options[:sensitive] == 'true' ? @options[:sensitive] = 'false' : @options[:sensitive] = 'true' })
|
40
|
+
@cw_button = TkButton.new(@tootFrame, 'text' => 'cw', 'command' => proc{@options[:spoiler_text] == "" ? @options[:spoiler_text] = "Contents Warning!" : @options[:spoiler_text] = ""; @options[:sensitive] == 'true' ? @options[:sensitive] = 'false' : @options[:sensitive] = 'true' })
|
46
41
|
@quitbutton = TkButton.new(@tootFrame, 'text' => 'quit', 'command' => proc{exit})
|
47
42
|
end
|
48
43
|
|
@@ -62,20 +57,39 @@ class TootFrame
|
|
62
57
|
@mediabutton.pack('side' => 'left', 'fill' => 'both')
|
63
58
|
end
|
64
59
|
|
65
|
-
def
|
66
|
-
|
67
|
-
|
60
|
+
def AccountMenu(window, streaming)
|
61
|
+
|
62
|
+
Dotenv.load
|
63
|
+
|
64
|
+
menu = TkMenu.new(window)
|
65
|
+
url = ENV["MASTODON_URL"].split(",")
|
66
|
+
procArray = Array.new
|
68
67
|
|
69
|
-
|
70
|
-
|
68
|
+
url.each do |address|
|
69
|
+
menu.add('command', 'label' => "#{address}", 'command' => proc{streaming.num = url.index(address);}, 'underline' => 0)
|
70
|
+
end
|
71
|
+
|
72
|
+
return menu
|
71
73
|
end
|
72
74
|
|
73
|
-
def
|
74
|
-
|
75
|
+
def VisibilityMenu(window)
|
76
|
+
|
77
|
+
menu = TkMenu.new(window)
|
78
|
+
|
79
|
+
@visibility.each do |visibility|
|
80
|
+
menu.add('command', 'label' => "#{visibility}", 'command' => proc{@options[:visibility] = visibility;})
|
81
|
+
end
|
82
|
+
|
83
|
+
return menu
|
75
84
|
end
|
76
85
|
|
77
|
-
def
|
78
|
-
|
86
|
+
def MenuBar_pack(window, streaming)
|
87
|
+
menubar = TkMenu.new(window)
|
88
|
+
|
89
|
+
menubar.add('cascade', 'menu' => self.AccountMenu(window, streaming), 'label' => 'Accounts')
|
90
|
+
menubar.add('cascade', 'menu' => self.VisibilityMenu(window), 'label' => 'Visibility')
|
91
|
+
|
92
|
+
window.menu(menubar)
|
79
93
|
end
|
80
94
|
|
81
95
|
def NsfwButton_pack
|
@@ -90,15 +104,12 @@ class TootFrame
|
|
90
104
|
@quitbutton.pack('side' => 'right', 'fill' => 'both')
|
91
105
|
end
|
92
106
|
|
93
|
-
def set
|
107
|
+
def set(window, streaming)
|
94
108
|
self.TootFrame_pack
|
95
109
|
self.Text_pack
|
96
110
|
self.Button_pack
|
97
|
-
self.PubilcButton_pack
|
98
111
|
self.MediaButton_pack
|
99
|
-
self.
|
100
|
-
self.PrivateButton_pack
|
101
|
-
self.DirectButton_pack
|
112
|
+
self.MenuBar_pack(window, streaming)
|
102
113
|
self.NsfwButton_pack
|
103
114
|
self.CwButton_pack
|
104
115
|
self.Quitbutton_pack
|
data/lib/legion/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module Legion
|
2
|
-
VERSION = "0.1.
|
3
|
-
end
|
1
|
+
module Legion
|
2
|
+
VERSION = "0.1.2"
|
3
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: legion_mastodon_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- S-H-GAMELINKS
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-06-
|
11
|
+
date: 2018-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -98,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
98
|
version: '0'
|
99
99
|
requirements: []
|
100
100
|
rubyforge_project:
|
101
|
-
rubygems_version: 2.
|
101
|
+
rubygems_version: 2.5.2
|
102
102
|
signing_key:
|
103
103
|
specification_version: 4
|
104
104
|
summary: Mastodon Client(Ruby/Tk)
|