forked from GitHub/dbot
Added crypto module
This commit is contained in:
parent
75b4b4e2c2
commit
7a51fdf524
29
modules/crypto/README.md
Normal file
29
modules/crypto/README.md
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
## Reddit
|
||||||
|
|
||||||
|
Various Reddit functionality
|
||||||
|
|
||||||
|
### Description
|
||||||
|
|
||||||
|
This module provides Reddit related functionality, which is currently limited to
|
||||||
|
reading various links, but will be expanded in future to include stuff like
|
||||||
|
monitoring posts and creating its own.
|
||||||
|
|
||||||
|
### API
|
||||||
|
|
||||||
|
#### getSubredditInfo(name, callback)
|
||||||
|
Get information about a subreddit from the Reddit API. Callback takes one
|
||||||
|
argument, the data returned from the API.
|
||||||
|
|
||||||
|
#### getPostInfo(name, callback)
|
||||||
|
Get information about a post from the Reddit API. Callback takes one argument,
|
||||||
|
the data returned from the API about the post.
|
||||||
|
|
||||||
|
#### getCommentInfo(post, name, callback)
|
||||||
|
Get information about a particular comment in a particular post. Callback takes
|
||||||
|
one argument, information about the given comment.
|
||||||
|
|
||||||
|
### Hooks
|
||||||
|
|
||||||
|
#### link
|
||||||
|
Posts a summary when either a subreddit, a post or a comment is linked in a
|
||||||
|
channel.
|
36
modules/crypto/crypto.js
Normal file
36
modules/crypto/crypto.js
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
/**
|
||||||
|
* Module Name: Flashy
|
||||||
|
* Description: Makes pages with flashing text and that innit.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var MD5 = require('crypto-js/md5');
|
||||||
|
var SHA1 = require('crypto-js/sha1');
|
||||||
|
var SHA256 = require('crypto-js/sha256');
|
||||||
|
var SHA512 = require('crypto-js/sha512');
|
||||||
|
var AES = require('crypto-js/aes');
|
||||||
|
|
||||||
|
var crypto = function(dbot) {
|
||||||
|
this.commands = {
|
||||||
|
'~md5': function(event) {
|
||||||
|
event.reply("MD5 hash of "+event.input[1]+" is: "+MD5(event.input[1]));
|
||||||
|
},
|
||||||
|
'~sha1': function(event) {
|
||||||
|
event.reply("SHA1 hash of "+event.input[1]+" is: "+SHA1(event.input[1]));
|
||||||
|
},
|
||||||
|
'~sha256': function(event) {
|
||||||
|
event.reply("SHA256 hash of "+event.input[1]+" is: "+SHA256(event.input[1]));
|
||||||
|
},
|
||||||
|
'~aes': function(event) {
|
||||||
|
event.reply("AES of "+event.input[1]+" is: "+AES.encrypt(event.input[1],event.input[2]));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
this.commands['~md5'].regex = /^~md5 ([^ ]+)$/;
|
||||||
|
this.commands['~sha1'].regex = /^~sha1 ([^ ]+)$/;
|
||||||
|
this.commands['~sha256'].regex = /^~sha256 ([^ ]+)$/;
|
||||||
|
this.commands['~aes'].regex = /^~aes "(.*)" "(.*)"$/;
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.fetch = function(dbot) {
|
||||||
|
return new crypto(dbot);
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user