mirror of
https://github.com/wiz0u/WTelegramClient.git
synced 2026-04-04 14:07:41 +00:00
updated EXAMPLES.md for Program_Heroku
This commit is contained in:
parent
74f22a2f5c
commit
63faf9a070
2 changed files with 24 additions and 3 deletions
|
|
@ -25,7 +25,8 @@ namespace WTelegramClientTest
|
|||
{
|
||||
var exit = new SemaphoreSlim(0);
|
||||
AppDomain.CurrentDomain.ProcessExit += (s, e) => exit.Release(); // detect SIGTERM to exit gracefully
|
||||
var store = new PostgreStore(); // if DB does not contain a session, client will be run in interactive mode
|
||||
var store = new PostgreStore(Environment.GetEnvironmentVariable("DATABASE_URL"));
|
||||
// if DB does not contain a session yet, client will be run in interactive mode
|
||||
Client = new WTelegram.Client(store.Length == 0 ? null : Environment.GetEnvironmentVariable, store);
|
||||
using (Client)
|
||||
{
|
||||
|
|
@ -65,9 +66,9 @@ namespace WTelegramClientTest
|
|||
private DateTime _lastWrite;
|
||||
private Task _delayedWrite;
|
||||
|
||||
public PostgreStore()
|
||||
public PostgreStore(string databaseUrl) // Heroku DB URL of the form "postgres://user:password@host:port/database"
|
||||
{
|
||||
var parts = Environment.GetEnvironmentVariable("DATABASE_URL").Split(':', '/', '@'); // parse Heroku DB URL
|
||||
var parts = databaseUrl.Split(':', '/', '@');
|
||||
_sql = new NpgsqlConnection($"User ID={parts[3]};Password={parts[4]};Host={parts[5]};Port={parts[6]};Database={parts[7]};Pooling=true;SSL Mode=Require;Trust Server Certificate=True;");
|
||||
_sql.Open();
|
||||
using (var create = new NpgsqlCommand($"CREATE TABLE IF NOT EXISTS WTelegram (name text NOT NULL PRIMARY KEY, data bytea)", _sql))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue