rubydium 0.3.9 → 0.3.11
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 +4 -4
- data/lib/rubydium/mixins/command_macros.rb +10 -8
- data/lib/rubydium/mixins/other_actions.rb +4 -4
- data/lib/rubydium/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: fd0eb1502674be02b220ba6dd98163edcfe8c8199f8bdfffe23bd54773f22bb9
|
4
|
+
data.tar.gz: c07ea74daaaecebc0cff6d2e1fa36b302f63549edec3429f6294d4caf19f28c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83263e4fa1d630376e7bb7a18933d4437df13947d5c3f6395c78c0f4ff894130505428d2317948c48e71bbf4dc213954aeafd42aff068b78eed9260919b2d98a
|
7
|
+
data.tar.gz: 494ef7bb4c17a418567aeb22a6db79513365adc5985121493ef249041a4f9220858cd5b657902b5159e11018a4b1fb8be0cd4d51abc65f35e9e8f67e55503668
|
@@ -74,19 +74,21 @@ module Rubydium
|
|
74
74
|
@registered_on_every_message ||= []
|
75
75
|
end
|
76
76
|
|
77
|
-
def on_command(command, method_name=nil, description: nil, ignore_forwarded: true, &block)
|
77
|
+
def on_command(command, method_name=nil, aliases: [], description: nil, ignore_forwarded: true, &block)
|
78
78
|
@registered_commands ||= {}
|
79
79
|
action = (method_name || block)
|
80
80
|
raise ArgumentError, "Provide either method name or a block" unless action
|
81
81
|
|
82
|
+
parameters = {
|
83
|
+
action: action,
|
84
|
+
description: description,
|
85
|
+
ignore_forwarded: ignore_forwarded
|
86
|
+
}
|
87
|
+
|
82
88
|
@registered_commands.merge!(
|
83
|
-
{
|
84
|
-
|
85
|
-
|
86
|
-
description: description,
|
87
|
-
ignore_forwarded: ignore_forwarded
|
88
|
-
}
|
89
|
-
}
|
89
|
+
[command, **aliases].map { |comm|
|
90
|
+
[comm, parameters]
|
91
|
+
}.to_h
|
90
92
|
)
|
91
93
|
end
|
92
94
|
|
@@ -3,15 +3,15 @@ module Rubydium
|
|
3
3
|
module OtherActions
|
4
4
|
def safe_delete(maybe_message)
|
5
5
|
message = definitely_message(maybe_message)
|
6
|
-
from_bot = message&.from&.id == config.bot_id # also returns if it's nil
|
7
6
|
from_owner = message&.from&.username == config.owner_username
|
7
|
+
from_bot = message&.from&.id == config.bot_id
|
8
8
|
return false unless from_bot || from_owner
|
9
9
|
|
10
|
-
safe_delete_by_id(message.message_id)
|
10
|
+
safe_delete_by_id(message.message_id, from_bot: true)
|
11
11
|
end
|
12
12
|
|
13
|
-
def safe_delete_by_id(id)
|
14
|
-
return false unless bot_can_delete_messages?
|
13
|
+
def safe_delete_by_id(id, from_bot: false)
|
14
|
+
return false unless bot_can_delete_messages? || from_bot
|
15
15
|
|
16
16
|
result = @api.delete_message(chat_id: @chat.id, message_id: id)
|
17
17
|
result["ok"]
|
data/lib/rubydium/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubydium
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bulgakke
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: telegram-bot-ruby
|