Account workflow

A typical z3n7 project works through a range of accounts: it picks the next account that is due, starts the browser with that account's profile, does its job and records the result.

// jVars must hold a path to an existing file: InitVariables reads it with File.ReadAllText
// 1. Session start: ZennoPoster file logs off, session id, account range, SAFU, embedded server
project.InitVariables(instance);

// 2. Pick an account that is due and start its browser
project.ChooseAndRunByCondition(instance,
    "daily < NOW OR daily = ''",       // condition on the project table
    browser: true);                    // Chromium; false = no browser

// 3. ... the actual work, with project.Db*, Rqst, Mail, instance.He* ...

// 4. Record the result
project.DbDone("daily", cooldownMin: 24 * 60);   // due again in 24 hours

// 5. Report, save the profile, free the account, stop the instance
project.Finish(instance);

Picking an account

ChooseAccountByCondition looks for accounts in the project table that match the condition and the cfgAccRange range, picks one at random (or the one with the oldest task column with sortByTaskAge) and stores it in acc0. Its row gets status = 'working...'.

  • NOW in the condition becomes the current time, so timestamps written by DbDone can be compared directly.
  • Range groups separated by : in cfgAccRange are priorities: 1-10:11-100 tries 1–10 first.
  • filterTwitter, filterDiscord, filterGithub keep only accounts whose row in _twitter, _discord, _github has status = 'ok'.
  • acc0Forced overrides the choice.

ChooseAndRunByCondition also starts the browser and moves on to the next account when the profile folder cannot be opened.

Starting the browser

RunBrowser launches the browser with the account's profile folder ({profiles_folder}/accounts/profilesFolder/{acc0}), then applies WebGL settings, proxy and cookies from the account's _instance row. The proxy is checked first: it must answer and show an IP different from the local one.

Finishing

Finish writes a success report, or an error report with a screenshot when lastQuery contains dropped, to the log and the account's row; saves the profile; clears acc0 and the account's busy flag; and stops the instance.

See also: 04. Project variables, 05. Database, Accounts.