Skip to content

Commit

Permalink
Merge branch 'rubocop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Erisa committed Apr 24, 2020
2 parents 01e863d + d5bad05 commit 51b5cb7
Show file tree
Hide file tree
Showing 44 changed files with 1,438 additions and 1,259 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: RuboCop Linter

on:
push:
branches: '*'
pull_request:
branches: '*'

jobs:
lint:
if: "!contains(github.event.commits[0].message, '[skip ci]')"
runs-on: ubuntu-latest
steps:
- name: RuboCop Linter Action
uses: andrewmcodes/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,4 @@ log/*
logs/*
log*
.vscode/*
!.rubocop.yml
62 changes: 62 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
Metrics/BlockLength:
Enabled: false

Metrics/MethodLength:
Enabled: false

Metrics/ModuleLength:
Enabled: false

Style/Documentation:
Enabled: false

Security/Eval:
Exclude:
- "modules/owner/eval.rb"

Lint/Debugger:
Exclude:
- "run.rb"

Layout/EndOfLine:
EnforcedStyle: lf

Layout/LineLength:
Exclude:
- "config/custom/custom.sample.rb"
Max: 100

Style/GlobalVars:
Exclude:
- "run.rb"

Security/Open:
Exclude:
- "modules/helper/download.rb"

# Keep to syntactic linting, instead of complexity.
Metrics/CyclomaticComplexity:
Enabled: false

Metrics/AbcSize:
Enabled: false

Metrics/PerceivedComplexity:
Enabled: false

# Pending cops for RuboCop 0.80
Style/HashEachMethods:
Enabled: true

Style/HashTransformKeys:
Enabled: true

Style/HashTransformValues:
Enabled: true

# Pendng cops for RuboCop 0.81
Lint/RaiseException:
Enabled: true

Lint/StructNewOverride:
Enabled: true
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# frozen_string_literal: true

source 'http://rubygems.org'
gem 'commandrb', git: 'https://github.com/Yuuki-Discord/commandrb.git'
gem 'discordrb', git: 'https://github.com/discordrb/discordrb.git'
gem 'haste'
gem 'pomf.rb'
gem 'pry'
gem 'rainbow'
gem 'rake'
gem 'redis'
gem 'redis-namespace'
gem 'rqrcode'
gem 'rumoji'

23 changes: 11 additions & 12 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
GIT
remote: https://github.com/Yuuki-Discord/commandrb.git
revision: c5b83935544641c79e293e7a5e2720bb190f26ad
revision: 3c18c1028ddce3755d6491610deddbed2fda4516
specs:
commandrb (0.4.7.2)
discordrb (~> 3.1, >= 3.1.0)

GIT
remote: https://github.com/discordrb/discordrb.git
revision: 2c2b50e32c055aa8288b34644346a10696d5efa1
revision: 44f93948a812e06b439968c6b072c0d9b749a842
specs:
discordrb (3.3.0)
discordrb-webhooks (~> 3.3.0)
Expand All @@ -28,27 +28,26 @@ GEM
event_emitter (0.2.6)
faraday (0.17.3)
multipart-post (>= 1.2, < 3)
ffi (1.12.1)
ffi (1.12.1-x64-mingw32)
ffi (1.12.2)
ffi (1.12.2-x64-mingw32)
haste (0.2.3)
faraday (~> 0.9)
json
http-accept (1.7.0)
http-cookie (1.0.3)
domain_name (~> 0.5)
json (2.3.0)
method_source (0.9.2)
method_source (1.0.0)
mime-types (3.3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2019.1009)
multipart-post (2.1.1)
netrc (0.11.0)
opus-ruby (1.0.1)
ffi
pomf.rb (1.0.0)
pry (0.12.2)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
pry (0.13.1)
coderay (~> 1.1)
method_source (~> 1.0)
rainbow (3.0.0)
rake (13.0.1)
redis (4.1.3)
Expand All @@ -68,11 +67,12 @@ GEM
rqrcode (1.1.2)
chunky_png (~> 1.0)
rqrcode_core (~> 0.1)
rqrcode_core (0.1.1)
rqrcode_core (0.1.2)
rumoji (0.5.0)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.6)
unf_ext (0.0.7.7)
unf_ext (0.0.7.7-x64-mingw32)
websocket (1.2.8)
websocket-client-simple (0.3.0)
event_emitter
Expand All @@ -86,7 +86,6 @@ DEPENDENCIES
commandrb!
discordrb!
haste
pomf.rb
pry
rainbow
rake
Expand Down
4 changes: 4 additions & 0 deletions config/config.sample.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ donate_urls:
- <https://ko-fi.com/ErisaMoe>
# - <https://paypal.me/your_name_here>

# If your eval/bash/etc output is larger than what can be sent on Discord,
# it'll be uploaded to the Hastebin instance specified below.
hastebin_instance_url: https://paste.erisa.moe

##~~~ (: DONT TOUCH THIS PART :) ~~~##

# Init options, if unsure please leave alone to avoid accidental catastrophes.
Expand Down
2 changes: 1 addition & 1 deletion config/custom/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
This folder contains multiple files used for basic custom commands.
For each file there will be a `.sample.` version available. Remove the `.sample.` from the name to use the file, then adjust it according to your needs. Most of these files achieve the same purposes, but some are more complex than others.

Custom text commands can only show static strings for now, with the exception of the ones in the .rb files, which can show some dynamic content, but custom.rb won't be able to access the `event`, however you can still access the Commandrb bot object using `$cbot`.
Custom text commands can only show static strings for now, with the exception of the ones in the .rb files, which can show some dynamic content, but custom.rb won't be able to access the `event`, however you can still access the Commandrb bot object using `YuukiBot.crb`.

## Files:

Expand Down
40 changes: 20 additions & 20 deletions config/custom/custom.sample.rb
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
# Three different ways to add custom commands easy.
# frozen_string_literal: true

# Three different ways to add custom commands easily.

#### NOTE ####
# The below examples that use {user} and {userid} do not currently function.
# This feature is planned for later.

CUSTOM = {}
CUSTOM = {}.freeze

# 1. Make your own hashes!
CUSTOM[:pong] = {
:type => 'text',
:response => 'Ping!'
type: 'text',
response: 'Ping!'
}

CUSTOM[:hi] = {
:type => 'text',
:response => 'Hello, {user}!'
type: 'text',
response: 'Hello, {user}!'
}

CUSTOM[:mentionme] = {
:type => 'text',
:response => 'Hello, <@{userid}>!'
type: 'text',
response: 'Hello, <@{userid}>!'
}

# 2. All in one hash!
CUSTOM_TEXT = {
:pong => 'Ping!',
:hi => 'Hello, {user}!',
:mentionme => 'Hello, <@{userid}>!'
}
pong: 'Ping!',
hi: 'Hello, {user}!',
mentionme: 'Hello, <@{userid}>!'
}.freeze

# 3. Change one variable(!)
CUSTOM_TEXT[:pong] = 'Ping'
CUSTOM_TEXT[:hi] = 'Hello, {user}!'
CUSTOM_TEXT[:mentionme] = 'Hello, <@{userid}>!'

# Don't forget images!
CUSTOM_IMAGE = {}
CUSTOM_IMAGE = {}.freeze

CUSTOM_IMAGE[:dab] = 'custom/dab.jpg'


CUSTOM_TEXT = {
lenny: '( ͡° ͜ʖ ͡°)',
shrug: '¯\_(ツ)_/¯',
support: "⚙ **Need help?**\nYou can join the support server here:\n**https://discord.gg/PrTMrv4 **",
facedesk: 'https://giphy.com/gifs/XLOsdacfjL5cI',
smea: 'https://giphy.com/gifs/Sb2NkTl1oV6eI',
}
lenny: '( ͡° ͜ʖ ͡°)',
shrug: '¯\_(ツ)_/¯',
support: "⚙ **Need help?**\nYou can join the support server here:\n**https://discord.gg/PrTMrv4 **",
facedesk: 'https://giphy.com/gifs/XLOsdacfjL5cI',
smea: 'https://giphy.com/gifs/Sb2NkTl1oV6eI'
}.freeze
53 changes: 30 additions & 23 deletions maintenance.rb
Original file line number Diff line number Diff line change
@@ -1,37 +1,44 @@
# frozen_string_literal: true

require 'yaml'
require 'discordrb'

# Load Config from YAML
if File.exists?('config/maintenance.yml')
@config = YAML.load_file('config/maintenance.yml')
else
@config = YAML.load_file('config/config.yml')
end
@config = if File.exist?('config/maintenance.yml')
YAML.load_file('config/maintenance.yml')
else
YAML.load_file('config/config.yml')
end

@config.each do |key, value|
if value.nil?
puts "config.yml: #{key} is nil!"
puts 'Corrupt or incorrect Yaml.'
exit
else
puts("config.yml: Found #{key}: #{value}") if @config['verbose']
end
if value.nil?
puts "config.yml: #{key} is nil!"
puts 'Corrupt or incorrect Yaml.'
exit
elsif @config['verbose']
puts("config.yml: Found #{key}: #{value}")
end
end

bot = Discordrb::Bot.new token: @config['token']
bot.ready do |event|
event.bot.dnd
event.bot.game = "Down for maintenance... :("
event.bot.dnd
event.bot.game = 'Down for maintenance... :('
end

bot.message do |event|
if event.message.content.split(' ').length > 1
@config['prefixes'].each { |x|
if event.message.content.start_with? x
event.respond("Hi, if you're seeing this message, it means that Yuuki-Bot is currently unavailable (Deliberately, unlike downtime) or is in maintenance due to a major bug that needs to be dealt with.\nPlease try again later, and contact `#{event.bot.user(@config['master_owner']).distinct}` if problems persist.\nSorry for any inconvenience caused!")
break
end
}
if event.message.content.split(' ').length > 1
@config['prefixes'].each do |x|
next unless event.message.content.start_with? x

username = event.bot.profile.name
owner_distinct = event.bot.user(@config['master_owner']).distinct
event.respond("Hi! It seems that #{username} is currently undergoing maintenance.\n" \
"Please try again later, and contact `#{owner_distinct}` if problems persist.\n" \
'Sorry for any inconvenience caused!')
break
end
end
end

bot.run
bot.run
Loading

0 comments on commit 51b5cb7

Please sign in to comment.