-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathstorage_factory.js
More file actions
33 lines (26 loc) · 944 Bytes
/
storage_factory.js
File metadata and controls
33 lines (26 loc) · 944 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
function StorageFactory(connection, module, sender){
this.connection = connection;
this.sender = sender;
this.module = module;
this.USER_TYPE = 'user_data';
this.MODULE_TYPE = 'module_data';
this.GLOBAL_TYPE = 'global_data';
this.Storage = require("./storage").Storage;
}
StorageFactory.prototype.getUserStorage = function(user){
console.log("getting storage for " + user);
// We want to be kind of nice here, so we strip out the <@...> piece if this is a mention
m = user.match(/<@([UW][A-Z0-9]+)/)
if (m){
user = m[1];
console.log('match: ' + user);
}
return new this.Storage(this.connection, this.USER_TYPE, user);
};
StorageFactory.prototype.getModuleStorage = function(){
return new this.Storage(this.connection, this.MODULE_TYPE, this.module);
};
StorageFactory.prototype.getGlobalStorage = function(id){
return new this.Storage(this.connection, this.GLOBAL_TYPE, id);
};
exports.StorageFactory = StorageFactory;