Skip to content

Commit 663b75c

Browse files
Supported sending files to cliq
Initial setup * Generating a client-id and a client-secret * Authenticating the user on web using OAuth 2.0 Actual Logic * REST API call to upload a file to cliq-server * support for sending a file to a user's email, channel, bot or just using the chat-id
1 parent 1acf305 commit 663b75c

File tree

9 files changed

+1192
-1
lines changed

9 files changed

+1192
-1
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/.vscode
2+
/node_modules

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,13 @@
11
# cliq-to using command line
2-
A gift for people who use command-line often to send cliq attachments quickly.
2+
A gift for people who use command-line often to send cliq attachments quickly.
3+
4+
#### Usage: cliq-to [options] [file]
5+
6+
### Options:
7+
8+
* -v, --version output the version number
9+
* -ch, --channel [string] Channel name in cliq
10+
* -b, --bot [string] Bot name in cliq
11+
* -i, --chat-id [string] Chat id on cliq
12+
* -e, --email [string] Email id on cliq
13+
* -h, --help output usage information

index.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env node
2+
3+
const os = require('os'),
4+
path = require('path'),
5+
commander = require('commander'),
6+
sendFileToCliq = require('./src/sendFileToCliq').sendFileToCliq,
7+
accessTokenFetcher = require('./src/accessTokenFetcher').accessTokenFetcher,
8+
packageJson = require('./package.json');
9+
10+
global.FileSystem = {};
11+
global.FileSystem.home = path.join(os.homedir(),".cliqTo");
12+
global.FileSystem.oauthDataFile = path.join(global.FileSystem.home,"oauth.json");
13+
global.FileSystem.tokenDataFile = path.join(global.FileSystem.home,"token.json");
14+
15+
global.app = {};
16+
global.app.port = 12345;
17+
global.app.authenticationPath = '/authentication';
18+
global.app.authenticationUrl = "http://localhost:"+global.app.port+global.app.authenticationPath;
19+
global.app.callbackPath = '/callback';
20+
global.app.callbackUrl = "http://localhost:"+global.app.port+global.app.callbackPath;
21+
22+
let cliqTo = (filePath) => {
23+
try{
24+
sendFileToCliq(
25+
{
26+
channel : commander.channel,
27+
bot : commander.bot,
28+
chatId : commander.chatId,
29+
email : commander.email
30+
},
31+
accessTokenFetcher,
32+
filePath
33+
);
34+
} catch(e){
35+
console.error(e);
36+
}
37+
}
38+
39+
commander
40+
.version(packageJson.version,'-v, --version')
41+
.option('-ch, --channel [string]','Channel name in cliq')
42+
.option('-b, --bot [string]','Bot name in cliq')
43+
.option('-i, --chat-id [string]','Chat id on cliq')
44+
.option('-e, --email [string]','Email id on cliq')
45+
.action(cliqTo)
46+
.parse(process.argv);

0 commit comments

Comments
 (0)