Use proper database path depending on OSPlatform
This commit is contained in:
parent
60ad19e914
commit
9614e6400f
|
@ -2,6 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Td = TdLib;
|
||||
|
@ -49,7 +50,10 @@ public static class tgcli {
|
|||
if (args.Length == 1 && args[0] == "-s")
|
||||
silent = true;
|
||||
|
||||
dbdir = $"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}{Path.DirectorySeparatorChar}.tgcli";
|
||||
dbdir = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
|
||||
? $"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}{Path.DirectorySeparatorChar}.tgcli"
|
||||
: $"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}{Path.DirectorySeparatorChar}.local{Path.DirectorySeparatorChar}share{Path.DirectorySeparatorChar}tgcli";
|
||||
|
||||
if (!Directory.Exists(dbdir))
|
||||
Directory.CreateDirectory(dbdir);
|
||||
|
||||
|
@ -193,7 +197,7 @@ public static class tgcli {
|
|||
else
|
||||
output += "]";
|
||||
output += " > ";
|
||||
var prefixlen = GetActualStringWidth(output);
|
||||
var prefixlen = GetActualStringWidth(output);
|
||||
var inputLine = GetPagedMessageInputLine(currentInputLine, currentInputPos, Console.LargestWindowWidth - prefixlen);
|
||||
output += inputLine.messageBuffer;
|
||||
|
||||
|
@ -350,17 +354,17 @@ public static class tgcli {
|
|||
switch (state.AuthorizationState) {
|
||||
case AuthorizationState.AuthorizationStateWaitTdlibParameters _:
|
||||
client.Send(new SetTdlibParameters {
|
||||
ApiId = 600606,
|
||||
ApiHash = "c973f46778be4b35481ce45e93271e82",
|
||||
DatabaseDirectory = dbdir,
|
||||
UseMessageDatabase = true,
|
||||
SystemLanguageCode = "en_US",
|
||||
DeviceModel = Environment.MachineName,
|
||||
SystemVersion = ".NET Core CLR " + Environment.Version,
|
||||
ApplicationVersion = "0.3a",
|
||||
EnableStorageOptimizer = true,
|
||||
UseSecretChats = true
|
||||
});
|
||||
ApiId = 600606,
|
||||
ApiHash = "c973f46778be4b35481ce45e93271e82",
|
||||
DatabaseDirectory = dbdir,
|
||||
UseMessageDatabase = true,
|
||||
SystemLanguageCode = "en_US",
|
||||
DeviceModel = Environment.MachineName,
|
||||
SystemVersion = ".NET Core CLR " + Environment.Version,
|
||||
ApplicationVersion = "0.3a",
|
||||
EnableStorageOptimizer = true,
|
||||
UseSecretChats = true
|
||||
});
|
||||
break;
|
||||
// case AuthorizationState.AuthorizationStateWaitEncryptionKey _:
|
||||
// client.Send(new Td.TdApi.CheckDatabaseEncryptionKey());
|
||||
|
@ -416,13 +420,9 @@ public static class tgcli {
|
|||
if (msg.Content is MessageContent.MessageText messageText)
|
||||
text = messageText.Text.Text;
|
||||
else if (msg.Content is MessageContent.MessagePhoto photo)
|
||||
text = !string.IsNullOrWhiteSpace(photo.Caption.Text)
|
||||
? $"[unsupported {msg.Content.DataType}] {photo.Caption.Text}"
|
||||
: $"[unsupported {msg.Content.DataType}]";
|
||||
text = !string.IsNullOrWhiteSpace(photo.Caption.Text) ? $"[unsupported {msg.Content.DataType}] {photo.Caption.Text}" : $"[unsupported {msg.Content.DataType}]";
|
||||
else if (msg.Content is MessageContent.MessageDocument document)
|
||||
text = !string.IsNullOrWhiteSpace(document.Caption.Text)
|
||||
? $"[unsupported {msg.Content.DataType}] {document.Caption.Text}"
|
||||
: $"[unsupported {msg.Content.DataType}]";
|
||||
text = !string.IsNullOrWhiteSpace(document.Caption.Text) ? $"[unsupported {msg.Content.DataType}] {document.Caption.Text}" : $"[unsupported {msg.Content.DataType}]";
|
||||
else
|
||||
text = $"[unsupported {msg.Content.DataType}]";
|
||||
var chat = GetChat(msg.ChatId);
|
||||
|
|
Loading…
Reference in a new issue