emoji refactor

This commit is contained in:
Laura Hausmann 2019-12-13 20:59:46 +01:00
parent f0fb725e02
commit f4eee05ce6
Signed by: zotan
GPG key ID: 5EC1D38FFC321311
3 changed files with 18 additions and 13 deletions

View file

@ -545,6 +545,7 @@ namespace telegram
if (inputParams.Count == 0) if (inputParams.Count == 0)
{ {
currentInputLine = "/e " + ((TdApi.MessageContent.MessageText) lastMessage?.Content)?.Text?.Text; currentInputLine = "/e " + ((TdApi.MessageContent.MessageText) lastMessage?.Content)?.Text?.Text;
Emojis.ForEach(em => currentInputLine = currentInputLine.Replace(em.Item2, em.Item1));
return; return;
} }

View file

@ -194,10 +194,7 @@ namespace telegram
public static void ClearCurrentConsoleLine() public static void ClearCurrentConsoleLine()
{ {
do Console.Write("\u001b[2K\r");
{
Console.Write("\b \b");
} while (Console.CursorLeft > 0);
//TODO is there a better solution? //TODO is there a better solution?
//Console.SetCursorPosition(0, Console.WindowHeight); //Console.SetCursorPosition(0, Console.WindowHeight);
@ -238,14 +235,7 @@ namespace telegram
{ {
if (string.IsNullOrWhiteSpace(message)) if (string.IsNullOrWhiteSpace(message))
return; return;
message = message.Replace("⏎", "\n") Emojis.ForEach(em => message = message.Replace(em.Item1, em.Item2));
.Replace(":xd:", Emoji.FaceWithTearsOfJoy.Sequence.AsString)
.Replace(":check:", Emoji.WhiteHeavyCheckMark.Sequence.AsString)
.Replace(":thinking:", Emoji.ThinkingFace.Sequence.AsString)
.Replace(":heart:", Emoji.RedHeart.Sequence.AsString)
.Replace(":shrug:", Emoji.PersonShrugging.Sequence.AsString)
.Replace(":shrugf:", Emoji.WomanShrugging.Sequence.AsString)
.Replace(":shrugm:", Emoji.ManShrugging.Sequence.AsString);
client.ExecuteAsync(new SendMessage client.ExecuteAsync(new SendMessage
{ {
ChatId = chatId, ChatId = chatId,
@ -263,6 +253,8 @@ namespace telegram
public static Message EditMessage(string newText, Message message) public static Message EditMessage(string newText, Message message)
{ {
Emojis.ForEach(em => newText = newText.Replace(em.Item1, em.Item2));
var msg = client.ExecuteAsync(new EditMessageText var msg = client.ExecuteAsync(new EditMessageText
{ {
ChatId = message.ChatId, ChatId = message.ChatId,
@ -403,6 +395,19 @@ namespace telegram
return input.Length <= maxLen ? input : "<" + input.Substring(input.Length - maxLen + 1); return input.Length <= maxLen ? input : "<" + input.Substring(input.Length - maxLen + 1);
} }
public static readonly List<Tuple<string, string>> Emojis = new List<Tuple<string, string>>
{
new Tuple<string, string>("⏎", "\n"),
new Tuple<string, string>(":xd:", Emoji.FaceWithTearsOfJoy.Sequence.AsString),
new Tuple<string, string>(":check:", Emoji.WhiteHeavyCheckMark.Sequence.AsString),
new Tuple<string, string>(":thinking:", Emoji.ThinkingFace.Sequence.AsString),
new Tuple<string, string>(":eyes:", Emoji.Eyes.Sequence.AsString),
new Tuple<string, string>(":heart:", Emoji.RedHeart.Sequence.AsString),
new Tuple<string, string>(":shrug:", Emoji.PersonShrugging.Sequence.AsString),
new Tuple<string, string>(":shrugf:", Emoji.WomanShrugging.Sequence.AsString),
new Tuple<string, string>(":shrugm:", Emoji.ManShrugging.Sequence.AsString)
};
public static readonly List<ConsoleKey> SpecialKeys = new List<ConsoleKey> public static readonly List<ConsoleKey> SpecialKeys = new List<ConsoleKey>
{ {
ConsoleKey.Backspace, ConsoleKey.Backspace,

View file

@ -14,7 +14,6 @@ namespace telegram
{ {
/* /*
* TODO: * TODO:
* replace emoji on send & un-replace on edit, two-way dictionary!!
* waaay more error messages instead of just doing nothing or crashing (search for "do something") * waaay more error messages instead of just doing nothing or crashing (search for "do something")
* add option to disable terminal bell * add option to disable terminal bell
* make commands & keybinds more consistent (maybe configurable?) * make commands & keybinds more consistent (maybe configurable?)