-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9f8fbc9
commit 61fcc6d
Showing
5 changed files
with
34 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
- clone this repository | ||
- create a mastodon account for your bot, e.g. on https://botsin.space/ | ||
- when your account is approved, go to the [development settings](https://botsin.space/settings/applications) and create a new application | ||
- copy [`/config/.env_example`](./config/.env_example) to `/config/.env` | ||
- copy [`/config/.env_example`](./config/.env_example) to `/config/.env` (for local test, **do not upload the .env to GitHub!**) | ||
- copy the access token from the mastodon application and save it in the `.env` as `MASTODON_TOKEN`, go to the repository settings on GitHub under `{repo_url}/settings/secrets/actions` and save it there too (not necessary if you plan to run the bot on your own webserver) | ||
- save the mastodon instance URL in the `.env` as `MASTODON_INSTANCE`, save it as GitHub repository secret as well | ||
- if you plan to use remote authentication with the mastodon app, you will need to do the same for the client key, secret and callback-URL | ||
|
@@ -69,14 +69,22 @@ jobs: | |
|
||
# please note that this requires read/write permissions for the actions runner! | ||
- name: "Commit log" | ||
run: | | ||
git config user.name github-actions | ||
git config user.email [email protected] | ||
git add data/posted.json | ||
git commit -m "posted toot" | ||
git push | ||
uses: stefanzweifel/git-auto-commit-action@v4 | ||
with: | ||
commit_message: ":octocat: posted toot" | ||
file_pattern: 'data/posted.json' | ||
``` | ||
## related projects | ||
- [php-tootbot/php-tootbot](https://github.com/php-tootbot/php-tootbot) | ||
- [php-tootbot/tootbot-template](https://github.com/php-tootbot/tootbot-template) | ||
- [chillerlan/php-httpinterface](https://github.com/chillerlan/php-httpinterface) | ||
- [chillerlan/php-http-message-utils](https://github.com/chillerlan/php-http-message-utils) | ||
- [chillerlan/php-oauth-core](https://github.com/chillerlan/php-oauth-core) | ||
- [chillerlan/php-oauth-providers](https://github.com/chillerlan/php-oauth-providers) | ||
- [chillerlan/php-settings-container](https://github.com/chillerlan/php-settings-container) | ||
- [chillerlan/php-dotenv](https://github.com/chillerlan/php-dotenv) | ||
## disclaimer | ||
WE'RE TOTALLY NOT RUNNING A PRODUCTION-LIKE ENVIRONMENT ON GITHUB.<br> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
/** | ||
* common.php | ||
* TootBot CLI runner | ||
* | ||
* @created 03.12.2022 | ||
* @author smiley <[email protected]> | ||
|
@@ -14,22 +14,15 @@ | |
use Psr\Log\LogLevel; | ||
|
||
ini_set('date.timezone', 'UTC'); | ||
#mb_internal_encoding('UTF-8'); | ||
|
||
require_once __DIR__.'/../vendor/autoload.php'; | ||
|
||
// if we're running on gh-actions, we're going to fetch the variables from gh.secrets, | ||
if(isset($_SERVER['GITHUB_ACTIONS'])){ | ||
$instance = getenv('MASTODON_INSTANCE'); | ||
$apiToken = getenv('MASTODON_TOKEN'); | ||
// otherwise we'll load them from the local .env file into the global environment | ||
if(!isset($_SERVER['GITHUB_ACTIONS'])){ | ||
(new DotEnv(__DIR__.'/../config', '.env', true))->load(); | ||
} | ||
// otherwise we're loading them from the local .env file | ||
else{ | ||
$env = (new DotEnv(__DIR__.'/../config', '.env', false))->load(); | ||
|
||
$instance = $env->get('MASTODON_INSTANCE'); | ||
$apiToken = $env->get('MASTODON_TOKEN'); | ||
} | ||
|
||
|
||
// invoke the options instance | ||
$options = new TootBotOptions; | ||
|
@@ -41,14 +34,14 @@ | |
|
||
// OAuthOptionsTrait | ||
// these settings are only required for authentication/remote token acquisition | ||
#$options->key = $env->get('MASTODON_KEY') ?? ''; | ||
#$options->secret = $env->get('MASTODON_SECRET') ?? ''; | ||
#$options->callbackURL = $env->get('MASTODON_CALLBACK_URL') ?? ''; | ||
#$options->key = getenv('MASTODON_KEY'); | ||
#$options->secret = getenv('MASTODON_SECRET'); | ||
#$options->callbackURL = getenv('MASTODON_CALLBACK_URL'); | ||
#$options->sessionStart = true; | ||
|
||
// TootBotOptions | ||
$options->instance = $instance; | ||
$options->apiToken = $apiToken; | ||
$options->instance = getenv('MASTODON_INSTANCE'); | ||
$options->apiToken = getenv('MASTODON_TOKEN'); | ||
$options->loglevel = LogLevel::INFO; | ||
#$options->buildDir = __DIR__.'/../.build'; | ||
$options->dataDir = __DIR__.'/../data'; | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,23 +2,24 @@ | |
/** | ||
* Class MyTootBot | ||
* | ||
* @todo: update/change docblock | ||
* | ||
* @created 03.02.2023 | ||
* @author smiley <[email protected]> | ||
* @copyright 2023 smiley | ||
* @author you | ||
* @copyright 2023 you | ||
* @license MIT | ||
*/ | ||
|
||
namespace PHPTootBot\MyTootBot; | ||
|
||
use PHPTootBot\PHPTootBot\TootBot; | ||
use PHPTootBot\PHPTootBot\TootBotInterface; | ||
|
||
/** | ||
* | ||
*/ | ||
class MyTootBot extends TootBot{ | ||
|
||
public function post():TootBotInterface{ | ||
public function post():static{ | ||
// TODO: Implement post() method. | ||
|
||
return $this; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,11 @@ | |
/** | ||
* Class MyTootBotTest | ||
* | ||
* @todo: update/change docblock | ||
* | ||
* @created 03.02.2023 | ||
* @author smiley <[email protected]> | ||
* @copyright 2023 smiley | ||
* @author you | ||
* @copyright 2023 you | ||
* @license MIT | ||
*/ | ||
|
||
|