elephrame 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +2 -2
- data/examples/combined.rb +1 -2
- data/examples/command.rb +6 -6
- data/examples/interact.rb +2 -2
- data/examples/reply.rb +2 -2
- data/lib/elephrame/streaming/streaming.rb +30 -6
- data/lib/elephrame/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 925f58429ac0d48573209e51c2ad09fbc030d9b3ab3eb138f49219ed672aaac6
|
4
|
+
data.tar.gz: efff93a265abf97c14c8e37a02676bacd2b02967a61d0d422233ddfe097a85f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e5dfe1f3bfc1ded1c5f79dfe8d9f9b498fe916e0276e6b8aaeebd954526447155b7f8430b9ae1ef50666e869d1ca0dbcb28e3d2c454ac43c2a1b26d71521b24
|
7
|
+
data.tar.gz: 3dc7ba9f4161d0dbccb83925c13094e24756b49db9c466511cca1ab27de73fbe3864fe295b91ccf6df9a18e60d79dc744165d4fd378cd37cc17f1aa4ba4bf39d
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/elephrame.svg)](https://badge.fury.io/rb/elephrame)
|
4
4
|
[RubyDoc](https://www.rubydoc.info/github/theZacAttacks/elephrame/)
|
5
5
|
|
6
|
-
Elephant-Framework
|
6
|
+
Elephant-Framework -- by [zac@computerfox.xyz](https://social.computerfox.xyz/@zac)
|
7
7
|
|
8
8
|
A framework that helps simplify the creation of bots for mastodon/pleroma
|
9
9
|
|
@@ -45,7 +45,7 @@ Check the [examples](https://github.com/theZacAttacks/elephrame/tree/master/exam
|
|
45
45
|
|
46
46
|
### Bot Types
|
47
47
|
|
48
|
-
So far the framework support
|
48
|
+
So far the framework support 5 bot types: Periodic, Interact, PeroidInteract, Reply, Command
|
49
49
|
|
50
50
|
- `Periodic` supports posting on a set schedule
|
51
51
|
- `Interact` supports callbacks for each type of interaction (favorites, boosts, replies, follows)
|
data/examples/combined.rb
CHANGED
@@ -3,8 +3,7 @@ require 'elephrame'
|
|
3
3
|
mix = Elephrame::Bots::PeriodInteract.new '30s'
|
4
4
|
|
5
5
|
mix.on_reply { |bot, post|
|
6
|
-
bot.
|
7
|
-
reply_id: post.id, visibility: post.visibility)
|
6
|
+
bot.reply("Thanks for helping me test stuff :3")
|
8
7
|
}
|
9
8
|
|
10
9
|
mix.on_fave { |bot, notif|
|
data/examples/command.rb
CHANGED
@@ -7,22 +7,22 @@ Genders = [ 'sweet', 'sour', 'bitter', 'creamy', 'umami' ]
|
|
7
7
|
cmd_bot = Elephrame::Bots::Command.new '!', 'mention me with !candy to get candy, or !gender to get a gender'
|
8
8
|
|
9
9
|
# add in the candy command
|
10
|
-
cmd_bot.add_command 'candy' do |bot
|
11
|
-
bot.reply("
|
10
|
+
cmd_bot.add_command 'candy' do |bot|
|
11
|
+
bot.reply("here's some candy!
|
12
12
|
*gives you a #{Candy.sample}*",
|
13
13
|
spoiler: 'candy')
|
14
14
|
end
|
15
15
|
|
16
16
|
# add in the gender command
|
17
|
-
cmd_bot.add_command 'gender' do |bot
|
18
|
-
bot.reply("
|
17
|
+
cmd_bot.add_command 'gender' do |bot|
|
18
|
+
bot.reply("here's a spare gender!
|
19
19
|
*gives you a #{Genders.sample} gender*",
|
20
20
|
spoiler: 'gender shitpost')
|
21
21
|
end
|
22
22
|
|
23
23
|
# if the command is not found
|
24
|
-
cmd_bot.if_not_found do |bot
|
25
|
-
bot.reply("
|
24
|
+
cmd_bot.if_not_found do |bot|
|
25
|
+
bot.reply("I didn't recognize that! Respond with !help to get usage info")
|
26
26
|
end
|
27
27
|
|
28
28
|
cmd_bot.run
|
data/examples/interact.rb
CHANGED
@@ -2,13 +2,13 @@ require 'elephrame'
|
|
2
2
|
|
3
3
|
interacter = Elephrame::Bots::Interact.new
|
4
4
|
|
5
|
-
interacter.on_reply { |bot
|
5
|
+
interacter.on_reply { |bot|
|
6
6
|
|
7
7
|
#bot.post("@#{post.account.acct} Thanks for helping me test stuff :3",
|
8
8
|
# reply_id: post.id, visibility: post.visibility)
|
9
9
|
|
10
10
|
## this can be simplified to one line
|
11
|
-
bot.reply("
|
11
|
+
bot.reply("Thanks for helping me test stuff :3")
|
12
12
|
}
|
13
13
|
|
14
14
|
interacter.on_fave { |bot, notif|
|
data/examples/reply.rb
CHANGED
@@ -25,9 +25,11 @@ module Elephrame
|
|
25
25
|
|
26
26
|
##
|
27
27
|
# Replies to the last mention the bot recieved using the mention's
|
28
|
-
#
|
28
|
+
# visibility and spoiler with +text+
|
29
29
|
#
|
30
|
-
#
|
30
|
+
# Automatically includes an @ for the account that mentioned the bot.
|
31
|
+
# Does not include any other @. See +reply_with_mentions+ if you want
|
32
|
+
# to automatically include all mentions
|
31
33
|
#
|
32
34
|
# @param text [String] text to post as a reply
|
33
35
|
# @param options [Hash] a hash of arguments to pass to post, overrides
|
@@ -36,8 +38,29 @@ module Elephrame
|
|
36
38
|
def reply(text, *options)
|
37
39
|
options = Hash[*options]
|
38
40
|
|
39
|
-
|
40
|
-
|
41
|
+
post("@#{@mention_data[:account].acct} #{text}",
|
42
|
+
**@mention_data.merge(options).reject { |k|
|
43
|
+
k == :mentions or k == :account
|
44
|
+
})
|
45
|
+
end
|
46
|
+
|
47
|
+
##
|
48
|
+
# Replies to the last post and tags everyone who was mentioned
|
49
|
+
# (this function respects #NoBot)
|
50
|
+
#
|
51
|
+
# @param text [String] text to post as a reply
|
52
|
+
# @param options [Hash] arguments to pass to post, overrides settings from
|
53
|
+
# last mention
|
54
|
+
|
55
|
+
def reply_with_mentions(text, *options)
|
56
|
+
# build up a string of all accounts mentioned in the post
|
57
|
+
# unless that account is our own, or the tagged account
|
58
|
+
# has #NoBot
|
59
|
+
mentions = @mention_data[:mentions].collect do |m|
|
60
|
+
"@#{m.acct}" unless m.acct == @username or no_bot? m.id
|
61
|
+
end.join ' '
|
62
|
+
|
63
|
+
reply("#{mentions.strip} #{text}", *options)
|
41
64
|
end
|
42
65
|
|
43
66
|
##
|
@@ -75,8 +98,9 @@ module Elephrame
|
|
75
98
|
reply_id: mention.id,
|
76
99
|
visibility: mention.visibility,
|
77
100
|
spoiler: mention.spoiler_text,
|
101
|
+
hide_media: mention.sensitive?,
|
78
102
|
mentions: mention.mentions,
|
79
|
-
|
103
|
+
account: mention.account
|
80
104
|
}
|
81
105
|
end
|
82
106
|
end
|
@@ -165,7 +189,7 @@ module Elephrame
|
|
165
189
|
|
166
190
|
def set_help usage
|
167
191
|
add_command 'help' do |bot, content, status|
|
168
|
-
bot.reply("
|
192
|
+
bot.reply("#{usage}")
|
169
193
|
end
|
170
194
|
end
|
171
195
|
|
data/lib/elephrame/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elephrame
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zac
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-12-
|
11
|
+
date: 2018-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|