richpresence-rb 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 +7 -0
- data/lib/client.rb +44 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5c5222eceed9b5523af1594e17608d42a4878a05ad72703373535cd442c84c8f
|
4
|
+
data.tar.gz: 5b1b4979548b135d87da013885c63c113073a5145972fe4f10328ae2a2a5db52
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bd8df23d8338aafd5195ef200bbdc9a09bac31f27e95be5636a556ec20ad39636fc6450fec5056ff5559b97a740ef5c67aa2bc143587cb5f21f04cea8480b1ac
|
7
|
+
data.tar.gz: 3364866100f2b723623fb6d6452d30f067d471b799b1e51fb29f90eaa2fc516091d74bdba1e19c6844ca74337f79f5c403e56e58d0bf299217d41dcf9d306a81
|
data/lib/client.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require_relative 'ipc'
|
2
|
+
require_relative 'errors'
|
3
|
+
require 'hue'
|
4
|
+
|
5
|
+
module Richpresence
|
6
|
+
class Client
|
7
|
+
def initialize(client_id)
|
8
|
+
@client_id = client_id.to_s
|
9
|
+
@ipc = Richpresence::Ipc.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def login
|
13
|
+
payload = {
|
14
|
+
v: 1,
|
15
|
+
client_id: @client_id
|
16
|
+
}
|
17
|
+
|
18
|
+
@ipc.send(Richpresence::Opcode::HANDSHAKE, payload)
|
19
|
+
end
|
20
|
+
|
21
|
+
def activity=(params)
|
22
|
+
payload = {
|
23
|
+
cmd: 'SET_ACTIVITY',
|
24
|
+
args: {
|
25
|
+
activity: params,
|
26
|
+
pid: Process.pid
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
run 'Setting activity...'
|
31
|
+
response = JSON.parse @ipc.send(Richpresence::Opcode::FRAME, payload)[1]
|
32
|
+
|
33
|
+
# If there is an error
|
34
|
+
code = response['data']['code']
|
35
|
+
if code
|
36
|
+
error = Richpresence::Errors.parse_error_code(code)
|
37
|
+
bad "An error occured: #{error}"
|
38
|
+
exit code
|
39
|
+
end
|
40
|
+
|
41
|
+
good 'Activity setted'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: richpresence-rb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '1.0'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- AnanaGame
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-05-17 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: "\U0001F5F3 Discord RPC rich presence library for Ruby "
|
14
|
+
email: gameanana@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/client.rb
|
20
|
+
homepage: https://github.com/AnanaGame/richpresence-rb
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.7.6
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: Richpresence-rb
|
44
|
+
test_files: []
|