Skip to content
This repository was archived by the owner on Apr 8, 2019. It is now read-only.

Commit 0eabe65

Browse files
committed
Initial Publication
Publishing with GPL2 License
0 parents  commit 0eabe65

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+2205
-0
lines changed

.gitignore

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
*.gem
2+
*.rbc
3+
/.config
4+
/coverage/
5+
/InstalledFiles
6+
/pkg/
7+
/spec/reports/
8+
/test/tmp/
9+
/test/version_tmp/
10+
/tmp/
11+
12+
## Specific to RubyMotion:
13+
.dat*
14+
.repl_history
15+
build/
16+
17+
## Documentation cache and generated files:
18+
/.yardoc/
19+
/_yardoc/
20+
/doc/
21+
/rdoc/
22+
23+
## Environment normalisation:
24+
/.bundle/
25+
/vendor/bundle
26+
/lib/bundler/man/
27+
28+
# for a library or gem, you might want to ignore these files since the code is
29+
# intended to run in multiple environments; otherwise, check them in:
30+
# Gemfile.lock
31+
# .ruby-version
32+
# .ruby-gemset
33+
34+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35+
.rvmrc

.rubocop.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# RubyCop configuration file for Arisa
2+
3+
# Exclude the old, not (yet?) rewritten modules
4+
AllCops:
5+
Exclude:
6+
- 'oldmodules/*.rb'
7+
8+
# Offense count: 2
9+
# Configuration parameters: EnforcedStyle, SupportedStyles.
10+
# NOTE: This is used for creating fake-classes using methods.
11+
# It's not awesome but jira-ruby does it too, and I think
12+
# consistency is more important than awesomeness. :)
13+
Style/MethodName:
14+
Enabled: false

Gemfile

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
source 'https://rubygems.org'
2+
gem 'jira-ruby', require: 'jira'

Gemfile.lock

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
activesupport (4.2.1)
5+
i18n (~> 0.7)
6+
json (~> 1.7, >= 1.7.7)
7+
minitest (~> 5.1)
8+
thread_safe (~> 0.3, >= 0.3.4)
9+
tzinfo (~> 1.1)
10+
i18n (0.7.0)
11+
jira-ruby (0.1.14)
12+
activesupport
13+
oauth (~> 0.4.7)
14+
json (1.8.2)
15+
minitest (5.6.1)
16+
oauth (0.4.7)
17+
thread_safe (0.3.5)
18+
tzinfo (1.2.2)
19+
thread_safe (~> 0.1)
20+
21+
PLATFORMS
22+
ruby
23+
24+
DEPENDENCIES
25+
jira-ruby

LICENSE

+339
Large diffs are not rendered by default.

README.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Arisa
2+
Moderation Bot for Mojang's bug tracker
3+
4+
## Installation
5+
6+
**Note**: Please make sure that the settings in the
7+
`config` directory are correct before starting the bot.
8+
9+
See `config/client.rb` for information on how to specify your login credentials.
10+
11+
This bot has been tested with jira-ruby 0.1.14.
12+
13+
```shell
14+
# Install dependencies
15+
gem install bundler
16+
bundle install
17+
18+
# Start the bot
19+
ruby core.rb
20+
```

config/attachments.rb

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Attachments with one of the following
2+
# mime types will be deleted.
3+
ATTACHMENT_DELETE_MIME = [
4+
'application/java-archive',
5+
'application/x-msdos-program',
6+
'application/x-msdownload',
7+
'application/x-ms-dos-executable'
8+
]
9+
10+
# Attachments with names matching one of the
11+
# following regular expressions will be deleted.
12+
ATTACHMENT_DELETE_NAME = [
13+
/\.jar\z/,
14+
/\.exe\z/,
15+
/\.com\z/,
16+
/\.bat\z/,
17+
/\.msi\z/,
18+
/\.run\z/,
19+
/\.com\z/,
20+
/\.lnk\z/
21+
]

config/client.rb

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# The server hosting the bug tracker
2+
SITE = 'https://bugs.mojang.com'
3+
4+
# The base path to use in requests to the server
5+
CONTEXT_PATH = ''
6+
7+
# Read the bot's credentials from the environment.
8+
# You can change this behaviour, but it's not recommended to do so.
9+
USERNAME = ENV['ARISA_AUTH_USERNAME']
10+
PASSWORD = ENV['ARISA_AUTH_PASSWORD']
11+
12+
# Option hash for the JIRA API client
13+
CLIENT_OPTIONS = {
14+
auth_type: :basic,
15+
username: USERNAME,
16+
password: PASSWORD,
17+
site: SITE,
18+
context_path: CONTEXT_PATH
19+
}

config/crash_report.rb

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# An array of regular expressions that match the
2+
# "System Details / Is Modded" values of crash
3+
# reports that should be treated as modded
4+
CR_MODDED = [
5+
/very likely/i,
6+
/definitely/i
7+
]
8+
9+
# Crash report parsing configuration
10+
# You probably don't need to change this
11+
CR_HEADER = '---- Minecraft Crash Report ----'
12+
CR_STACKTRACE_HEADER = 'Stacktrace:'
13+
CR_DETAILS_HEADER = 'Details:'
14+
CR_VALUE_SEPARATOR = ': '
15+
CR_COMMENT_PREFIX = '//'
16+
CR_SECTIONS = {
17+
main: {
18+
stacktrace: :block
19+
},
20+
head: {
21+
title: 'Head',
22+
stacktrace: :value
23+
},
24+
ticked_entity: {
25+
title: 'Entity being ticked',
26+
stacktrace: :value
27+
},
28+
tesselated_block: {
29+
title: 'Block being tesselated',
30+
stacktrace: :value
31+
},
32+
screen: {
33+
title: 'Affected screen',
34+
stacktrace: :value
35+
},
36+
message: {
37+
title: 'Serialized Message',
38+
stacktrace: :value
39+
},
40+
level: {
41+
title: 'Affected level',
42+
stacktrace: :value
43+
},
44+
initialization: {
45+
title: 'Initialization',
46+
stacktrace: :value
47+
},
48+
system: {
49+
title: 'System Details'
50+
}
51+
}

config/footer.rb

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Whether the file "responses/footer" should automatically
2+
# be appended to every comment the bot creates.
3+
COMMENT_FOOTER = true
4+
5+
# Arguments required for the footer.
6+
# Currently this is an URL where users can report problems with the bot.
7+
# Example: COMMENT_FOOTER_ARGS = ['http://example.com/contact']
8+
COMMENT_FOOTER_ARGS = ['mailto:[email protected]'] # <-- sorry!

config/modules.rb

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Require all modules
2+
core_dir = File.dirname(__FILE__)
3+
files = File.join(core_dir, '..', 'modules', '**', '*.rb')
4+
Dir[files].each { |file| require file }
5+
6+
# List of modules that will be loaded when the bot starts
7+
ENABLED_MODULES = [
8+
Arisa::AttachmentModule,
9+
Arisa::CHKModule,
10+
Arisa::DuplicatesModule,
11+
Arisa::FixVersionModule,
12+
Arisa::JavaVersionModule,
13+
Arisa::ModsModule,
14+
Arisa::VersionModule
15+
]

config/parent_issues.rb

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Parent issues will be identified by at least one of the following:
2+
# headers: The first line of the stack trace
3+
# classes: The exception class in the first line of the stack trace
4+
# descriptions: The error description above the stacktrace
5+
# versions: Game versions affected by this issue
6+
# The issue will then be resolved and linked to the corresponding parent issue.
7+
# You can specify different comments for each parent issue. To do so, just
8+
# create the file responses/duplicate/issue/{key}, replacing {key} with the
9+
# key of the parent issue (like MC-1). Then, put the comment body in that file.
10+
11+
PARENT_ISSUES = {
12+
# The infamous MC-297: no supported graphics drivers
13+
'MC-297' => {
14+
headers: [
15+
'org.lwjgl.LWJGLException: Could not create context',
16+
'org.lwjgl.LWJGLException: Pixel format not accelerated'
17+
]
18+
},
19+
# Failed to check session.lock
20+
'MC-10167' => {
21+
headers: [
22+
'java.lang.RuntimeException: Failed to check session lock, aborting'
23+
]
24+
},
25+
# JRE out of RAM
26+
'MC-12949' => {
27+
classes: [
28+
'java.lang.OutOfMemoryError'
29+
]
30+
},
31+
# Unable to fit texture, use a lower texture resolution
32+
'MC-29565' => {
33+
headers: [
34+
'Maybe try a lowerresolution texturepack'
35+
]
36+
},
37+
# Malware or antivirus software blocking localhost connection
38+
'MC-34749' => {
39+
headers: [
40+
'java.lang.IllegalStateException: failed to create a child event loop'
41+
]
42+
},
43+
# Incompatible view distance after downgrading
44+
'MC-38527' => {
45+
classes: [
46+
'java.lang.IndexOutOfBoundsException'
47+
],
48+
versions: [
49+
'1.7.2',
50+
'1.7.4',
51+
'1.7.10'
52+
]
53+
},
54+
# Watchdog shuts down server
55+
'MC-63590' => {
56+
descriptions: [
57+
'Watching Server'
58+
],
59+
classes: [
60+
'java.lang.Error'
61+
]
62+
}
63+
}

config/queries.rb

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# A hash containing queries used by modules.
2+
# This allows for easier modification as everything is in one place,
3+
# and makes the modules more readable.
4+
QUERIES = {
5+
chk: '"Confirmation Status" != "Unconfirmed" AND "CHK" is EMPTY',
6+
fixversion: 'project in (MCL, MCPI, MCPE, MCCE, SC) ' \
7+
'AND resolution = Fixed AND fixVersion is EMPTY'
8+
}

config/query.rb

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# The number of seconds the bot should wait before
2+
# running the module checks again. Can be zero.
3+
# NOTE: As JQL time can only include hours and
4+
# minutes, setting this variable to less than 60
5+
# seconds will waste quite a bit of bandwidth as
6+
# many issues will be retrieved twice, and then
7+
# discarded again.
8+
# See util/issue_pool.rb for more information.
9+
TASK_DELAY = 1 * 60
10+
11+
# The number of seconds the bot should wait if the
12+
# server sends HTTP 429 Too Many Requests (RFC 6585)
13+
EMERGENCY_COOLDOWN = 60 * 60
14+
15+
# The number of seconds the bot should add to its
16+
# copy of TASK_DELAY if the server sends HTTP 429.
17+
EMERGENCY_ADD_DELAY = 1 * 60
18+
19+
# The smallest amount of query results the bot can request
20+
JQL_RESULTS_MIN = 1
21+
22+
# The amount of query results the bot requests by default
23+
JQL_RESULTS_DFL = 50
24+
25+
# The largest number of query results the bot can request.
26+
# This will be used by the IssuePool to retrieve as many
27+
# results as possible. NOTE: The server will most likely
28+
# implement its own limit on JQL query results.
29+
JQL_RESULTS_MAX = 2**(32 - 1) - 1
30+
31+
API_TIME_FORMAT = '%FT%T.%L%z'
32+
JQL_TIME_FORMAT = '%F %R'

config/versions.rb

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# A regular expression that matches unreleased versions
2+
# Set this to nil if you'd like to use JIRA's `released` field instead
3+
VERSION_UNRELEASED_REGEXP = /future/i
4+
5+
# Cache duration for versions when used passively,
6+
# for example in JQL queries
7+
VERSION_CACHE_TTL_PASSIVE = 60 * 60
8+
9+
# Cache duration for versions when used actively,
10+
# for example when updating issues
11+
VERSION_CACHE_TTL_ACTIVE = 2 * 60
12+
13+
# A URL containing the latest JRE version, for example "1.2.3_45"
14+
JRE_VERSION_URL = 'http://java.com/applet/JreCurrentVersion2.txt'
15+
16+
# The time in seconds after which the JRE version should be updated
17+
JRE_CACHE_TTL = 60 * 60 * 24 * 7
18+
19+
# Regular expression that extracts the main part of the version
20+
# from the full version identifier that's used on crash reports
21+
JRE_VERSION_REGEXP = /([\d\.]+_\d+), ([[[:alnum:]][[:blank]]])/
22+
23+
# Vendors that should be ignored when checking for outdated Java
24+
# versions. You can find the vendor name after the Java version
25+
# on crash reports. This setting can be used for vendors that
26+
# tend to use versions that are far behind the latest official
27+
# version in order to prevent the bot from notifying every user
28+
# about their outdated Java version.
29+
JRE_OUTDATED_IGNORE_VENDORS = ['Apple Inc.']

core.rb

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/ruby
2+
3+
require 'jira'
4+
5+
# Require all source files
6+
core_dir = File.dirname(__FILE__)
7+
files = File.join(core_dir, '**', '*.rb')
8+
Dir[files].each { |file| require file }
9+
10+
# Arisa project module
11+
module Arisa
12+
# Stores the JIRA client and starts the main loop
13+
class Core
14+
attr_reader :client
15+
attr_reader :dispatcher
16+
attr_reader :versions
17+
18+
def initialize
19+
@client = JIRA::Client.new(CLIENT_OPTIONS)
20+
@dispatcher = Dispatcher.new(self)
21+
@versions = Versions.new(@client)
22+
end
23+
24+
def start
25+
loop do
26+
@dispatcher.dispatch
27+
sleep @dispatcher.task_delay
28+
end
29+
end
30+
end
31+
32+
Core.new.start
33+
end

0 commit comments

Comments
 (0)