ruboty-fop 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/ruboty-fop/version.rb +1 -1
- data/lib/ruboty/handlers/fop.rb +26 -12
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 738aecee9800922f4f72ee55b24ea1cea5350203e58587f46c66ea2c547dfba3
|
4
|
+
data.tar.gz: 84f602dd1affa279e20883a36927c23a1fb4e3ac0c69a782bb826faaef33d084
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58ecdfe269f3aa4ce77c1ea9fa27ce3fef6b77a836e9ba721dba5e6506a8a30310354510ead2b56aef13b758ed83db12eb2998bf71d63c111151187814cbae62
|
7
|
+
data.tar.gz: ef763b7848544704a10719f3ecfc28d1c9cf9d31e28464bce5f060a72f96ab3601cf0ee9c32ec61db26df27483efb2320fc4d0b3245c7eb71e8a132bbb28ac20
|
data/Gemfile.lock
CHANGED
data/lib/ruboty-fop/version.rb
CHANGED
data/lib/ruboty/handlers/fop.rb
CHANGED
@@ -38,8 +38,8 @@ CARD:
|
|
38
38
|
|
39
39
|
CLASS: #{fop.valid_dom_classes.map { |_| "`#{_.code}` #{_.name}" }.join(", ")}
|
40
40
|
FARE:
|
41
|
-
#{fop.valid_dom_fares.map { |_| "- dom: `#{_.code}` #{_.name}: #{_.remark}" }.join("\n")}
|
42
|
-
#{fop.valid_intl_fares.map { |_| "- intl: `#{_.code}` #{_.name}: #{_.remark}" }.join("\n")}
|
41
|
+
#{fop.valid_dom_fares.map { |_| "- dom: `#{_.code}` #{_.name}: #{_.remark.gsub(/\*|_/,'')}" }.join("\n")}
|
42
|
+
#{fop.valid_intl_fares.map { |_| "- intl: `#{_.code}` #{_.name}: #{_.remark.gsub(/\*|_/,'')}" }.join("\n")}
|
43
43
|
EOF
|
44
44
|
rescue ::Fop::Error
|
45
45
|
message.reply e.inspect
|
@@ -128,15 +128,15 @@ FARE:
|
|
128
128
|
#{from.code} (#{from.name}) - #{to.code} (#{to.name})
|
129
129
|
#{klass ? "#{klass.name}, " : nil}#{fare.name}, #{status.name} (#{card.name})
|
130
130
|
|
131
|
-
|
132
|
-
|
131
|
+
#{bold}single-trip #{result.miles} miles, #{result.fop} FOP#{bold}
|
132
|
+
#{italic}round-trip #{result.miles * 2} miles, #{result.fop * 2} FOP#{italic}
|
133
133
|
|
134
|
-
Mileage
|
135
|
-
- #{result.flight_miles} (#{result.flight_miles_remark})
|
136
|
-
#{result.bonus_miles ? "- #{result.bonus_miles} (#{result.bonus_miles_remark})" : nil}
|
137
|
-
FOP
|
138
|
-
|
139
|
-
#{result.fop_bonus ? "- #{result.fop_bonus } (#{result.fop_bonus_remark})" : nil}
|
134
|
+
#{bold}Mileage:#{bold}
|
135
|
+
- #{result.flight_miles} (#{result.flight_miles_remark.gsub(/\*|_/,'')})
|
136
|
+
#{result.bonus_miles ? "- #{result.bonus_miles} (#{result.bonus_miles_remark.gsub(/\*|_/,'')})" : nil}
|
137
|
+
#{bold}FOP:#{bold}
|
138
|
+
#{result.flight_miles} x #{result.fop_rate}
|
139
|
+
#{result.fop_bonus ? "- #{result.fop_bonus } (#{result.fop_bonus_remark.gsub(/\*|_/,'')})" : nil}
|
140
140
|
EOF
|
141
141
|
rescue ::Fop::Error => e
|
142
142
|
message.reply e.message
|
@@ -191,7 +191,7 @@ FOP:
|
|
191
191
|
def find_dom_fare(str)
|
192
192
|
fare = fop.valid_dom_fares.find { |_| _.code == str }
|
193
193
|
unless fare
|
194
|
-
list = fop.valid_dom_fares.map { |_| "- `#{_.code}` #{_.name}: #{_.remark}" }.join("\n")
|
194
|
+
list = fop.valid_dom_fares.map { |_| "- `#{_.code}` #{_.name}: #{_.remark.gsub(/\*|_/,'')}" }.join("\n")
|
195
195
|
if str
|
196
196
|
raise ::Fop::Error, "fare #{str.inspect} is not valid\n#{list}"
|
197
197
|
else
|
@@ -204,7 +204,7 @@ FOP:
|
|
204
204
|
def find_intl_fare(str)
|
205
205
|
fare = fop.valid_intl_fares.find { |_| _.code == str }
|
206
206
|
unless fare
|
207
|
-
list = fop.valid_intl_fares.map { |_| "- `#{_.code}` #{_.name}: #{_.remark}" }.join("\n")
|
207
|
+
list = fop.valid_intl_fares.map { |_| "- `#{_.code}` #{_.name}: #{_.remark.gsub(/\*|_/,'')}" }.join("\n")
|
208
208
|
if str
|
209
209
|
raise ::Fop::Error, "fare #{str.inspect} is not valid\n#{list}"
|
210
210
|
else
|
@@ -248,6 +248,20 @@ FOP:
|
|
248
248
|
def parse_options(str)
|
249
249
|
str&.scan(/-(.+?) (.+?)(?:\s+|$)/)&.map{ |_| [_[0].to_sym, _[1]] }.to_h || {}
|
250
250
|
end
|
251
|
+
|
252
|
+
def bold
|
253
|
+
markdown? ? '**' : '*'
|
254
|
+
end
|
255
|
+
|
256
|
+
def italic
|
257
|
+
'_'
|
258
|
+
end
|
259
|
+
|
260
|
+
def markdown?
|
261
|
+
return @use_markdown if @markdown_detected
|
262
|
+
@markdown_detected = true
|
263
|
+
@use_markdown = ENV['RUBOTY_FOP_MARKDOWN'] || Ruboty::AdapterBuilder.adapter_classes.last.name.include?('Discord')
|
264
|
+
end
|
251
265
|
end
|
252
266
|
end
|
253
267
|
end
|