Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added file uploading, codeblock printing/parsing, updated readme
- Loading branch information
1 parent
309932f
commit e52d97c
Showing
7 changed files
with
102 additions
and
6 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
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
const Discord = require('discord.js'); | ||
const bot = new Discord.Client(); | ||
const config = require("./config.json"); | ||
const args = process.argv; | ||
const fs = require('fs'); | ||
|
||
bot.on("ready", () =>{ | ||
const chan = bot.channels.find(channel => channel.name === config.channel); | ||
|
||
fs.readFile('/tmp/discho', 'utf-8', (err, data) => { | ||
if (err) throw err; | ||
if (data) { | ||
chan.send(data); | ||
} | ||
}); | ||
|
||
fs.readFile('/tmp/dischofn', 'utf-8', (err, data) => { | ||
if (err) throw err; | ||
fl = __dirname+"/out/" + data.split("/").splice(-1); | ||
fn = "" + data.split("/").splice(-1); | ||
ft = ""+fn.split(".").splice(-1); | ||
|
||
if(args[2] == "cb"){ | ||
if(ft.trim() == "js" || ft.trim() == "py" || ft.trim() == "css" || ft.trim() == "fix" || ft.trim() == "md" || ft.trim() == "cs" || ft.trim() == "diff" || ft.trim() == "tex" || ft.trim() == "sh" || ft.trim() == "h" || ft.trim() == "cpp" || ft.trim() == "json"){ | ||
fs.readFile(fl.trim(),'utf8',(er, cfile) => { | ||
if (er) throw er; | ||
console.log("Detected code file type ["+ft.trim()+"] attempting to print code block") | ||
chan.send("`"+"``"+ft.trim()+"\n"+cfile+"`"+"``") | ||
}) | ||
} | ||
} | ||
|
||
chan.send({files: [{attachment: fl.trim(), name: fn.trim()}]}) | ||
.then(console.log) | ||
.catch(console.error);; | ||
}); | ||
}) | ||
|
||
bot.on('message', function(message){ | ||
if (message.attachments.size > 0) { | ||
process.exit(); | ||
}else{ | ||
console.log("waiting to detect attatchment to exit...") | ||
} | ||
}); | ||
|
||
bot.login(config.token); |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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