Fix Bear
This commit is contained in:
+17
-9
@@ -199,8 +199,12 @@ function bareBaresayRainbowCodes() {
|
||||
/** Extract cow body from .cow text (Perl heredoc or raw template). */
|
||||
function bareBaresayExtractCow(raw) {
|
||||
const s = String(raw || '').replace(/^\ufeff/, '')
|
||||
const m = s.match(/\$the_cow\s*=\s*<<"EOC"\s*\r?\n([\s\S]*?)\r?\nEOC\b/)
|
||||
if (m) return m[1].replace(/\r\n/g, '\n')
|
||||
// cowsay uses: $the_cow = <<"EOC"; ← semicolon before newline
|
||||
const m = s.match(
|
||||
/\$the_cow\s*=\s*<<"EOC"\s*;?\s*\r?\n([\s\S]*?)\r?\n\s*EOC\s*(?:\r?\n|$)/m
|
||||
)
|
||||
if (m)
|
||||
return m[1].replace(/\r\n/g, '\n').replace(/\n+$/, '') + '\n'
|
||||
return s.replace(/\r\n/g, '\n').trimEnd() + '\n'
|
||||
}
|
||||
|
||||
@@ -212,11 +216,15 @@ function bareBaresayExtractCow(raw) {
|
||||
*/
|
||||
function bareBaresayFillCow(template, eyes, tongue, thoughts) {
|
||||
const e = (eyes || 'oo').slice(0, 2).padEnd(2, 'o')
|
||||
const L = e.charAt(0) || 'o'
|
||||
const R = e.charAt(1) || 'o'
|
||||
const tg = (tongue || ' ').slice(0, 1)
|
||||
const th = thoughts || '\\'
|
||||
return template
|
||||
.replace(/\$thoughts/g, th)
|
||||
.replace(/\$eyes/g, e)
|
||||
.replace(/\$L/g, L)
|
||||
.replace(/\$R/g, R)
|
||||
.replace(/\$tongue/g, tg)
|
||||
}
|
||||
|
||||
@@ -264,13 +272,13 @@ function bareBaresayCompose(message, cowBody, opts) {
|
||||
function bareBaresayFallbackBearTemplate() {
|
||||
return [
|
||||
' $thoughts',
|
||||
' $thoughts .--.--.',
|
||||
' $thoughts ( @ @ )',
|
||||
' $thoughts / $eyes \\',
|
||||
' $thoughts | $tongue |',
|
||||
' $thoughts \\______/',
|
||||
' $thoughts ||',
|
||||
' $thoughts ~~'
|
||||
' $thoughts __ __',
|
||||
' $thoughts / \\.-"""-./ \\',
|
||||
' $thoughts \\ - - /',
|
||||
' $thoughts | $L $R |',
|
||||
' $thoughts \\ .-\'\'\'-. /',
|
||||
" $thoughts '-\\__Y__/-'",
|
||||
' $thoughts \u0060---\u0060'
|
||||
].join('\n')
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user