fix channels/supergroups
This commit is contained in:
parent
d4aee295a6
commit
d5bcd885dd
|
@ -112,6 +112,7 @@ namespace telegram
|
|||
else if (chat.UnreadCount > 0)
|
||||
{
|
||||
var unreads = GetHistory(chatId, chat.UnreadCount);
|
||||
Console.WriteLine(unreads.Count);
|
||||
var rest = GetHistory(chatId, 5 - unreads.Count, unreads.First().Id);
|
||||
rest.ForEach(AddMessageToQueue);
|
||||
messageQueue.Add($"{Ansi.Yellow}[tgcli] ---UNREAD---");
|
||||
|
@ -273,7 +274,7 @@ namespace telegram
|
|||
{
|
||||
if (currentChatId == 0) return; //TODO: do something
|
||||
MarkUnread(currentChatId);
|
||||
CommandManager.HandleCommand("close");
|
||||
CommandManager.HandleCommand("c");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -444,17 +445,16 @@ namespace telegram
|
|||
{
|
||||
try
|
||||
{
|
||||
|
||||
var message = inputParams.Aggregate((current, param) => current + " " + param).Trim();
|
||||
|
||||
if (currentChatId == 0) return; //TODO do something
|
||||
|
||||
if (message.Length == 0)
|
||||
if (inputParams.Count == 0)
|
||||
{
|
||||
currentInputLine = "/e " + ((TdApi.MessageContent.MessageText) lastMessage?.Content)?.Text?.Text;
|
||||
return;
|
||||
}
|
||||
|
||||
var message = inputParams.Aggregate((current, param) => current + " " + param).Trim();
|
||||
|
||||
if (currentChatId == 0) return; //TODO do something
|
||||
|
||||
if (lastMessage == null)
|
||||
{
|
||||
//try to find last message
|
||||
|
|
|
@ -77,7 +77,6 @@ namespace telegram
|
|||
{
|
||||
var response = client.ExecuteAsync(new SearchChatMessages
|
||||
{
|
||||
|
||||
ChatId = chatId,
|
||||
Query = "+",
|
||||
Limit = 1
|
||||
|
@ -90,17 +89,23 @@ namespace telegram
|
|||
}
|
||||
}
|
||||
|
||||
public static List<Message> GetHistory(long chatId, int limit = 5, long fromMessageId = 0, int offset = 0, bool isSecret = false)
|
||||
public static List<Message> GetHistory(long chatId, int limit = 5, long fromMessageId = 0, int offset = 0,
|
||||
bool isSecret = false, bool skipTotal = false)
|
||||
{
|
||||
var history = new List<Message>();
|
||||
var total = GetTotalMessages(chatId);
|
||||
if (limit > total) limit = total;
|
||||
var chat = GetChat(chatId);
|
||||
if (chat.Type is ChatType.ChatTypeSupergroup || isSecret)
|
||||
skipTotal = true;
|
||||
if (limit > total && !skipTotal) limit = total;
|
||||
|
||||
for (var i = 5; i > 0; i--)
|
||||
{
|
||||
if (limit <= 0)
|
||||
{
|
||||
lock (@lock) messageQueue.Add($"{Ansi.Red}[tgcli] " + $"Limit cannot be less than one. Usage: /history <count>");
|
||||
lock (@lock)
|
||||
messageQueue.Add($"{Ansi.Red}[tgcli] " +
|
||||
$"Limit cannot be less than one. Usage: /history <count>");
|
||||
return history;
|
||||
}
|
||||
|
||||
|
@ -124,6 +129,7 @@ namespace telegram
|
|||
history.Reverse();
|
||||
return history;
|
||||
}
|
||||
|
||||
return history;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,11 +28,10 @@ namespace telegram
|
|||
* make Util.getActualStringWidth better
|
||||
* refactor everything
|
||||
* add option to disable terminal bell
|
||||
* command /s /search -> list matching chats, option 1-n, archived, muted indicator
|
||||
* command /s /search -> list matching chats, archived, muted indicator
|
||||
* mute,unmute chats
|
||||
* split with newline if received message enters next line
|
||||
* fix issues when current_input message is longer than term width (only show as much as fits?)
|
||||
* photo/document/etc captions
|
||||
* photo download & show externally
|
||||
* publish AUR package
|
||||
* maybe cursor input nav (cmd+del, left/right, up for last inputs, etc)
|
||||
|
@ -379,6 +378,14 @@ namespace telegram
|
|||
string text;
|
||||
if (msg.Content is Td.TdApi.MessageContent.MessageText messageText)
|
||||
text = messageText.Text.Text;
|
||||
else if (msg.Content is Td.TdApi.MessageContent.MessagePhoto photo)
|
||||
text = !string.IsNullOrWhiteSpace(photo.Caption.Text)
|
||||
? $"[unsupported {msg.Content.DataType}] {photo.Caption.Text}"
|
||||
: $"[unsupported {msg.Content.DataType}]";
|
||||
else if (msg.Content is Td.TdApi.MessageContent.MessageDocument document)
|
||||
text = !string.IsNullOrWhiteSpace(document.Caption.Text)
|
||||
? $"[unsupported {msg.Content.DataType}] {document.Caption.Text}"
|
||||
: $"[unsupported {msg.Content.DataType}]";
|
||||
else
|
||||
text = $"[unsupported {msg.Content.DataType}]";
|
||||
var sender = GetUser(msg.SenderUserId);
|
||||
|
|
Loading…
Reference in a new issue