Skip to content

Commit

Permalink
Merge pull request #35 from botwiki/glitch
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanbohacek authored Sep 9, 2020
2 parents 10d6d9c + 254360b commit 023defd
Show file tree
Hide file tree
Showing 29 changed files with 838 additions and 455 deletions.
28 changes: 9 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
***Note: This project is under active development and not available for remixing on Glitch. Instead, please [import it from this GitHub repo](https://glitch.com/#!/import/github/botwiki/glitch-fediverse-bot).***
![Fediverse bot feed](https://cdn.glitch.com/a4825d5c-d1d6-4780-8464-8636780177ef%2Ffeed-comb.png)

# Fediverse bot

![Glitch Fediverse bot feed](https://cdn.glitch.com/a4825d5c-d1d6-4780-8464-8636780177ef%2Ffeed-comb.png)
Make creative online bots that anyone [in the fediverse](https://en.wikipedia.org/wiki/Fediverse) can follow! This project is [under active development](https://github.com/botwiki/fediverse-bot/issues) and contributions and feature suggestions are welcome.


# Glitch Fediverse bot

With this Glitch starter project, you can create a bot that anyone [in the fediverse](https://en.wikipedia.org/wiki/Fediverse) can follow. This project is [in early development](https://github.com/botwiki/glitch-fediverse-bot/issues) with more features coming.

To automate your bot, set up a free service like [cron-job.org](https://cron-job.org/en/), [Uptime Robot](https://uptimerobot.com/), or [a similar one](https://www.google.com/search?q=free+web+cron) to wake up your bot [every 25+ minutes](https://support.glitch.com/t/a-simple-twitter-bot-template/747/16). Use `https://YOUR_PROJECT_NAME.glitch.me/BOT_ENDPOINT` as a URL to which to send the HTTP request. (`BOT_ENDPOINT` is set in your `.env` file.)
- [import to Glitch](https://glitch.com/#!/import/github/botwiki/fediverse-bot)


## Bot administration

You can log into the admin panel by going to `YOUR_PROJECT_NAME.glitch.me/admin` and logging in using the password set inside your `.env` file. This will allow you to delete your bot's posts one by one. (Multi-post deletion is coming!)
You can log into the admin panel by going to `/admin` and logging in using the password set inside your `.env` file. This will allow you to delete your bot's posts one by one. (Multi-post deletion is coming!)

## Bot logic (the back end)

Your bot's logic is inside the `routes/bot-endpoint.js` file. This is the code that runs when you access your bot's endpoint, as defined inside the `.env` file. See the `examples` folder for some examples of what your bot can do.
*TBD*

## The look of your bot's page (the front end)

Expand All @@ -27,7 +23,7 @@ You can use [ES6](http://es6-features.org/#Constants), you script files will be

## TO-DO:

[See issues on GitHub.](https://github.com/fourtonfish/glitch-fediverse-bot/issues)
[See issues on GitHub.](https://github.com/fourtonfish/fediverse-bot/issues)

## Resources:

Expand All @@ -38,11 +34,5 @@ You can use [ES6](http://es6-features.org/#Constants), you script files will be

## Debugging/testing

- [webfinger output](https://glitch-fediverse-bot.glitch.me/.well-known/webfinger?resource=acct:[email protected])
- [the Actor object](https://glitch-fediverse-bot.glitch.me/bot?debug=true)


Powered by [Glitch](https://glitch.com/)
-------------------

\ ゜o゜)ノ
- [webfinger output](https://fediverse-bot.glitch.me/.well-known/webfinger?resource=acct:[email protected])
- [the Actor object](https://fediverse-bot.glitch.me/bot?debug=true)
96 changes: 48 additions & 48 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,78 +1,78 @@
var path = require('path'),
express = require('express'),
session = require('express-session'),
SQLiteStore = require('connect-sqlite3')(session),
exphbs = require('express-handlebars'),
bodyParser = require('body-parser'),
pubSubHubbub = require('pubsubhubbub'),
sassMiddleware = require('node-sass-middleware'),
babelify = require('express-babelify-middleware'),
helpers = require(__dirname + '/helpers/general.js'),
db = require(__dirname + '/helpers/db.js'),
app = express();
const path = require( 'path' ),
express = require( 'express' ),
session = require( 'express-session' ),
SQLiteStore = require( 'connect-sqlite3' )( session ),
exphbs = require( 'express-handlebars' ),
bodyParser = require( 'body-parser' ),
pubSubHubbub = require( 'pubsubhubbub' ),
sassMiddleware = require( 'node-sass-middleware' ),
babelify = require( 'express-babelify-middleware' ),
helpers = require( __dirname + '/helpers/general.js' ),
db = require( __dirname + '/helpers/db.js' ),
app = express();

app.use(express.static('public'));
app.use( express.static( 'public' ) );

app.use(bodyParser.json({
app.use( bodyParser.json( {
type: 'application/activity+json'
}));
} ) );

app.use(bodyParser.urlencoded({
app.use( bodyParser.urlencoded( {
extended: true
}));
} ) );

app.use(session({
app.use( session( {
store: new SQLiteStore,
secret: process.env.ADMIN_PASSWORD,
resave: true,
saveUninitialized: true,
cookie: { maxAge: 7 * 24 * 60 * 60 * 1000 }
}));
} ) );

app.use(sassMiddleware({
app.use( sassMiddleware( {
// src: __dirname,
src: __dirname + '/src/styles',
dest: path.join(__dirname, 'public'),
dest: path.join( __dirname, 'public' ),
force: true,
// debug: true,
outputStyle: 'compressed',
response: true
}));
} ) );

app.use('/js/scripts.js', babelify('src/scripts/scripts.js', {
app.use( '/js/scripts.js', babelify( 'src/scripts/scripts.js', {
minify: true
}));
} ) );

app.engine('handlebars', exphbs({
app.use('/node_modules', express.static(__dirname + '/node_modules/'));

app.engine( 'handlebars', exphbs( {
defaultLayout: 'main',
helpers: {
for: require('./handlebars-helpers/for'),
equals: require('./handlebars-helpers/equals')
for: require( './handlebars-helpers/for' ),
equals: require( './handlebars-helpers/equals' )
}
}));

app.set('views', __dirname + '/views');
app.set('view engine', 'handlebars');
} ) );

app.use('/', require('./routes/index.js'))
app.use('/admin', require('./routes/admin.js'));
app.use('/bot', require('./routes/bot.js'));
app.use('/delete-post', require('./routes/delete-post.js'));
app.use('/feed', require('./routes/feed.js'));
app.use('/img', express.static(__dirname + '/.data/img/'));
app.set( 'views', __dirname + '/views' );
app.set( 'view engine', 'handlebars' );

app.use('/inbox', require('./routes/inbox.js'));
app.use('/outbox', require('./routes/outbox.js'));
app.use('/post', require('./routes/post.js'));
app.use('/pubsub', require('./routes/pubsub.js'));
app.use('/salmon', require('./routes/salmon.js'));
app.use('/webhook', require('./routes/webhook.js'));
app.use('/.well-known', require('./routes/well-known.js'));
app.use( '/', require( './routes/index.js' ) )
app.use( '/admin', require( './routes/admin.js' ) );
app.use( '/bot', require( './routes/bot.js' ) );
app.use( '/delete-post', require( './routes/delete-post.js' ) );
app.use( '/feed', require( './routes/feed.js' ) );
app.use( '/img', express.static( __dirname + '/.data/img/' ) );

app.use(`/${process.env.BOT_ENDPOINT}`, require('./routes/bot-endpoint.js'));
app.use( '/inbox', require( './routes/inbox.js' ) );
app.use( '/outbox', require( './routes/outbox.js' ) );
app.use( '/post', require( './routes/post.js' ) );
app.use( '/pubsub', require( './routes/pubsub.js' ) );
app.use( '/salmon', require( './routes/salmon.js' ) );
app.use( '/webhook', require( './routes/webhook.js' ) );
app.use( '/.well-known', require( './routes/well-known.js' ) );

app.get('/js/helpers.js', function (req, res) {
res.sendFile(path.join(__dirname + '/helpers/general.js'));
});
app.get( '/js/helpers.js', function ( req, res ) {
res.sendFile( path.join( __dirname + '/helpers/general.js' ) );
} );

module.exports = app;
Loading

0 comments on commit 023defd

Please sign in to comment.