forked from elanthia-online/dr-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelp-me.lic
82 lines (69 loc) · 2.56 KB
/
help-me.lic
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
require 'net/http'
class HelpMe
def initialize
arg_definitions = [
[
{ name: 'user', regex: /\b\w+\b/i, optional: true, description: 'Send help_me to a specific user.' },
{ name: 'script_summary', optional: true, description: 'Script that sends installation and yaml information for user help purposes.' }
]
]
args = parse_args(arg_definitions)
@paste_bin_token = 'dca351a27a8af501a8d3123e29af7981'
@paste_bin_url = 'https://pastebin.com/api/api_post.php'
help_me(args.user)
end
def help_me(user = nil)
result = submit_help_pastebin
if result.include?('Bad API request') || user.nil?
echo "#{result} "
else
if Script.running?('lnet')
UpstreamHook.run("<c>#{$clean_lich_char}chat to #{user} #{result}")
echo("Attempted to PM YAML link on lnet to #{user}. Check lnet window for success or failure.")
else
echo "#{result} "
end
end
end
def submit_help_pastebin
message_body += "Lich Version: #{LICH_VERSION}"
message_body += "\n"
message_body += "Ruby Version: #{RUBY_VERSION}p#{RUBY_PATCHLEVEL} #{RUBY_PLATFORM}"
message_body += "\n"
message_body += "Dependency Version: #{$DEPENDENCY_VERSION}"
message_body += "\n"
message_body += "Game Client: #{$frontend}"
message_body += "\n"
message_body += "Dev Mode: #{$manager.developer}"
message_body += "\n"
Dir[File.join(SCRIPT_DIR, 'profiles/*.yaml')].map { |item| File.path(item) }.select { |path| path.include?("#{checkname}-") }.each do |path|
message_body += "\n****" * 3
message_body += path.to_s
message_body += "\n"
message_body += File.read(path)
end
message_body += "\n****\n" * 3
message_body += Dir[File.join(SCRIPT_DIR, 'profiles/*.*')].join(',')
message_body += "\n"
message_body += Dir[File.join(SCRIPT_DIR, 'data/*.*')].join(',')
message_body += "\n"
message_body.gsub!("bastard", "dastard (modified)")
submit_pastebin(message_body)
end
def submit_pastebin(message_body)
uri = URI.parse(@paste_bin_url)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(uri.request_uri)
request.set_form_data(api_dev_key: @paste_bin_token, api_paste_code: message_body, api_paste_private: '1', api_paste_expire_date: '1W', api_option: 'paste')
response = http.request(request)
result = response.body.chomp
if result.size >= 200
'Failed to upload pastebin.'
else
result
end
end
end
HelpMe.new