mirror of
https://github.com/fazo96/telecommander.git
synced 2025-01-09 11:29:51 +01:00
I can't believe I forgot some files. But I did.
This commit is contained in:
parent
93b0c8a9b6
commit
0905019b55
29
lib/cli.js
Normal file
29
lib/cli.js
Normal file
@ -0,0 +1,29 @@
|
||||
module.exports = function(data){
|
||||
data.cli = require('commander')
|
||||
data.cli
|
||||
.version('0.1.0')
|
||||
.description('the full-featured curses-like command line client for Telegram.\n\n More Info: https://github.com/fazo96/telecommander')
|
||||
.usage('[options]')
|
||||
.option('-d, --debug', "debug mode")
|
||||
.option('-t, --testdc',"use Telegram's test DataCenter")
|
||||
.option('-n, --nuke','delete user data and access key (overdramatic log out)')
|
||||
.parse(process.argv)
|
||||
|
||||
data.debug = data.cli.debug
|
||||
|
||||
if(data.cli.testdc){
|
||||
data.dataCenter = data.telegramLink.TEST_PRIMARY_DC
|
||||
} else data.dataCenter = data.telegramLink.PROD_PRIMARY_DC
|
||||
|
||||
if(data.cli.nuke){
|
||||
var fs = require('fs')
|
||||
try {
|
||||
fs.unlinkSync(data.keyFile)
|
||||
fs.unlinkSync(data.userFile)
|
||||
} catch (e){
|
||||
console.log("Couldn't delete "+data.keyFile+" and "+data.userFile+". They probably don't exist.")
|
||||
}
|
||||
console.log('Deleted',data.keyFile,'and',data.userFile)
|
||||
process.exit(0)
|
||||
}
|
||||
}
|
40
lib/ui-widgets/chatbox.js
Normal file
40
lib/ui-widgets/chatbox.js
Normal file
@ -0,0 +1,40 @@
|
||||
var blessed = require('blessed')
|
||||
|
||||
function ChatBox(options) {
|
||||
var self = this
|
||||
if (!(this instanceof blessed.Node)) {
|
||||
return new ChatBox(options)
|
||||
}
|
||||
options = options || {}
|
||||
options.scrollable = true
|
||||
this.options = options
|
||||
blessed.Box.call(this, options)
|
||||
this.on('log',function(text){
|
||||
if(self.options.autoscroll) self.setScrollPerc(100);
|
||||
this.setLine(this.getLines().length-1,this.getLine(this.getLines().length-1).trim())
|
||||
self.screen.render()
|
||||
})
|
||||
this.on('prepend',function(){
|
||||
this.setLine(this.getLines().length-1,this.getLine(this.getLines().length-1).trim())
|
||||
self.screen.render()
|
||||
})
|
||||
this.on('click',function(){
|
||||
self.focus()
|
||||
self.screen.render()
|
||||
})
|
||||
}
|
||||
|
||||
ChatBox.prototype.__proto__ = blessed.Box.prototype
|
||||
ChatBox.prototype.type = 'chatbox'
|
||||
ChatBox.prototype.add = ChatBox.prototype.log = function(){
|
||||
var text = Array.prototype.slice.call(arguments).join(' ')
|
||||
this.pushLine(text)
|
||||
this.emit('log',text)
|
||||
}
|
||||
ChatBox.prototype.prepend = function(){
|
||||
var text = Array.prototype.slice.call(arguments).join(' ')
|
||||
this.insertLine(0,text)
|
||||
this.emit('prepend',text)
|
||||
}
|
||||
|
||||
module.exports = ChatBox
|
Loading…
Reference in New Issue
Block a user