revoltrb 0.0.3 → 0.1.0
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/README.md +7 -33
- data/lib/revoltrb/bot.rb +589 -539
- data/lib/revoltrb/version.rb +1 -1
- data/lib/revoltrb/webhooks.rb +103 -107
- metadata +19 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e1833048a57c6bd197930741b0d788bd6b416c8ced680b5874e90d0158e8dfdb
|
|
4
|
+
data.tar.gz: 24a8b1bc143b4e3287c46d066b103abc854905293994ae2f4f35ce1b75ed4f1d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0b5d133303eb069a69c0ee5b09bdf0876256650dfe813cfd1590a4e5a031fa6f0f7df7ab51d2857f6557e60c4e84677eceab860dba6f2ccf7f6d540fe91e5778
|
|
7
|
+
data.tar.gz: b2dbd9bd8efd009f64d33471a332841513dcc57d45928e742d335a7ffad4ec669b157e41b5dc0f75d01cc6a1860350836214cd00579ef42a59b6940ce0698dfb
|
data/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# revoltrb
|
|
2
2
|
|
|
3
|
+

|
|
4
|
+
|
|
3
5
|
Revoltrb is a Ruby package (a.k.a. Gem) that allows you to make Revolt.chat bots using the Ruby programming language. This package (a.k.a. Gem) is not officially endorsed by Revolt.chat amd this is not an official Revolt.chat product.
|
|
4
6
|
|
|
5
7
|
You need Ruby 3.0 or newer in order to use this package (Ruby 3.2 or newer is recommended)
|
|
@@ -22,7 +24,7 @@ You can install Revoltrb through several methods:
|
|
|
22
24
|
Add the following to your Gemfile file and run the "[bundle install](https://rubygems.org/gems/revoltrb)" command:
|
|
23
25
|
|
|
24
26
|
```ruby
|
|
25
|
-
gem '
|
|
27
|
+
gem 'revoltrb'
|
|
26
28
|
```
|
|
27
29
|
|
|
28
30
|
#### Method 2: Install via Git
|
|
@@ -37,6 +39,8 @@ gem 'revoltrb', git: 'https://gitlab.com/roxannewolf/revoltrb'
|
|
|
37
39
|
|
|
38
40
|
If you encounter the "Exited with code: 16 output:Ignoring debug-1.7.1 because its extensions are not built." error, most likely, there is something wrong with the parser package. This can be fixed by installing parser manually (gem install parser)
|
|
39
41
|
|
|
42
|
+
On the v0.0.x releases, you would need to install websocket-client-simple from your Gemfile. Now this is included within the package as of v0.1.0
|
|
43
|
+
|
|
40
44
|
## Usage
|
|
41
45
|
|
|
42
46
|
You can make a simple bot like this:
|
|
@@ -56,22 +60,7 @@ bot.on_message do |message|
|
|
|
56
60
|
end
|
|
57
61
|
end
|
|
58
62
|
|
|
59
|
-
|
|
60
|
-
unless bot.login
|
|
61
|
-
puts "Bot failed to log in. Exiting."
|
|
62
|
-
exit(1)
|
|
63
|
-
end
|
|
64
|
-
puts "Bot is ONLINE and READY! Press Ctrl+C to stop."
|
|
65
|
-
bot.instance_variable_get(:@websocket_thread).join
|
|
66
|
-
rescue Interrupt
|
|
67
|
-
puts "\nCtrl+C detected. Shutting down bot"
|
|
68
|
-
rescue => e
|
|
69
|
-
puts "An unhandled error occurred in the main script loop: #{e.message}"
|
|
70
|
-
puts e.backtrace.join("\n")
|
|
71
|
-
ensure
|
|
72
|
-
bot.stop
|
|
73
|
-
puts "Bot process ended."
|
|
74
|
-
end
|
|
63
|
+
bot.run
|
|
75
64
|
```
|
|
76
65
|
|
|
77
66
|
or you can make a bot with full prefix commands like this:
|
|
@@ -86,22 +75,7 @@ bot.command(:ping) do |message, args|
|
|
|
86
75
|
bot.send_message(channel_id, text: "Pong! You sent: #{args.join(' ')}")
|
|
87
76
|
end
|
|
88
77
|
|
|
89
|
-
|
|
90
|
-
unless bot.login
|
|
91
|
-
puts "Bot failed to log in. Exiting."
|
|
92
|
-
exit(1)
|
|
93
|
-
end
|
|
94
|
-
puts "Bot is online and running. Press Ctrl+C to stop."
|
|
95
|
-
bot.instance_variable_get(:@websocket_thread).join
|
|
96
|
-
rescue Interrupt
|
|
97
|
-
puts "\nCtrl+C detected. Shutting down bot gracefully..."
|
|
98
|
-
rescue => e
|
|
99
|
-
puts "An unhandled error occurred in the main script loop: #{e.message}"
|
|
100
|
-
puts e.backtrace.join("\n")
|
|
101
|
-
ensure
|
|
102
|
-
bot.stop
|
|
103
|
-
puts "Bot process ended."
|
|
104
|
-
end
|
|
78
|
+
bot.run
|
|
105
79
|
```
|
|
106
80
|
|
|
107
81
|
Webhook example:
|