2017-11-08 01:30:50 +01:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Text;
|
2017-11-06 23:55:28 +01:00
|
|
|
|
|
|
|
|
|
namespace Geekbot.net.Lib
|
|
|
|
|
{
|
|
|
|
|
public class EmojiConverter : IEmojiConverter
|
|
|
|
|
{
|
|
|
|
|
public string numberToEmoji(int number)
|
|
|
|
|
{
|
|
|
|
|
if (number == 10)
|
|
|
|
|
{
|
|
|
|
|
return "🔟";
|
|
|
|
|
}
|
|
|
|
|
var emojiMap = new string[] {"0⃣", "1⃣", "2⃣", "3⃣", "4⃣", "5⃣", "6⃣", "7⃣", "8⃣", "9⃣"};
|
|
|
|
|
var numbers = number.ToString().ToCharArray();
|
|
|
|
|
var returnString = new StringBuilder();
|
|
|
|
|
foreach (var n in numbers)
|
|
|
|
|
{
|
|
|
|
|
returnString.Append(emojiMap[int.Parse(n.ToString())]);
|
|
|
|
|
}
|
|
|
|
|
return returnString.ToString();
|
|
|
|
|
}
|
2017-11-08 01:30:50 +01:00
|
|
|
|
|
|
|
|
|
public string textToEmoji(string text)
|
|
|
|
|
{
|
|
|
|
|
var emojiMap = new Hashtable
|
|
|
|
|
{
|
|
|
|
|
['A'] = ":regional_indicator_a:",
|
|
|
|
|
['B'] = ":b:",
|
|
|
|
|
['C'] = ":regional_indicator_c:",
|
|
|
|
|
['D'] = ":regional_indicator_d:",
|
|
|
|
|
['E'] = ":regional_indicator_e:",
|
|
|
|
|
['F'] = ":regional_indicator_f:",
|
|
|
|
|
['G'] = ":regional_indicator_g:",
|
|
|
|
|
['H'] = ":regional_indicator_h:",
|
|
|
|
|
['I'] = ":regional_indicator_i:",
|
|
|
|
|
['J'] = ":regional_indicator_j:",
|
|
|
|
|
['K'] = ":regional_indicator_k:",
|
|
|
|
|
['L'] = ":regional_indicator_l:",
|
|
|
|
|
['M'] = ":regional_indicator_m:",
|
|
|
|
|
['N'] = ":regional_indicator_n:",
|
|
|
|
|
['O'] = ":regional_indicator_o:",
|
|
|
|
|
['P'] = ":regional_indicator_p:",
|
|
|
|
|
['Q'] = ":regional_indicator_q:",
|
|
|
|
|
['R'] = ":regional_indicator_r:",
|
|
|
|
|
['S'] = ":regional_indicator_s:",
|
|
|
|
|
['T'] = ":regional_indicator_t:",
|
|
|
|
|
['U'] = ":regional_indicator_u:",
|
|
|
|
|
['V'] = ":regional_indicator_v:",
|
|
|
|
|
['W'] = ":regional_indicator_w:",
|
|
|
|
|
['X'] = ":regional_indicator_x:",
|
|
|
|
|
['Y'] = ":regional_indicator_y:",
|
|
|
|
|
['Z'] = ":regional_indicator_z:",
|
|
|
|
|
['!'] = ":exclamation:",
|
|
|
|
|
['?'] = ":question:",
|
|
|
|
|
['#'] = ":hash:",
|
|
|
|
|
['*'] = ":star2:",
|
|
|
|
|
['+'] = ":heavy_plus_sign:",
|
|
|
|
|
['0'] = ":zero:",
|
|
|
|
|
['1'] = ":one:",
|
|
|
|
|
['2'] = ":two:",
|
|
|
|
|
['3'] = ":three:",
|
|
|
|
|
['4'] = ":four:",
|
2017-11-08 19:19:43 +01:00
|
|
|
|
['5'] = ":five:",
|
|
|
|
|
['6'] = ":six:",
|
2017-11-08 01:30:50 +01:00
|
|
|
|
['7'] = ":seven:",
|
2017-11-08 19:19:43 +01:00
|
|
|
|
['8'] = ":eight:",
|
2017-11-08 01:30:50 +01:00
|
|
|
|
['9'] = ":nine:",
|
|
|
|
|
[' '] = " "
|
|
|
|
|
};
|
|
|
|
|
var letters = text.ToUpper().ToCharArray();
|
|
|
|
|
var returnString = new StringBuilder();
|
|
|
|
|
foreach (var n in letters)
|
|
|
|
|
{
|
|
|
|
|
var emoji = emojiMap[n] ?? n;
|
|
|
|
|
returnString.Append(emoji);
|
|
|
|
|
}
|
|
|
|
|
return returnString.ToString();
|
|
|
|
|
}
|
2017-11-06 23:55:28 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public interface IEmojiConverter
|
|
|
|
|
{
|
|
|
|
|
string numberToEmoji(int number);
|
2017-11-08 01:30:50 +01:00
|
|
|
|
string textToEmoji(string text);
|
2017-11-06 23:55:28 +01:00
|
|
|
|
}
|
|
|
|
|
}
|