Browse Source

[tsh] make default shell os dependent

master
Pavan Jadhaw 6 years ago
parent
commit
fccc263eae
  1. 13
      app.js

13
app.js

@ -1,5 +1,6 @@
const { spawn } = require('child_process');
const { EOL } = require('os');
const os = require('os');
const Telegraf = require('telegraf');
const { path } = require('./util/index.js');
@ -28,11 +29,17 @@ bot.use((ctx, next) =>
`Username Not authenticated!`
)));
// get os info
const home = os.homedir();
const hostname = os.hostname();
const username = os.userInfo().username;
const defaultShell = os.platform() === 'win32' ? 'cmd.exe' : 'bash';
bot.command('start',
ctx => {
ctx.replyWithHTML('Welcome to tsh -- <code>Telegram Shell!</code>');
const newProc = spawn('bash', {
cwd: '/home'
ctx.replyWithHTML(`Welcome to tsh -- <code>Telegram Shell!</code><br><br>You are now connected to <code>${hostname}</code> as <strong>${username}</strong>`);
const newProc = spawn(defaultShell, {
cwd: home
});
newProc.stdout.setEncoding('utf8');
sessions.push(newProc);

Loading…
Cancel
Save