add reply command
This commit is contained in:
parent
3d6d6f62d9
commit
681270d95d
|
@ -34,6 +34,7 @@ namespace telegram
|
||||||
new ClearCommand(),
|
new ClearCommand(),
|
||||||
new CloseCommand(),
|
new CloseCommand(),
|
||||||
new EditCommand(),
|
new EditCommand(),
|
||||||
|
new ReplyCommand(),
|
||||||
new HistoryCommand(),
|
new HistoryCommand(),
|
||||||
new OpenCommand(),
|
new OpenCommand(),
|
||||||
new UnreadsCommand(),
|
new UnreadsCommand(),
|
||||||
|
@ -481,4 +482,43 @@ namespace telegram
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class ReplyCommand : Command
|
||||||
|
{
|
||||||
|
public ReplyCommand() : base("r", "", "replies to message", "<offset> <message>", -1)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Handler(List<string> inputParams)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (inputParams.Count < 2)
|
||||||
|
{
|
||||||
|
return; //TODO do something
|
||||||
|
}
|
||||||
|
|
||||||
|
var history = GetHistory(currentChatId, 50);
|
||||||
|
var parsed = int.TryParse(inputParams[0], out var offset);
|
||||||
|
inputParams.RemoveAt(0);
|
||||||
|
history.Reverse();
|
||||||
|
var message = inputParams.Aggregate((current, param) => current + " " + param).Trim();
|
||||||
|
|
||||||
|
if (!parsed || string.IsNullOrWhiteSpace(message) || history.Count < offset)
|
||||||
|
{
|
||||||
|
return; //TODO do something
|
||||||
|
}
|
||||||
|
|
||||||
|
var replyMessage = history[offset - 1];
|
||||||
|
|
||||||
|
if (currentChatId == 0) return; //TODO do something
|
||||||
|
|
||||||
|
SendMessage(message, currentChatId, replyMessage.Id);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
//TODO do something
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -228,7 +228,7 @@ namespace telegram
|
||||||
return pass;
|
return pass;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SendMessage(string message, long chatId)
|
public static void SendMessage(string message, long chatId, long replyTo = 0)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(message))
|
if (string.IsNullOrWhiteSpace(message))
|
||||||
return;
|
return;
|
||||||
|
@ -247,7 +247,8 @@ namespace telegram
|
||||||
{
|
{
|
||||||
Text = message
|
Text = message
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
ReplyToMessageId = replyTo,
|
||||||
});
|
});
|
||||||
currentUserRead = false;
|
currentUserRead = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,9 +15,7 @@ namespace telegram
|
||||||
/*
|
/*
|
||||||
* TODO:
|
* TODO:
|
||||||
* improve secret chat open: open by username, allow just one sec chat per userId
|
* improve secret chat open: open by username, allow just one sec chat per userId
|
||||||
* commands: more shortcuts?
|
|
||||||
* make commands & keybinds more consistent (maybe configurable?)
|
* make commands & keybinds more consistent (maybe configurable?)
|
||||||
* reply to x messages ago
|
|
||||||
* replace emoji on send & un-replace on edit, two-way dictionary!!
|
* replace emoji on send & un-replace on edit, two-way dictionary!!
|
||||||
* replace more emojis on send (is there a lib for that)
|
* replace more emojis on send (is there a lib for that)
|
||||||
* make typing newlines actually good (inputline as list?)
|
* make typing newlines actually good (inputline as list?)
|
||||||
|
|
Loading…
Reference in a new issue