Skip to content

Instantly share code, notes, and snippets.

@chitoku-k
Last active December 27, 2019 05:37
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chitoku-k/9756540 to your computer and use it in GitHub Desktop.
Save chitoku-k/9756540 to your computer and use it in GitHub Desktop.
淫夢語録
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
public class 淫夢語録
{
private static Dictionary<Func<string, bool>, string> sayings = new Dictionary<Func<string, bool>, string>
{
{ text => Regex.IsMatch(text, "(?:なん|何)でも(?:し|す)") && !Regex.IsMatch(text, "ん[??]"), "ん?" },
{ text => Regex.IsMatch(text, @"はい(?:$|[^\w])"), "はいじゃねえよ1dollar!" },
{ text => Regex.IsMatch(text, "年齢(?:を|、)?教えてくれるかな"), "24歳です" },
{ text => Regex.IsMatch(text, "(?:夜中?)?腹減んないで?すか"), "腹減ったな" },
{ text => Regex.IsMatch(text, "屋上ある?んだけど.?(?:焼いてい?かない[??])"), "あぁ^~いいっすね~" },
{ text => Regex.IsMatch(text, "(?:気持ち?|きもち)よく(?:出来|でき)ましたか"), "出来ませんでした・・・・。" },
{ text => Regex.IsMatch(text, "この辺に[いぃ]?うまいラーメン屋(?:の屋台)?、?来てるらしい?っすよ?"), "あっ、そっか" },
{ text => Regex.IsMatch(text, "じゃけん.*しょうね"), "おっそうだな" },
{ text => text.Contains("まずいですよ"), "いいだろ遠野!" },
{ text => text.Contains("見てただろ"), "なんで見る必要なんかあるんですか(正論)" },
{ text => text.Contains("おじさん"), "おじ↑さん↓だとふざけんじゃねえよお前!" },
{ text => text.Contains("ぼくひで"), "ひでしね" },
{ text => text.Where(x => x == '金').Count() > 1, "金金って言うんじゃねえよガキのくせによオォン?" }
};
public static bool Is淫夢語録(string value)
{
return sayings.Any(x => x.Key(value));
}
public static string Get淫夢語録(string value)
{
if (!Is淫夢語録(value))
return "";
return sayings.Where(x => x.Key(value)).Select(x => x.Value).First();
}
}
const 淫夢語録 = (function () {
function Pattern(callback, text) {
if (typeof callback === "string") {
this.callback = target => target.includes(callback);
}
if (callback instanceof RegExp) {
this.callback = target => callback.test(target);
}
if (callback instanceof Function) {
this.callback = callback;
}
if (!this.callback) {
throw new Error("引数 callback: 壊れるなぁ…" + callback.toString());
}
this.text = text;
}
this.sayings = [
new Pattern(text => /(?:なん|何)でも(?:し|す)/.test(text) && !/ん[??]/.test(text), "ん?"),
new Pattern(/はい(?:$|[^\\w])/, "はいじゃねえよ1dollar!"),
new Pattern(/年齢(?:を|、)?教えてくれるかな/, "24歳です"),
new Pattern(/(?:夜中?)?腹減んないで?すか/, "腹減ったな"),
new Pattern(/屋上ある?んだけど.?(?:焼いてい?かない[??])/, "あぁ^~いいっすね~"),
new Pattern(/(?:気持ち?|きもち)よく(?:出来|でき)ましたか/, "出来ませんでした・・・・。"),
new Pattern(/この辺に[いぃ]?うまいラーメン屋(?:の屋台)?、?来てるらしい?っすよ?/, "あっ、そっか"),
new Pattern(/じゃけん.*しょうね/, "おっそうだな"),
new Pattern("まずいですよ", "いいだろ遠野!"),
new Pattern("見てただろ", "なんで見る必要なんかあるんですか(正論)"),
new Pattern("おじさん", "おじ↑さん↓だとふざけんじゃねえよお前!"),
new Pattern("ぼくひで", "ひでしね"),
new Pattern(text => text.split("").filter(x => x == "金").length > 1, "金金って言うんじゃねえよガキのくせによオォン?")
];
this.is淫夢語録 = value => this.sayings.some(x => x.callback(value));
this.get淫夢語録 = value => !this.is淫夢語録(value) ? "" : this.sayings.filter(x => x.callback(value))[0].text;
return this;
}());
using System;
public class Program
{
static void Main(string[] args)
{
Console.WriteLine(淫夢語録.Get淫夢語録("まずいですよ"));
Console.ReadLine();
}
}
console.log(淫夢語録.get淫夢語録("まずいですよ"));
@iciclize
Copy link

えっ…何これは…(ドン引き)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment