elephrame 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 041bac1a80ecb71d3a0da5c2af2f24ec9302457c8663efe0acad6cfaabbb57f4
4
- data.tar.gz: fdf9594ab59e48986b3e8c92f22c3da7c8f696e2b014197b42ea7897bc368f7d
3
+ metadata.gz: 925f58429ac0d48573209e51c2ad09fbc030d9b3ab3eb138f49219ed672aaac6
4
+ data.tar.gz: efff93a265abf97c14c8e37a02676bacd2b02967a61d0d422233ddfe097a85f3
5
5
  SHA512:
6
- metadata.gz: 55ea90d7f5b18997aa31d5662b2261728a2a6a407ff2d5ebec9f78796d3df0a7f45fff54a7686adde3768db011f89425dbaae81da5e9e0e3180887732fd16611
7
- data.tar.gz: 4ebfbcdbfafddfd91b1da93bf71f265d6b499a2f43d58abe3af4a45cad948f2e7063b463da74a47048d5fc810bb34f9f6efbc77f49c93667628c2655c5bdb988
6
+ metadata.gz: 1e5dfe1f3bfc1ded1c5f79dfe8d9f9b498fe916e0276e6b8aaeebd954526447155b7f8430b9ae1ef50666e869d1ca0dbcb28e3d2c454ac43c2a1b26d71521b24
7
+ data.tar.gz: 3dc7ba9f4161d0dbccb83925c13094e24756b49db9c466511cca1ab27de73fbe3864fe295b91ccf6df9a18e60d79dc744165d4fd378cd37cc17f1aa4ba4bf39d
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- elephrame (0.4.0)
4
+ elephrame (0.4.1)
5
5
  moostodon (~> 0.2.0)
6
6
  rufus-scheduler
7
7
 
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 4 bot types: Periodic, Interact, PeroidInteract, Reply
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.post("@#{post.account.acct} Thanks for helping me test stuff :3",
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, data, status|
11
- bot.reply("@#{status.account.acct} here's some candy!
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, data, status|
18
- bot.reply("@#{status.account.acct} here's a spare gender!
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, status|
25
- bot.reply("@#{status.account.acct} I didn't recognize that! Respond with !help to get usage info")
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, post|
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("@#{post.account.acct} Thanks for helping me test stuff :3")
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
@@ -2,6 +2,6 @@ require 'elephrame'
2
2
 
3
3
  replier = Elephrame::Bots::Reply.new
4
4
 
5
- replier.run { |bot, mention|
6
- bot.reply("@#{mention.account.acct} hey!")
5
+ replier.run { |bot|
6
+ bot.reply("hey!")
7
7
  }
@@ -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
- # visibility and spoiler with +text+
28
+ # visibility and spoiler with +text+
29
29
  #
30
- # *DOES NOT AUTOMATICALLY INCLUDE @'S*
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
- # maybe also @ everyone from the mention? idk that seems like a bad idea tbh
40
- post(text, **@mention_data.merge(options).reject { |k| k == :mentions })
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
- hide_media: mention.sensitive?
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("@#{status.account.acct} #{usage}")
192
+ bot.reply("#{usage}")
169
193
  end
170
194
  end
171
195
 
@@ -1,3 +1,3 @@
1
1
  module Elephrame
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
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.0
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-09 00:00:00.000000000 Z
11
+ date: 2018-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler