elephrame 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +59 -0
- data/LICENSE +20 -0
- data/README.md +39 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/elephrame.gemspec +46 -0
- data/examples/combined.rb +20 -0
- data/examples/interact.rb +18 -0
- data/examples/periodic.rb +7 -0
- data/examples/reply.rb +8 -0
- data/lib/elephrame/bot.rb +35 -0
- data/lib/elephrame/mix/bots.rb +26 -0
- data/lib/elephrame/rest/bots.rb +18 -0
- data/lib/elephrame/rest/rest.rb +24 -0
- data/lib/elephrame/streaming/bots.rb +34 -0
- data/lib/elephrame/streaming/streaming.rb +75 -0
- data/lib/elephrame/version.rb +3 -0
- data/lib/elephrame.rb +5 -0
- metadata +140 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 898b60769d6d1b3e6cb144017948786c46b39a7afcde1a73da8858f91d8ae425
|
4
|
+
data.tar.gz: fc7e8caf3197c2a4634b325c0535f8d9a05c01e17cc05bc0d13a2ffc35f0ffc5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 70f4e752ecb1eb3dfc24304539c1c291b7b00a8052a4356858105fc305e83895306f5ae2ca449bccccdd64b26aeafbfe044b69fe78c34a02bb620e0d609fef37
|
7
|
+
data.tar.gz: e94ab3417ab4f45bca3b4e63ba62077932611191fa3eaab634c79fee7981575388dabb3f1b24974fe5a6c9ba5d95b4000c36bcf59aecfd16091ddf640b82f257
|
data/.gitignore
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 thezacattacks@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
data/Gemfile.lock
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
elephrame (0.2.0)
|
5
|
+
moostodon (~> 0.2.0)
|
6
|
+
rufus-scheduler
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
addressable (2.5.2)
|
12
|
+
public_suffix (>= 2.0.2, < 4.0)
|
13
|
+
buftok (0.2.0)
|
14
|
+
domain_name (0.5.20180417)
|
15
|
+
unf (>= 0.0.5, < 1.0.0)
|
16
|
+
et-orbi (1.1.6)
|
17
|
+
tzinfo
|
18
|
+
fugit (1.1.6)
|
19
|
+
et-orbi (~> 1.1, >= 1.1.6)
|
20
|
+
raabro (~> 1.1)
|
21
|
+
http (3.3.0)
|
22
|
+
addressable (~> 2.3)
|
23
|
+
http-cookie (~> 1.0)
|
24
|
+
http-form_data (~> 2.0)
|
25
|
+
http_parser.rb (~> 0.6.0)
|
26
|
+
http-cookie (1.0.3)
|
27
|
+
domain_name (~> 0.5)
|
28
|
+
http-form_data (2.1.1)
|
29
|
+
http_parser.rb (0.6.0)
|
30
|
+
minitest (5.11.3)
|
31
|
+
moostodon (0.2.0)
|
32
|
+
addressable (~> 2.5)
|
33
|
+
buftok (~> 0)
|
34
|
+
http (~> 3.0)
|
35
|
+
oj (~> 3.3)
|
36
|
+
oj (3.7.1)
|
37
|
+
public_suffix (3.0.3)
|
38
|
+
raabro (1.1.6)
|
39
|
+
rake (10.5.0)
|
40
|
+
rufus-scheduler (3.5.2)
|
41
|
+
fugit (~> 1.1, >= 1.1.5)
|
42
|
+
thread_safe (0.3.6)
|
43
|
+
tzinfo (1.2.5)
|
44
|
+
thread_safe (~> 0.1)
|
45
|
+
unf (0.1.4)
|
46
|
+
unf_ext
|
47
|
+
unf_ext (0.0.7.5)
|
48
|
+
|
49
|
+
PLATFORMS
|
50
|
+
ruby
|
51
|
+
|
52
|
+
DEPENDENCIES
|
53
|
+
bundler (~> 1.17)
|
54
|
+
elephrame!
|
55
|
+
minitest (~> 5.0)
|
56
|
+
rake (~> 10.0)
|
57
|
+
|
58
|
+
BUNDLED WITH
|
59
|
+
1.17.1
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
|
2
|
+
Copyright (c) 2018, Zachary Epps, thezacattacks@gmail.com
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
6
|
+
in the Software without restriction, including without limitation the rights
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
9
|
+
furnished to do so, subject to the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be included in
|
12
|
+
all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Elephrame
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/elephrame`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'elephrame'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install elephrame
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/elephrame. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
|
+
|
37
|
+
## Code of Conduct
|
38
|
+
|
39
|
+
Everyone interacting in the Elephrame project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/elephrame/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "elephrame"
|
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
ADDED
data/elephrame.gemspec
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "elephrame/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "elephrame"
|
8
|
+
spec.version = Elephrame::VERSION
|
9
|
+
spec.authors = ["Zac"]
|
10
|
+
spec.email = ["thezacattacks@gmail.com"]
|
11
|
+
spec.license = "MIT"
|
12
|
+
|
13
|
+
spec.summary = %q{A framework for assisting in making mastodon/pleroma bots}
|
14
|
+
spec.homepage = "https://github.com/theZacAttacks/elephrame"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
20
|
+
|
21
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
22
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
23
|
+
else
|
24
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
25
|
+
"public gem pushes."
|
26
|
+
end
|
27
|
+
|
28
|
+
# Specify which files should be added to the gem when it is released.
|
29
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
30
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
31
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
32
|
+
end
|
33
|
+
spec.bindir = "exe"
|
34
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
35
|
+
spec.require_paths = ["lib"]
|
36
|
+
|
37
|
+
spec.add_development_dependency "bundler", "~> 1.17"
|
38
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
39
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
40
|
+
|
41
|
+
spec.add_dependency 'rufus-scheduler'
|
42
|
+
spec.add_dependency 'moostodon', '~> 0.2.0'
|
43
|
+
|
44
|
+
# until mastodon-api gets a bump this stays commented out
|
45
|
+
#spec.add_dependency 'mastodon-api', '> 1.1.0'
|
46
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'elephrame'
|
2
|
+
|
3
|
+
mix = Elephrame::Bots::PeriodInteract.new '30s'
|
4
|
+
|
5
|
+
mix.on_reply { |bot, post|
|
6
|
+
bot.post("@#{post.account.acct} Thanks for helping me test stuff :3",
|
7
|
+
reply_id: post.id, visibility: post.visibility)
|
8
|
+
}
|
9
|
+
|
10
|
+
mix.on_fave { |bot, notif|
|
11
|
+
puts "#{notif.account.acct} just faved post #{notif.status.content}"
|
12
|
+
}
|
13
|
+
|
14
|
+
mix.on_boost { |bot, notif|
|
15
|
+
puts "#{notif.account.acct} just boosted post #{notif.status.content}"
|
16
|
+
}
|
17
|
+
|
18
|
+
mix.run do |bot|
|
19
|
+
bot.post('testing', visibility: 'direct')
|
20
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'elephrame'
|
2
|
+
|
3
|
+
interacter = Elephrame::Bots::Interact.new
|
4
|
+
|
5
|
+
interacter.on_reply { |bot, post|
|
6
|
+
bot.post("@#{post.account.acct} Thanks for helping me test stuff :3",
|
7
|
+
reply_id: post.id, visibility: post.visibility)
|
8
|
+
}
|
9
|
+
|
10
|
+
interacter.on_fave { |bot, notif|
|
11
|
+
puts "#{notif.account.acct} just faved post #{notif.status.content}"
|
12
|
+
}
|
13
|
+
|
14
|
+
interacter.on_boost { |bot, notif|
|
15
|
+
puts "#{notif.account.acct} just boosted post #{notif.status.content}"
|
16
|
+
}
|
17
|
+
|
18
|
+
interacter.run
|
data/examples/reply.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
module Elephrame
|
2
|
+
module Bots
|
3
|
+
|
4
|
+
# a superclass for other bots
|
5
|
+
# holds common functions and the rest api client
|
6
|
+
class BaseBot
|
7
|
+
attr_reader :client
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@client = Mastodon::REST::Client.new(base_url: ENV['INSTANCE'],
|
11
|
+
bearer_token: ENV['TOKEN'])
|
12
|
+
end
|
13
|
+
|
14
|
+
def post(text, visibility: 'unlisted', spoiler: '', reply_id: '', media: [])
|
15
|
+
|
16
|
+
if not media.empty?
|
17
|
+
media.collect! {|m|
|
18
|
+
@client.upload_media(m).id
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
options = {
|
23
|
+
visibility: visibility,
|
24
|
+
spoiler_text: spoiler,
|
25
|
+
in_reply_to_id: reply_id,
|
26
|
+
media_ids: media,
|
27
|
+
}
|
28
|
+
|
29
|
+
@client.create_status text, options
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative '../rest/rest'
|
2
|
+
require_relative '../streaming/streaming'
|
3
|
+
require_relative '../bot'
|
4
|
+
|
5
|
+
module Elephrame
|
6
|
+
module Bots
|
7
|
+
# a bot that posts things on an interval
|
8
|
+
# but can also respond to interactions
|
9
|
+
class PeriodInteract < BaseBot
|
10
|
+
include Elephrame::Scheduler
|
11
|
+
include Elephrame::AllInteractions
|
12
|
+
|
13
|
+
def initialize intv
|
14
|
+
super()
|
15
|
+
|
16
|
+
setup_scheduler intv
|
17
|
+
setup_streaming
|
18
|
+
end
|
19
|
+
|
20
|
+
def run
|
21
|
+
run_scheduled &Proc.new
|
22
|
+
run_interact
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require_relative 'rest'
|
2
|
+
require_relative '../bot'
|
3
|
+
|
4
|
+
module Elephrame
|
5
|
+
module Bots
|
6
|
+
# a bot that runs commands based off of
|
7
|
+
# an interval or a cron string
|
8
|
+
class Periodic < BaseBot
|
9
|
+
include Elephrame::Scheduler
|
10
|
+
|
11
|
+
def initialize intv
|
12
|
+
super()
|
13
|
+
|
14
|
+
setup_scheduler intv
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Elephrame
|
2
|
+
module Scheduler
|
3
|
+
attr :scheduler, :interval
|
4
|
+
attr_reader :schedule
|
5
|
+
|
6
|
+
def setup_scheduler intv
|
7
|
+
require 'rufus-scheduler'
|
8
|
+
|
9
|
+
|
10
|
+
@interval = intv
|
11
|
+
@scheduler = Rufus::Scheduler.new
|
12
|
+
end
|
13
|
+
|
14
|
+
def run_scheduled
|
15
|
+
@scheduler.repeat @interval do |j|
|
16
|
+
@schedule = j
|
17
|
+
yield(self)
|
18
|
+
end
|
19
|
+
@scheduler.join unless not @streamer.nil?
|
20
|
+
end
|
21
|
+
|
22
|
+
alias_method :run, :run_scheduled
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require_relative 'streaming'
|
2
|
+
require_relative '../bot'
|
3
|
+
|
4
|
+
module Elephrame
|
5
|
+
module Bots
|
6
|
+
|
7
|
+
# a bot that can respond to all interactions
|
8
|
+
class Interact < BaseBot
|
9
|
+
include Elephrame::Streaming
|
10
|
+
include Elephrame::AllInteractions
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
super()
|
14
|
+
|
15
|
+
setup_streaming
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# a bot that only replies when mentioned
|
20
|
+
# run accepts a block, but also supports
|
21
|
+
# use of on_reply
|
22
|
+
class Reply < BaseBot
|
23
|
+
include Elephrame::Streaming
|
24
|
+
include Elephrame::Reply
|
25
|
+
|
26
|
+
def initialize
|
27
|
+
super()
|
28
|
+
|
29
|
+
setup_streaming
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
module Elephrame
|
2
|
+
module Streaming
|
3
|
+
attr :streamer
|
4
|
+
|
5
|
+
def setup_streaming
|
6
|
+
@streamer = Mastodon::Streaming::Client.new(base_url: ENV['INSTANCE'],
|
7
|
+
bearer_token: ENV['TOKEN'])
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
module Reply
|
12
|
+
attr :on_reply
|
13
|
+
|
14
|
+
def on_reply &block
|
15
|
+
@on_reply = block
|
16
|
+
end
|
17
|
+
|
18
|
+
def run_reply
|
19
|
+
@streamer.user do |update|
|
20
|
+
next unless update.kind_of? Mastodon::Notification and update.type == 'mention'
|
21
|
+
|
22
|
+
if block_given?
|
23
|
+
yield(self, update.status)
|
24
|
+
else
|
25
|
+
@on_reply.call(self, update.status)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
alias_method :run, :run_reply
|
31
|
+
end
|
32
|
+
|
33
|
+
module AllInteractions
|
34
|
+
include Elephrame::Reply
|
35
|
+
attr :on_fave, :on_boost, :on_follow
|
36
|
+
|
37
|
+
def on_fave &block
|
38
|
+
@on_fave = block
|
39
|
+
end
|
40
|
+
|
41
|
+
def on_boost &block
|
42
|
+
@on_boost = block
|
43
|
+
end
|
44
|
+
|
45
|
+
def on_follow &block
|
46
|
+
@on_follow = block
|
47
|
+
end
|
48
|
+
|
49
|
+
def run_interact
|
50
|
+
@streamer.user do |update|
|
51
|
+
if update.kind_of? Mastodon::Notification
|
52
|
+
|
53
|
+
case update.type
|
54
|
+
|
55
|
+
when 'mention'
|
56
|
+
@on_reply.call(self, update.status) unless @on_reply.nil?
|
57
|
+
|
58
|
+
when 'reblog'
|
59
|
+
@on_boost.call(self, update) unless @on_boost.nil?
|
60
|
+
|
61
|
+
when 'favourite'
|
62
|
+
@on_fave.call(self, update) unless @on_fave.nil?
|
63
|
+
|
64
|
+
when 'follow'
|
65
|
+
@on_follow.call(self, update) unless @on_follow.nil?
|
66
|
+
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
alias_method :run, :run_interact
|
74
|
+
end
|
75
|
+
end
|
data/lib/elephrame.rb
ADDED
metadata
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: elephrame
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Zac
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-11-29 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.17'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.17'
|
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: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rufus-scheduler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: moostodon
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.2.0
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.2.0
|
83
|
+
description:
|
84
|
+
email:
|
85
|
+
- thezacattacks@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".travis.yml"
|
92
|
+
- CODE_OF_CONDUCT.md
|
93
|
+
- Gemfile
|
94
|
+
- Gemfile.lock
|
95
|
+
- LICENSE
|
96
|
+
- README.md
|
97
|
+
- Rakefile
|
98
|
+
- bin/console
|
99
|
+
- bin/setup
|
100
|
+
- elephrame.gemspec
|
101
|
+
- examples/combined.rb
|
102
|
+
- examples/interact.rb
|
103
|
+
- examples/periodic.rb
|
104
|
+
- examples/reply.rb
|
105
|
+
- lib/elephrame.rb
|
106
|
+
- lib/elephrame/bot.rb
|
107
|
+
- lib/elephrame/mix/bots.rb
|
108
|
+
- lib/elephrame/rest/bots.rb
|
109
|
+
- lib/elephrame/rest/rest.rb
|
110
|
+
- lib/elephrame/streaming/bots.rb
|
111
|
+
- lib/elephrame/streaming/streaming.rb
|
112
|
+
- lib/elephrame/version.rb
|
113
|
+
homepage: https://github.com/theZacAttacks/elephrame
|
114
|
+
licenses:
|
115
|
+
- MIT
|
116
|
+
metadata:
|
117
|
+
allowed_push_host: https://rubygems.org
|
118
|
+
homepage_uri: https://github.com/theZacAttacks/elephrame
|
119
|
+
source_code_uri: https://github.com/theZacAttacks/elephrame
|
120
|
+
post_install_message:
|
121
|
+
rdoc_options: []
|
122
|
+
require_paths:
|
123
|
+
- lib
|
124
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
requirements: []
|
135
|
+
rubyforge_project:
|
136
|
+
rubygems_version: 2.7.6
|
137
|
+
signing_key:
|
138
|
+
specification_version: 4
|
139
|
+
summary: A framework for assisting in making mastodon/pleroma bots
|
140
|
+
test_files: []
|