rubyred 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 035db004c6621f98bb4a6ab502c121338e04ac76
4
+ data.tar.gz: 46306600bdbc296e9cbfcc2d2061dff76685eb84
5
+ SHA512:
6
+ metadata.gz: 4948e04db5622621190c11faa384e5b2b5cbdb0d388294e84ae62a8e26d71263b998fb8c16ed52c12f843cb9cce2b474722907c16bd2289d82bc06efb02d5b15
7
+ data.tar.gz: 2c7afa6db1c47c0a203896be1d8350b29c34397ff974ad1f8ca134cef4955077ac0c7c0c5e09c19a7e519c9c19cb7ee6a154190b2f148f9086f2885244f6280e
data/bin/rubyred ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/lib/env ruby
2
+
3
+ require 'rubyred'
4
+ RubyRed.run
data/lib/rubyred.rb ADDED
@@ -0,0 +1,23 @@
1
+ require 'discordrb'
2
+
3
+ module RubyRed
4
+
5
+ BOT = Discordrb::Commands::CommandBot.new(token: 'MjI3MTM4Nzc1MTk5OTA3ODQw.CsBy_A.xM0Fl1Iz7wv87DV9Y5EQ_zCnf4Q',
6
+ application_id: 227138775199907840,
7
+ prefix: '!',
8
+ advanced_functionality: false)
9
+
10
+ Dir["#{File.dirname(__FILE__)}/rubyred/*.rb"].each {|file| require file}
11
+
12
+ Discordrb::LOGGER = LOGGER = RubyRed::Console.new
13
+
14
+ Commands.include!
15
+
16
+ LOGGER.info "OAuth url: #{BOT.invite_url}+&permissions=0x00000C00"
17
+ LOGGER.info "Use ctrl+c to stop the bot."
18
+
19
+ def self.run
20
+ BOT.run
21
+ end
22
+
23
+ end
@@ -0,0 +1,19 @@
1
+ module RubyRed
2
+ module Commands
3
+ # Core module for adding commands to the Bot for use
4
+ #
5
+ # Has a wide-include that auto-includes the files in the 'lib/commands' folder
6
+
7
+ Dir["#{File.dirname(__FILE__)}/commands/*.rb"].each {|file| require file}
8
+
9
+ @commands = [
10
+ Ping
11
+ ]
12
+
13
+ def self.include!
14
+ @commands.each do |command|
15
+ RubyRed::BOT.include!(command)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,22 @@
1
+ module RubyRed
2
+ module Commands
3
+ module Ping
4
+ # Displays a 'Pong!' after receiving a 'Ping!'
5
+ #
6
+ # Examples:
7
+ # "Ping!"
8
+ # RubyRed: "Pong!"
9
+
10
+ extend Discordrb::Commands::CommandContainer
11
+ command(:ping, description: 'Displays a Pong! after receiving a Ping!') do |event|
12
+ #"#{((Time.now - event.timestamp) * 1000).to_i}ms" # This is a literal ping time test
13
+ 'Pong!'
14
+ end
15
+ #def self.ping # This is the old method, replaced with the one above.
16
+ # BOT.message(with_text: 'Ping!') do |event|
17
+ # event.respond 'Pong!'
18
+ # end
19
+ #end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,60 @@
1
+ module RubyRed
2
+ CON_TIMESTAMP_FMT = '%d-%m-%Y-%H-%M-%S'.freeze
3
+
4
+ class Console
5
+ attr_writer :fancy
6
+
7
+ def initialize(mode = :normal)
8
+ self.mode = mode
9
+ time = Time.now.strftime(CON_TIMESTAMP_FMT)
10
+ end
11
+
12
+ # The modes this logger can have. This is probably useless unless you want to write your own Logger
13
+ MODES = {
14
+ debug: { long: 'DEBUG', short: 'D', format_code: '' },
15
+ good: { long: 'GOOD', short: '✓', format_code: "\u001B[32m" }, # green
16
+ info: { long: 'INFO', short: 'i', format_code: '' },
17
+ warn: { long: 'WARN', short: '!', format_code: "\u001B[33m" }, # yellow
18
+ error: { long: 'ERROR', short: '✗', format_code: "\u001B[31m" }, # red
19
+ out: { long: 'OUT', short: '→', format_code: "\u001B[36m" }, # cyan
20
+ in: { long: 'IN', short: '←', format_code: "\u001B[35m" } # purple
21
+ }.freeze
22
+
23
+ # The ANSI format code that resets formatting
24
+ FORMAT_RESET = "\u001B[0m".freeze
25
+
26
+ # The ANSI format code that makes something bold
27
+ FORMAT_BOLD = "\u001B[1m".freeze
28
+
29
+ MODES.each do |mode, hash|
30
+ define_method(mode) do |message|
31
+ time = Time.now.strftime(CON_TIMESTAMP_FMT)
32
+ if @enabled_modes.include? mode
33
+ write(message, hash, time)
34
+ end
35
+ end
36
+ end
37
+
38
+ def mode=(value)
39
+ case value
40
+ when :debug
41
+ @log_modes = @enabled_modes = [:debug, :good, :info, :warn, :error, :out, :in]
42
+ when :normal
43
+ @log_modes = [:warn, :error]
44
+ @enabled_modes = [:info, :warn, :error]
45
+ end
46
+ end
47
+
48
+ # Logs an exception to the console.
49
+ def log_exception(e)
50
+ error(e.inspect)
51
+ e.backtrace.each { |line| error(line) }
52
+ end
53
+
54
+ private
55
+
56
+ def write(message, mode, timestamp)
57
+ puts "[#{mode[:format_code]}#{timestamp} #{mode[:long]}#{FORMAT_RESET}] #{message}"
58
+ end
59
+ end
60
+ end
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rubyred
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - George Spiceland
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-09-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: discordrb
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.1'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 2.1.3
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '2.1'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 2.1.3
33
+ description: RubyRed is a Ruby based Discord bot using DiscordRB
34
+ email:
35
+ - george@vallenwood.com
36
+ executables:
37
+ - rubyred
38
+ extensions: []
39
+ extra_rdoc_files: []
40
+ files:
41
+ - bin/rubyred
42
+ - lib/rubyred.rb
43
+ - lib/rubyred/commands.rb
44
+ - lib/rubyred/commands/ping.rb
45
+ - lib/rubyred/console.rb
46
+ homepage: http://rubygems.org/gems/rubyred
47
+ licenses:
48
+ - MPL-2.0
49
+ metadata: {}
50
+ post_install_message:
51
+ rdoc_options: []
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ requirements: []
65
+ rubyforge_project:
66
+ rubygems_version: 2.5.1
67
+ signing_key:
68
+ specification_version: 4
69
+ summary: RubyRed
70
+ test_files: []