id stringlengths 34 124 | type stringclasses 4
values | prompt stringlengths 0 4.95k | response stringlengths 21 4.89k | source_lang stringclasses 3
values | target_lang stringclasses 2
values | repo stringclasses 75
values | path stringlengths 10 88 | license stringclasses 1
value | commit stringlengths 40 40 | stars int64 431 18.7k | source_url stringlengths 86 176 | line_start int64 1 214 | line_end int64 3 253 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ExpediaGroup/cyclotron:cyclotron-site/app/scripts/common/services/services.userService.coffee:2:raw_corpus | raw_corpus | # Load cached username
$localForage.getItem('username').then (username) ->
if username?
exports.cachedUsername = username
# Load cached userId (not UID)
$localForage.getItem('cachedUserId').then (userId) ->
if userId?
exports.cachedUserId = userId
exports.login ... | CoffeeScript | ExpediaGroup/cyclotron | cyclotron-site/app/scripts/common/services/services.userService.coffee | MIT | d57e1ea8a1e73bb1b98d5b0d7b80dc356b595ce1 | 1,544 | https://github.com/ExpediaGroup/cyclotron/blob/d57e1ea8a1e73bb1b98d5b0d7b80dc356b595ce1/cyclotron-site/app/scripts/common/services/services.userService.coffee | 44 | 84 | ||
ExpediaGroup/cyclotron:cyclotron-site/app/scripts/common/services/services.userService.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
# Load cached username
$localForage.getItem('username').then (username) ->
if username?
exports.cachedUsername = username
# Load cached userId (not UID)
$localForage.getItem('cachedUserId').then (userId) ->
if userId?
... | // Load cached username
$localForage.getItem('username').then(function(username) {
if (username != null) {
return exports.cachedUsername = username;
}
});
// Load cached userId (not UID)
$localForage.getItem('cachedUserId').then(function(userId) {
if (userId != null) {
return exports.cachedUserId = userI... | CoffeeScript | JavaScript | ExpediaGroup/cyclotron | cyclotron-site/app/scripts/common/services/services.userService.coffee | MIT | d57e1ea8a1e73bb1b98d5b0d7b80dc356b595ce1 | 1,544 | https://github.com/ExpediaGroup/cyclotron/blob/d57e1ea8a1e73bb1b98d5b0d7b80dc356b595ce1/cyclotron-site/app/scripts/common/services/services.userService.coffee | 44 | 84 |
ExpediaGroup/cyclotron:cyclotron-site/app/scripts/common/services/services.userService.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
// Load cached username
$localForage.getItem('username').then(function(username) {
if (username != null) {
return exports.cachedUsername = username;
}
});
// Load cached userId (not UID)
$localForage.getItem('cachedUserId').then(function(userId) {
if (us... | # Load cached username
$localForage.getItem('username').then (username) ->
if username?
exports.cachedUsername = username
# Load cached userId (not UID)
$localForage.getItem('cachedUserId').then (userId) ->
if userId?
exports.cachedUserId = userId
exports.login ... | JavaScript | CoffeeScript | ExpediaGroup/cyclotron | cyclotron-site/app/scripts/common/services/services.userService.coffee | MIT | d57e1ea8a1e73bb1b98d5b0d7b80dc356b595ce1 | 1,544 | https://github.com/ExpediaGroup/cyclotron/blob/d57e1ea8a1e73bb1b98d5b0d7b80dc356b595ce1/cyclotron-site/app/scripts/common/services/services.userService.coffee | 44 | 84 |
ExpediaGroup/cyclotron:cyclotron-site/app/scripts/common/services/services.userService.coffee:2:completion | completion | # Load cached username
$localForage.getItem('username').then (username) ->
if username?
exports.cachedUsername = username
# Load cached userId (not UID)
$localForage.getItem('cachedUserId').then (userId) ->
if userId?
exports.cachedUserId = userId
exports.login ... | # Store session and username in localstorage
$localForage.setItem 'session', session
$localForage.setItem 'username', username
$localForage.setItem 'cachedUserId', session.user._id
exports.cachedUsername = username
exports.cachedUserId = session.user._id
... | CoffeeScript | CoffeeScript | ExpediaGroup/cyclotron | cyclotron-site/app/scripts/common/services/services.userService.coffee | MIT | d57e1ea8a1e73bb1b98d5b0d7b80dc356b595ce1 | 1,544 | https://github.com/ExpediaGroup/cyclotron/blob/d57e1ea8a1e73bb1b98d5b0d7b80dc356b595ce1/cyclotron-site/app/scripts/common/services/services.userService.coffee | 44 | 84 |
ExpediaGroup/cyclotron:cyclotron-site/app/scripts/common/services/services.userService.coffee:3:raw_corpus | raw_corpus | deferred = $q.defer()
errorHandler = ->
exports.setLoggedOut()
deferred.resolve(null)
if configService.authentication.enable == true
$localForage.getItem('session').then (existingSession) ->
if existingSession?
validator = $http.... | CoffeeScript | ExpediaGroup/cyclotron | cyclotron-site/app/scripts/common/services/services.userService.coffee | MIT | d57e1ea8a1e73bb1b98d5b0d7b80dc356b595ce1 | 1,544 | https://github.com/ExpediaGroup/cyclotron/blob/d57e1ea8a1e73bb1b98d5b0d7b80dc356b595ce1/cyclotron-site/app/scripts/common/services/services.userService.coffee | 86 | 126 | ||
ExpediaGroup/cyclotron:cyclotron-site/app/scripts/common/services/services.userService.coffee:3:completion | completion | deferred = $q.defer()
errorHandler = ->
exports.setLoggedOut()
deferred.resolve(null)
if configService.authentication.enable == true
$localForage.getItem('session').then (existingSession) ->
if existingSession?
validator = $http.... | alertify.log('Previous session expired', 2500) unless hideAlerts
errorHandler()
else
errorHandler()
, errorHandler
else
errorHandler()
return deferred.promise
exports.logout = ->
deferred = $q.defer()
... | CoffeeScript | CoffeeScript | ExpediaGroup/cyclotron | cyclotron-site/app/scripts/common/services/services.userService.coffee | MIT | d57e1ea8a1e73bb1b98d5b0d7b80dc356b595ce1 | 1,544 | https://github.com/ExpediaGroup/cyclotron/blob/d57e1ea8a1e73bb1b98d5b0d7b80dc356b595ce1/cyclotron-site/app/scripts/common/services/services.userService.coffee | 86 | 126 |
ExpediaGroup/cyclotron:cyclotron-site/app/scripts/common/services/services.userService.coffee:4:raw_corpus | raw_corpus | promise.error (error) ->
alertify.error('Error during logout', 2500)
deferred.reject()
return deferred.promise
exports.search = (query) ->
deferred = $q.defer()
promise = $http.get(configService.restServiceUrl + '/ldap/search', { params: { q: query } })
... | CoffeeScript | ExpediaGroup/cyclotron | cyclotron-site/app/scripts/common/services/services.userService.coffee | MIT | d57e1ea8a1e73bb1b98d5b0d7b80dc356b595ce1 | 1,544 | https://github.com/ExpediaGroup/cyclotron/blob/d57e1ea8a1e73bb1b98d5b0d7b80dc356b595ce1/cyclotron-site/app/scripts/common/services/services.userService.coffee | 128 | 168 | ||
ExpediaGroup/cyclotron:cyclotron-site/app/scripts/common/services/services.userService.coffee:4:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
promise.error (error) ->
alertify.error('Error during logout', 2500)
deferred.reject()
return deferred.promise
exports.search = (query) ->
deferred = $q.defer()
promise = $http.get(configService.rest... | promise.error(function(error) {
alertify.error('Error during logout', 2500);
return deferred.reject();
});
return deferred.promise;
exports.search = function(query) {
var deferred, promise;
deferred = $q.defer();
promise = $http.get(configService.restServiceUrl + '/ldap/search', {
params: {
q: que... | CoffeeScript | JavaScript | ExpediaGroup/cyclotron | cyclotron-site/app/scripts/common/services/services.userService.coffee | MIT | d57e1ea8a1e73bb1b98d5b0d7b80dc356b595ce1 | 1,544 | https://github.com/ExpediaGroup/cyclotron/blob/d57e1ea8a1e73bb1b98d5b0d7b80dc356b595ce1/cyclotron-site/app/scripts/common/services/services.userService.coffee | 128 | 168 |
ExpediaGroup/cyclotron:cyclotron-site/app/scripts/common/services/services.userService.coffee:4:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
promise.error(function(error) {
alertify.error('Error during logout', 2500);
return deferred.reject();
});
return deferred.promise;
exports.search = function(query) {
var deferred, promise;
deferred = $q.defer();
promise = $http.get(configService.restSe... | promise.error (error) ->
alertify.error('Error during logout', 2500)
deferred.reject()
return deferred.promise
exports.search = (query) ->
deferred = $q.defer()
promise = $http.get(configService.restServiceUrl + '/ldap/search', { params: { q: query } })
... | JavaScript | CoffeeScript | ExpediaGroup/cyclotron | cyclotron-site/app/scripts/common/services/services.userService.coffee | MIT | d57e1ea8a1e73bb1b98d5b0d7b80dc356b595ce1 | 1,544 | https://github.com/ExpediaGroup/cyclotron/blob/d57e1ea8a1e73bb1b98d5b0d7b80dc356b595ce1/cyclotron-site/app/scripts/common/services/services.userService.coffee | 128 | 168 |
ExpediaGroup/cyclotron:cyclotron-site/app/scripts/common/services/services.userService.coffee:4:completion | completion | promise.error (error) ->
alertify.error('Error during logout', 2500)
deferred.reject()
return deferred.promise
exports.search = (query) ->
deferred = $q.defer()
promise = $http.get(configService.restServiceUrl + '/ldap/search', { params: { q: query } })
... | return true unless configService.authentication.enable
# Non-authenticated users cannot edit
return false unless exports.isLoggedIn()
# User is Admin
return true if exports.isAdmin()
# No edit permissions defined
return true if _.isEmpty(dashboard?.editors)
# ... | CoffeeScript | CoffeeScript | ExpediaGroup/cyclotron | cyclotron-site/app/scripts/common/services/services.userService.coffee | MIT | d57e1ea8a1e73bb1b98d5b0d7b80dc356b595ce1 | 1,544 | https://github.com/ExpediaGroup/cyclotron/blob/d57e1ea8a1e73bb1b98d5b0d7b80dc356b595ce1/cyclotron-site/app/scripts/common/services/services.userService.coffee | 128 | 168 |
ExpediaGroup/cyclotron:cyclotron-site/app/scripts/common/services/services.userService.coffee:5:raw_corpus | raw_corpus | # User is Admin
return true if exports.isAdmin()
# No view permissions defined
return true if _.isEmpty(dashboard?.viewers)
# If user can edit, they can view
return true if exports.hasEditPermission(dashboard)
# User is in the viwers list, or they are a member of a gro... | CoffeeScript | ExpediaGroup/cyclotron | cyclotron-site/app/scripts/common/services/services.userService.coffee | MIT | d57e1ea8a1e73bb1b98d5b0d7b80dc356b595ce1 | 1,544 | https://github.com/ExpediaGroup/cyclotron/blob/d57e1ea8a1e73bb1b98d5b0d7b80dc356b595ce1/cyclotron-site/app/scripts/common/services/services.userService.coffee | 170 | 192 | ||
ExpediaGroup/cyclotron:cyclotron-site/app/scripts/common/services/services.userService.coffee:5:completion | completion | # User is Admin
return true if exports.isAdmin()
# No view permissions defined
return true if _.isEmpty(dashboard?.viewers)
# If user can edit, they can view
return true if exports.hasEditPermission(dashboard)
# User is in the viwers list, or they are a member of a gro... | return (currentSession.user.distinguishedName == viewer.dn) ||
_.contains(currentSession.user.memberOf, viewer.dn)
exports.likesDashboard = (dashboard) ->
return false unless configService.authentication.enable
# Must be logged in to like a dashboard
return false unless exp... | CoffeeScript | CoffeeScript | ExpediaGroup/cyclotron | cyclotron-site/app/scripts/common/services/services.userService.coffee | MIT | d57e1ea8a1e73bb1b98d5b0d7b80dc356b595ce1 | 1,544 | https://github.com/ExpediaGroup/cyclotron/blob/d57e1ea8a1e73bb1b98d5b0d7b80dc356b595ce1/cyclotron-site/app/scripts/common/services/services.userService.coffee | 170 | 192 |
ExpediaGroup/cyclotron:cyclotron-site/app/scripts/common/services/services.userService.coffee:5:raw_corpus | raw_corpus | # User is Admin
return true if exports.isAdmin()
# No view permissions defined
return true if _.isEmpty(dashboard?.viewers)
# If user can edit, they can view
return true if exports.hasEditPermission(dashboard)
# User is in the viwers list, or they are a member of a gro... | CoffeeScript | ExpediaGroup/cyclotron | cyclotron-site/app/scripts/common/services/services.userService.coffee | MIT | 14b0e411415be801f94fe13ea6f63d5ad957c2ed | 1,544 | https://github.com/ExpediaGroup/cyclotron/blob/14b0e411415be801f94fe13ea6f63d5ad957c2ed/cyclotron-site/app/scripts/common/services/services.userService.coffee | 170 | 184 | ||
ExpediaGroup/cyclotron:cyclotron-site/app/scripts/common/services/services.userService.coffee:5:completion | completion | # User is Admin
return true if exports.isAdmin()
# No view permissions defined
return true if _.isEmpty(dashboard?.viewers)
# If user can edit, they can view | return true if exports.hasEditPermission(dashboard)
# User is in the viwers list, or they are a member of a group that is
return _.any dashboard.viewers, (viewer) ->
return (currentSession.user.distinguishedName == viewer.dn) ||
_.contains(currentSession.user.memberOf, viewe... | CoffeeScript | CoffeeScript | ExpediaGroup/cyclotron | cyclotron-site/app/scripts/common/services/services.userService.coffee | MIT | 14b0e411415be801f94fe13ea6f63d5ad957c2ed | 1,544 | https://github.com/ExpediaGroup/cyclotron/blob/14b0e411415be801f94fe13ea6f63d5ad957c2ed/cyclotron-site/app/scripts/common/services/services.userService.coffee | 170 | 184 |
lmaccherone/node-localstorage:test/localstorage-test.coffee:1:raw_corpus | raw_corpus | repeat = (string, count) ->
a = []
while count--
a.push(string)
return a.join('')
tape('localStorage API', (test) =>
localStorage = new LocalStorage('./scratch')
test.equal(localStorage._location, path.resolve('./scratch'))
localStorage.setItem('/', 'something')
test.equal(localStorage.getItem('/')... | CoffeeScript | lmaccherone/node-localstorage | test/localstorage-test.coffee | MIT | 23eff752dc603ad9559c50739589d3ec673c07f7 | 460 | https://github.com/lmaccherone/node-localstorage/blob/23eff752dc603ad9559c50739589d3ec673c07f7/test/localstorage-test.coffee | 5 | 54 | ||
lmaccherone/node-localstorage:test/localstorage-test.coffee:1:completion | completion | repeat = (string, count) ->
a = []
while count--
a.push(string)
return a.join('')
tape('localStorage API', (test) =>
localStorage = new LocalStorage('./scratch')
test.equal(localStorage._location, path.resolve('./scratch'))
localStorage.setItem('/', 'something')
test.equal(localStorage.getItem('/')... | localStorage.removeItem('2')
test.equal(localStorage.getItem('2'), null)
test.deepEqual(localStorage._keys, ['/'])
test.equal(localStorage.length, 1)
test.equal(localStorage.key(0), '/')
localStorage.clear()
test.equal(localStorage.length, 0)
localStorage._deleteLocation()
test.end()
)
tape('quota',... | CoffeeScript | CoffeeScript | lmaccherone/node-localstorage | test/localstorage-test.coffee | MIT | 23eff752dc603ad9559c50739589d3ec673c07f7 | 460 | https://github.com/lmaccherone/node-localstorage/blob/23eff752dc603ad9559c50739589d3ec673c07f7/test/localstorage-test.coffee | 5 | 54 |
lmaccherone/node-localstorage:test/localstorage-test.coffee:2:raw_corpus | raw_corpus | f = () ->
ls.setItem(6, n10)
test.throws(f, Error)
ls.setItem(2, n1000) # Should not throw because it replaces one of equal size
ls.removeItem(3)
ls.setItem(7, n100)
f2 = () ->
ls.setitem(8, n1000)
test.throws(f2, Error)
ls._deleteLocation()
test.end()
)
# tape('no new keyword', (test) =>
#... | CoffeeScript | lmaccherone/node-localstorage | test/localstorage-test.coffee | MIT | 23eff752dc603ad9559c50739589d3ec673c07f7 | 460 | https://github.com/lmaccherone/node-localstorage/blob/23eff752dc603ad9559c50739589d3ec673c07f7/test/localstorage-test.coffee | 55 | 104 | ||
lmaccherone/node-localstorage:test/localstorage-test.coffee:2:completion | completion | f = () ->
ls.setItem(6, n10)
test.throws(f, Error)
ls.setItem(2, n1000) # Should not throw because it replaces one of equal size
ls.removeItem(3)
ls.setItem(7, n100)
f2 = () ->
ls.setitem(8, n1000)
test.throws(f2, Error)
ls._deleteLocation()
test.end()
)
# tape('no new keyword', (test) =>
#... | local = new LocalStorage('./scratch4')
test.equals(local.getItem('junk'), null)
local._deleteLocation()
test.end()
)
tape('remove keys', (test) =>
localStorage = new LocalStorage('./scratch6');
localStorage.setItem('a', 'hello')
localStorage.setItem('b', 'hello')
localStorage.setItem('c', 'hello')
loc... | CoffeeScript | CoffeeScript | lmaccherone/node-localstorage | test/localstorage-test.coffee | MIT | 23eff752dc603ad9559c50739589d3ec673c07f7 | 460 | https://github.com/lmaccherone/node-localstorage/blob/23eff752dc603ad9559c50739589d3ec673c07f7/test/localstorage-test.coffee | 55 | 104 |
lmaccherone/node-localstorage:test/localstorage-test.coffee:3:raw_corpus | raw_corpus | localStorage._deleteLocation()
test.end()
)
tape('events', (test) =>
localStorage = new LocalStorage('./scratch5')
expectedUrl = "pid:" + process.pid
key = null; oldVal = null; newVal = null; url = null
handleEvent = (evnt) ->
key = evnt.key
oldVal = evnt.oldValue
newVal = evnt.newValue
url ... | CoffeeScript | lmaccherone/node-localstorage | test/localstorage-test.coffee | MIT | 23eff752dc603ad9559c50739589d3ec673c07f7 | 460 | https://github.com/lmaccherone/node-localstorage/blob/23eff752dc603ad9559c50739589d3ec673c07f7/test/localstorage-test.coffee | 105 | 154 | ||
lmaccherone/node-localstorage:test/localstorage-test.coffee:3:completion | completion | localStorage._deleteLocation()
test.end()
)
tape('events', (test) =>
localStorage = new LocalStorage('./scratch5')
expectedUrl = "pid:" + process.pid
key = null; oldVal = null; newVal = null; url = null
handleEvent = (evnt) ->
key = evnt.key
oldVal = evnt.oldValue
newVal = evnt.newValue
url ... | key = null; oldVal = null; newVal = null; url = null
localStorage.setItem('a', 'somethingnew')
test.equal(localStorage.getItem('a'), 'somethingnew')
test.equal(key, 'a')
test.equal(oldVal, 'something')
test.equal(newVal, 'somethingnew')
test.equal(url, expectedUrl)
key = null; oldVal = null; newVal = nul... | CoffeeScript | CoffeeScript | lmaccherone/node-localstorage | test/localstorage-test.coffee | MIT | 23eff752dc603ad9559c50739589d3ec673c07f7 | 460 | https://github.com/lmaccherone/node-localstorage/blob/23eff752dc603ad9559c50739589d3ec673c07f7/test/localstorage-test.coffee | 105 | 154 |
lmaccherone/node-localstorage:test/localstorage-test.coffee:4:raw_corpus | raw_corpus | test.end()
)
tape('get stat', (test) =>
localStorage = new LocalStorage('./scratch7')
o = {a:1, b:'some string', c:{x: 1, y: 2}}
localStorage.setItem('stat', o)
test.deepEqual(localStorage.getItem('stat'), o.toString())
test.ok(localStorage._getStat('stat')?)
test.equal(localStorage._getStat('not there')... | CoffeeScript | lmaccherone/node-localstorage | test/localstorage-test.coffee | MIT | 23eff752dc603ad9559c50739589d3ec673c07f7 | 460 | https://github.com/lmaccherone/node-localstorage/blob/23eff752dc603ad9559c50739589d3ec673c07f7/test/localstorage-test.coffee | 155 | 182 | ||
lmaccherone/node-localstorage:test/localstorage-test.coffee:4:completion | completion | test.end()
)
tape('get stat', (test) =>
localStorage = new LocalStorage('./scratch7')
o = {a:1, b:'some string', c:{x: 1, y: 2}}
localStorage.setItem('stat', o)
test.deepEqual(localStorage.getItem('stat'), o.toString())
test.ok(localStorage._getStat('stat')?)
test.equal(localStorage._getStat('not there')... | test.end()
)
tape('empty string', (test) =>
localStorage = new LocalStorage('./scratch8')
localStorage.setItem('', 'something')
test.equal(localStorage.getItem(''), 'something')
test.equal(localStorage.key(0), '')
localStorage._deleteLocation()
test.end()
) | CoffeeScript | CoffeeScript | lmaccherone/node-localstorage | test/localstorage-test.coffee | MIT | 23eff752dc603ad9559c50739589d3ec673c07f7 | 460 | https://github.com/lmaccherone/node-localstorage/blob/23eff752dc603ad9559c50739589d3ec673c07f7/test/localstorage-test.coffee | 155 | 182 |
lmaccherone/node-localstorage:test/localstorage-test.coffee:2:raw_corpus | raw_corpus | f = () ->
ls.setItem(6, n10)
test.throws(f, Error)
ls.setItem(2, n1000) # Should not throw because it replaces one of equal size
ls.removeItem(3)
ls.setItem(7, n100)
f2 = () ->
ls.setitem(8, n1000)
test.throws(f2, Error)
ls._deleteLocation()
test.end()
)
# tape('no new keyword', (test) =>
#... | CoffeeScript | lmaccherone/node-localstorage | test/localstorage-test.coffee | MIT | 520ddcfa4503e1fcf3ae08b2a08b560d7cdbf1b3 | 460 | https://github.com/lmaccherone/node-localstorage/blob/520ddcfa4503e1fcf3ae08b2a08b560d7cdbf1b3/test/localstorage-test.coffee | 55 | 104 | ||
lmaccherone/node-localstorage:test/localstorage-test.coffee:2:completion | completion | f = () ->
ls.setItem(6, n10)
test.throws(f, Error)
ls.setItem(2, n1000) # Should not throw because it replaces one of equal size
ls.removeItem(3)
ls.setItem(7, n100)
f2 = () ->
ls.setitem(8, n1000)
test.throws(f2, Error)
ls._deleteLocation()
test.end()
)
# tape('no new keyword', (test) =>
#... | tape('null', (test) =>
local = new LocalStorage('./scratch4')
test.equals(local.getItem('junk'), null)
local._deleteLocation()
test.end()
)
tape('remove keys', (test) =>
localStorage = new LocalStorage('./scratch6');
localStorage.setItem('a', 'hello')
localStorage.setItem('b', 'hello')
localStorage.se... | CoffeeScript | CoffeeScript | lmaccherone/node-localstorage | test/localstorage-test.coffee | MIT | 520ddcfa4503e1fcf3ae08b2a08b560d7cdbf1b3 | 460 | https://github.com/lmaccherone/node-localstorage/blob/520ddcfa4503e1fcf3ae08b2a08b560d7cdbf1b3/test/localstorage-test.coffee | 55 | 104 |
lmaccherone/node-localstorage:test/localstorage-test.coffee:3:raw_corpus | raw_corpus | localStorage._deleteLocation()
test.end()
)
tape('events', (test) =>
localStorage = new LocalStorage('./scratch5')
expectedUrl = "pid:" + process.pid
key = null; oldVal = null; newVal = null; url = null
handleEvent = (evnt) ->
key = evnt.key
oldVal = evnt.oldValue
newVal = evnt.newValue
url ... | CoffeeScript | lmaccherone/node-localstorage | test/localstorage-test.coffee | MIT | 520ddcfa4503e1fcf3ae08b2a08b560d7cdbf1b3 | 460 | https://github.com/lmaccherone/node-localstorage/blob/520ddcfa4503e1fcf3ae08b2a08b560d7cdbf1b3/test/localstorage-test.coffee | 105 | 154 | ||
lmaccherone/node-localstorage:test/localstorage-test.coffee:3:completion | completion | localStorage._deleteLocation()
test.end()
)
tape('events', (test) =>
localStorage = new LocalStorage('./scratch5')
expectedUrl = "pid:" + process.pid
key = null; oldVal = null; newVal = null; url = null
handleEvent = (evnt) ->
key = evnt.key
oldVal = evnt.oldValue
newVal = evnt.newValue
url ... | localStorage.setItem('a', 'somethingnew')
test.equal(localStorage.getItem('a'), 'somethingnew')
test.equal(key, 'a')
test.equal(oldVal, 'something')
test.equal(newVal, 'somethingnew')
test.equal(url, expectedUrl)
key = null; oldVal = null; newVal = null; url = null
localStorage.removeItem('a')
test.equ... | CoffeeScript | CoffeeScript | lmaccherone/node-localstorage | test/localstorage-test.coffee | MIT | 520ddcfa4503e1fcf3ae08b2a08b560d7cdbf1b3 | 460 | https://github.com/lmaccherone/node-localstorage/blob/520ddcfa4503e1fcf3ae08b2a08b560d7cdbf1b3/test/localstorage-test.coffee | 105 | 154 |
lmaccherone/node-localstorage:test/localstorage-test.coffee:4:raw_corpus | raw_corpus | )
tape('get stat', (test) =>
localStorage = new LocalStorage('./scratch7')
o = {a:1, b:'some string', c:{x: 1, y: 2}}
localStorage.setItem('stat', o)
test.deepEqual(localStorage.getItem('stat'), o.toString())
test.ok(localStorage._getStat('stat')?)
test.equal(localStorage._getStat('not there'), null)
... | CoffeeScript | lmaccherone/node-localstorage | test/localstorage-test.coffee | MIT | 520ddcfa4503e1fcf3ae08b2a08b560d7cdbf1b3 | 460 | https://github.com/lmaccherone/node-localstorage/blob/520ddcfa4503e1fcf3ae08b2a08b560d7cdbf1b3/test/localstorage-test.coffee | 155 | 181 | ||
lmaccherone/node-localstorage:test/localstorage-test.coffee:4:completion | completion | )
tape('get stat', (test) =>
localStorage = new LocalStorage('./scratch7')
o = {a:1, b:'some string', c:{x: 1, y: 2}}
localStorage.setItem('stat', o)
test.deepEqual(localStorage.getItem('stat'), o.toString())
test.ok(localStorage._getStat('stat')?)
test.equal(localStorage._getStat('not there'), null)
... | test.end()
)
tape('empty string', (test) =>
localStorage = new LocalStorage('./scratch8')
localStorage.setItem('', 'something')
test.equal(localStorage.getItem(''), 'something')
test.equal(localStorage.key(0), '')
localStorage._deleteLocation()
test.end()
) | CoffeeScript | CoffeeScript | lmaccherone/node-localstorage | test/localstorage-test.coffee | MIT | 520ddcfa4503e1fcf3ae08b2a08b560d7cdbf1b3 | 460 | https://github.com/lmaccherone/node-localstorage/blob/520ddcfa4503e1fcf3ae08b2a08b560d7cdbf1b3/test/localstorage-test.coffee | 155 | 181 |
lmaccherone/node-localstorage:test/localstorage-test.coffee:2:raw_corpus | raw_corpus | f = () ->
ls.setItem(6, n10)
test.throws(f, Error)
ls.setItem(2, n1000) # Should not throw because it replaces one of equal size
ls.removeItem(3)
ls.setItem(7, n100)
f2 = () ->
ls.setitem(8, n1000)
test.throws(f2, Error)
ls._deleteLocation()
test.end()
)
tape('no new keyword', (test) =>
l... | CoffeeScript | lmaccherone/node-localstorage | test/localstorage-test.coffee | MIT | b81b2c1807a4ee25d6415e92e4775e240b810615 | 460 | https://github.com/lmaccherone/node-localstorage/blob/b81b2c1807a4ee25d6415e92e4775e240b810615/test/localstorage-test.coffee | 55 | 104 | ||
lmaccherone/node-localstorage:test/localstorage-test.coffee:2:completion | completion | f = () ->
ls.setItem(6, n10)
test.throws(f, Error)
ls.setItem(2, n1000) # Should not throw because it replaces one of equal size
ls.removeItem(3)
ls.setItem(7, n100)
f2 = () ->
ls.setitem(8, n1000)
test.throws(f2, Error)
ls._deleteLocation()
test.end()
)
tape('no new keyword', (test) =>
l... | tape('null', (test) =>
local = LocalStorage('./scratch4')
test.equals(local.getItem('junk'), null)
local._deleteLocation()
test.end()
)
tape('remove keys', (test) =>
localStorage = new LocalStorage('./scratch6');
localStorage.setItem('a', 'hello')
localStorage.setItem('b', 'hello')
localStorage.setIte... | CoffeeScript | CoffeeScript | lmaccherone/node-localstorage | test/localstorage-test.coffee | MIT | b81b2c1807a4ee25d6415e92e4775e240b810615 | 460 | https://github.com/lmaccherone/node-localstorage/blob/b81b2c1807a4ee25d6415e92e4775e240b810615/test/localstorage-test.coffee | 55 | 104 |
lmaccherone/node-localstorage:test/localstorage-test.coffee:4:raw_corpus | raw_corpus | )
tape('get stat', (test) =>
localStorage = new LocalStorage('./scratch7')
o = {a:1, b:'some string', c:{x: 1, y: 2}}
localStorage.setItem('stat', o)
test.deepEqual(localStorage.getItem('stat'), o.toString())
test.ok(localStorage._getStat('stat')?)
test.equal(localStorage._getStat('not there'), null)
... | CoffeeScript | lmaccherone/node-localstorage | test/localstorage-test.coffee | MIT | 5c4b3306014091cd9071f63f4a845b6ebf84fffc | 460 | https://github.com/lmaccherone/node-localstorage/blob/5c4b3306014091cd9071f63f4a845b6ebf84fffc/test/localstorage-test.coffee | 155 | 179 | ||
lmaccherone/node-localstorage:test/localstorage-test.coffee:4:completion | completion | )
tape('get stat', (test) =>
localStorage = new LocalStorage('./scratch7')
o = {a:1, b:'some string', c:{x: 1, y: 2}}
localStorage.setItem('stat', o)
test.deepEqual(localStorage.getItem('stat'), o.toString())
test.ok(localStorage._getStat('stat')?)
test.equal(localStorage._getStat('not there'), null) | localStorage._deleteLocation()
test.end()
)
tape('empty string', (test) =>
localStorage = new LocalStorage('./scratch8')
localStorage.setItem('', 'something')
test.equal(localStorage.getItem(''), 'something')
localStorage._deleteLocation()
test.end()
) | CoffeeScript | CoffeeScript | lmaccherone/node-localstorage | test/localstorage-test.coffee | MIT | 5c4b3306014091cd9071f63f4a845b6ebf84fffc | 460 | https://github.com/lmaccherone/node-localstorage/blob/5c4b3306014091cd9071f63f4a845b6ebf84fffc/test/localstorage-test.coffee | 155 | 179 |
nicolaskruchten/pivottable:locales/pivot.ru.coffee:1:raw_corpus | raw_corpus | callWithJQuery = (pivotModule) ->
if typeof exports is "object" and typeof module is "object" # CommonJS
pivotModule require("jquery")
else if typeof define is "function" and define.amd # AMD
define ["jquery"], pivotModule
# Plain browser env
else
pivotModule jQuery
callWithJQue... | CoffeeScript | nicolaskruchten/pivottable | locales/pivot.ru.coffee | MIT | 838ec2fc38747749c28d2fd1cb6c4ace9e9cc520 | 4,440 | https://github.com/nicolaskruchten/pivottable/blob/838ec2fc38747749c28d2fd1cb6c4ace9e9cc520/locales/pivot.ru.coffee | 1 | 50 | ||
nicolaskruchten/pivottable:locales/pivot.ru.coffee:1:completion | completion | callWithJQuery = (pivotModule) ->
if typeof exports is "object" and typeof module is "object" # CommonJS
pivotModule require("jquery")
else if typeof define is "function" and define.amd # AMD
define ["jquery"], pivotModule
# Plain browser env
else
pivotModule jQuery
callWithJQue... | filterResults: "Возможные значения",
totals: "Всего",
vs: "на",
by: "с"
aggregators:
"Кол-во": tpl.count(frFmtInt),
"Кол-во уникальных": tpl.countUnique(frFmtInt),
"Список уникальных": tpl.listUnique(", "),
"Сумма": tpl.sum(frF... | CoffeeScript | CoffeeScript | nicolaskruchten/pivottable | locales/pivot.ru.coffee | MIT | 838ec2fc38747749c28d2fd1cb6c4ace9e9cc520 | 4,440 | https://github.com/nicolaskruchten/pivottable/blob/838ec2fc38747749c28d2fd1cb6c4ace9e9cc520/locales/pivot.ru.coffee | 1 | 50 |
CaryLandholt/AngularFun:src/scripts/app.coffee:1:raw_corpus | raw_corpus | do (angular) ->
'use strict'
angular.module 'app', ['ngResource', 'ngRoute'] | CoffeeScript | CaryLandholt/AngularFun | src/scripts/app.coffee | MIT | 84cd4633279ad391623504698a20ed4b5560dc77 | 672 | https://github.com/CaryLandholt/AngularFun/blob/84cd4633279ad391623504698a20ed4b5560dc77/src/scripts/app.coffee | 1 | 4 | ||
CaryLandholt/AngularFun:src/scripts/app.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
do (angular) ->
'use strict'
angular.module 'app', ['ngResource', 'ngRoute']
``` | (function(angular) {
'use strict';
return angular.module('app', ['ngResource', 'ngRoute']);
})(angular); | CoffeeScript | JavaScript | CaryLandholt/AngularFun | src/scripts/app.coffee | MIT | 84cd4633279ad391623504698a20ed4b5560dc77 | 672 | https://github.com/CaryLandholt/AngularFun/blob/84cd4633279ad391623504698a20ed4b5560dc77/src/scripts/app.coffee | 1 | 4 |
CaryLandholt/AngularFun:src/scripts/app.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
(function(angular) {
'use strict';
return angular.module('app', ['ngResource', 'ngRoute']);
})(angular);
``` | do (angular) ->
'use strict'
angular.module 'app', ['ngResource', 'ngRoute'] | JavaScript | CoffeeScript | CaryLandholt/AngularFun | src/scripts/app.coffee | MIT | 84cd4633279ad391623504698a20ed4b5560dc77 | 672 | https://github.com/CaryLandholt/AngularFun/blob/84cd4633279ad391623504698a20ed4b5560dc77/src/scripts/app.coffee | 1 | 4 |
CaryLandholt/AngularFun:src/scripts/app.coffee:1:completion | completion | do (angular) ->
'use strict' | angular.module 'app', ['ngResource', 'ngRoute'] | CoffeeScript | CoffeeScript | CaryLandholt/AngularFun | src/scripts/app.coffee | MIT | 84cd4633279ad391623504698a20ed4b5560dc77 | 672 | https://github.com/CaryLandholt/AngularFun/blob/84cd4633279ad391623504698a20ed4b5560dc77/src/scripts/app.coffee | 1 | 4 |
jianliaoim/talk-os:talk-web/client/util/snippet.coffee:1:raw_corpus | raw_corpus | Immutable = require 'immutable'
exports.assets = Immutable.OrderedMap
'txt': Immutable.Map { name: 'Plain Text', codemirror: 'null', highlightjs: 'nohighlight' }
'clojure': Immutable.Map { name: 'Clojure', codemirror: 'clojure', highlightjs: 'clojure' }
'coffee': Immutable.Map { name: 'CoffeeScript', codemirror:... | CoffeeScript | jianliaoim/talk-os | talk-web/client/util/snippet.coffee | MIT | 2545c4497865779a55762e03963a39237df9046b | 2,703 | https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/util/snippet.coffee | 1 | 40 | ||
jianliaoim/talk-os:talk-web/client/util/snippet.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
Immutable = require 'immutable'
exports.assets = Immutable.OrderedMap
'txt': Immutable.Map { name: 'Plain Text', codemirror: 'null', highlightjs: 'nohighlight' }
'clojure': Immutable.Map { name: 'Clojure', codemirror: 'clojure', highlightjs: 'clojure' }
'c... | var Immutable;
Immutable = require('immutable');
exports.assets = Immutable.OrderedMap({
'txt': Immutable.Map({
name: 'Plain Text',
codemirror: 'null',
highlightjs: 'nohighlight'
}),
'clojure': Immutable.Map({
name: 'Clojure',
codemirror: 'clojure',
highlightjs: 'clojure'
}),
'coffee... | CoffeeScript | JavaScript | jianliaoim/talk-os | talk-web/client/util/snippet.coffee | MIT | 2545c4497865779a55762e03963a39237df9046b | 2,703 | https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/util/snippet.coffee | 1 | 40 |
jianliaoim/talk-os:talk-web/client/util/snippet.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var Immutable;
Immutable = require('immutable');
exports.assets = Immutable.OrderedMap({
'txt': Immutable.Map({
name: 'Plain Text',
codemirror: 'null',
highlightjs: 'nohighlight'
}),
'clojure': Immutable.Map({
name: 'Clojure',
codemirror... | Immutable = require 'immutable'
exports.assets = Immutable.OrderedMap
'txt': Immutable.Map { name: 'Plain Text', codemirror: 'null', highlightjs: 'nohighlight' }
'clojure': Immutable.Map { name: 'Clojure', codemirror: 'clojure', highlightjs: 'clojure' }
'coffee': Immutable.Map { name: 'CoffeeScript', codemirror:... | JavaScript | CoffeeScript | jianliaoim/talk-os | talk-web/client/util/snippet.coffee | MIT | 2545c4497865779a55762e03963a39237df9046b | 2,703 | https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/util/snippet.coffee | 1 | 40 |
jianliaoim/talk-os:talk-web/client/util/snippet.coffee:1:completion | completion | Immutable = require 'immutable'
exports.assets = Immutable.OrderedMap
'txt': Immutable.Map { name: 'Plain Text', codemirror: 'null', highlightjs: 'nohighlight' }
'clojure': Immutable.Map { name: 'Clojure', codemirror: 'clojure', highlightjs: 'clojure' }
'coffee': Immutable.Map { name: 'CoffeeScript', codemirror:... | 'rb': Immutable.Map { name: 'Ruby', codemirror: 'ruby', highlightjs: 'ruby' }
'sql': Immutable.Map { name: 'SQL', codemirror: 'sql', highlightjs: 'sql' }
exports.getAssets = ->
exports.assets
exports.getAssetsByKey = (key) ->
exports.assets.get(key) or exports.assets.get('txt')
exports.getCodemirror = (key) ->... | CoffeeScript | CoffeeScript | jianliaoim/talk-os | talk-web/client/util/snippet.coffee | MIT | 2545c4497865779a55762e03963a39237df9046b | 2,703 | https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/util/snippet.coffee | 1 | 40 |
alekseykulikov/backbone-offline:spec/offline_records_spec.coffee:1:raw_corpus | raw_corpus | describe 'Offline.Records', ->
beforeEach ->
localStorage.setItem('ideas', '2,3')
@records = new Offline.Records('ideas')
it 'initializes @name', -> expect(@records.name).toEqual('ideas')
it 'initializes @values', -> expect(@records.values).toEqual(['2', '3'])
describe 'add', ->
beforeEach -> @rec... | CoffeeScript | alekseykulikov/backbone-offline | spec/offline_records_spec.coffee | MIT | f2e71813562f46f3678104f4200d20e97b2eb07e | 717 | https://github.com/alekseykulikov/backbone-offline/blob/f2e71813562f46f3678104f4200d20e97b2eb07e/spec/offline_records_spec.coffee | 1 | 21 | ||
alekseykulikov/backbone-offline:spec/offline_records_spec.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
describe 'Offline.Records', ->
beforeEach ->
localStorage.setItem('ideas', '2,3')
@records = new Offline.Records('ideas')
it 'initializes @name', -> expect(@records.name).toEqual('ideas')
it 'initializes @values', -> expect(@records.values).toEqual... | describe('Offline.Records', function() {
beforeEach(function() {
localStorage.setItem('ideas', '2,3');
return this.records = new Offline.Records('ideas');
});
it('initializes @name', function() {
return expect(this.records.name).toEqual('ideas');
});
it('initializes @values', function() {
retu... | CoffeeScript | JavaScript | alekseykulikov/backbone-offline | spec/offline_records_spec.coffee | MIT | f2e71813562f46f3678104f4200d20e97b2eb07e | 717 | https://github.com/alekseykulikov/backbone-offline/blob/f2e71813562f46f3678104f4200d20e97b2eb07e/spec/offline_records_spec.coffee | 1 | 21 |
alekseykulikov/backbone-offline:spec/offline_records_spec.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
describe('Offline.Records', function() {
beforeEach(function() {
localStorage.setItem('ideas', '2,3');
return this.records = new Offline.Records('ideas');
});
it('initializes @name', function() {
return expect(this.records.name).toEqual('ideas');
... | describe 'Offline.Records', ->
beforeEach ->
localStorage.setItem('ideas', '2,3')
@records = new Offline.Records('ideas')
it 'initializes @name', -> expect(@records.name).toEqual('ideas')
it 'initializes @values', -> expect(@records.values).toEqual(['2', '3'])
describe 'add', ->
beforeEach -> @rec... | JavaScript | CoffeeScript | alekseykulikov/backbone-offline | spec/offline_records_spec.coffee | MIT | f2e71813562f46f3678104f4200d20e97b2eb07e | 717 | https://github.com/alekseykulikov/backbone-offline/blob/f2e71813562f46f3678104f4200d20e97b2eb07e/spec/offline_records_spec.coffee | 1 | 21 |
alekseykulikov/backbone-offline:spec/offline_records_spec.coffee:1:completion | completion | describe 'Offline.Records', ->
beforeEach ->
localStorage.setItem('ideas', '2,3')
@records = new Offline.Records('ideas')
it 'initializes @name', -> expect(@records.name).toEqual('ideas')
it 'initializes @values', -> expect(@records.values).toEqual(['2', '3'])
describe 'add', ->
beforeEach -> @rec... | it 'pushes value to values', -> expect(@records.values).toEqual(['2', '3', '5'])
it 'updates localStorage item', -> expect(localStorage.getItem 'ideas').toEqual('2,3,5')
it 'does not include itemId to values twice', ->
@records.add('5')
expect(@records.values).toEqual(['2', '3', '5'])
describe '... | CoffeeScript | CoffeeScript | alekseykulikov/backbone-offline | spec/offline_records_spec.coffee | MIT | f2e71813562f46f3678104f4200d20e97b2eb07e | 717 | https://github.com/alekseykulikov/backbone-offline/blob/f2e71813562f46f3678104f4200d20e97b2eb07e/spec/offline_records_spec.coffee | 1 | 21 |
xhan/qqbot:src/qqbot.coffee:1:raw_corpus | raw_corpus | class QQBot
constructor: (@cookies, @auth, @config) ->
@buddy_info = {}
@group_info = {}
@groupmember_info = {}
api.cookies @cookies
@api = api
@dispatcher = new Dispatcher(@config.plugins)
# @format PROTOCOL `用户分组信息格式`
save_buddy_info: (@buddy_info)->
... | CoffeeScript | xhan/qqbot | src/qqbot.coffee | MIT | 7f3efc0a273c4884826c150c08457399ce225766 | 1,435 | https://github.com/xhan/qqbot/blob/7f3efc0a273c4884826c150c08457399ce225766/src/qqbot.coffee | 13 | 62 | ||
xhan/qqbot:src/qqbot.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class QQBot
constructor: (@cookies, @auth, @config) ->
@buddy_info = {}
@group_info = {}
@groupmember_info = {}
api.cookies @cookies
@api = api
@dispatcher = new Dispatcher(@config.plugins)
# @format PROTO... | var QQBot;
QQBot = class QQBot {
constructor(cookies, auth, config) {
this.cookies = cookies;
this.auth = auth;
this.config = config;
this.buddy_info = {};
this.group_info = {};
this.groupmember_info = {};
api.cookies(this.cookies);
this.api = api;
this.dispatcher = new Dispatcher... | CoffeeScript | JavaScript | xhan/qqbot | src/qqbot.coffee | MIT | 7f3efc0a273c4884826c150c08457399ce225766 | 1,435 | https://github.com/xhan/qqbot/blob/7f3efc0a273c4884826c150c08457399ce225766/src/qqbot.coffee | 13 | 62 |
xhan/qqbot:src/qqbot.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var QQBot;
QQBot = class QQBot {
constructor(cookies, auth, config) {
this.cookies = cookies;
this.auth = auth;
this.config = config;
this.buddy_info = {};
this.group_info = {};
this.groupmember_info = {};
api.cookies(this.cookies);
... | class QQBot
constructor: (@cookies, @auth, @config) ->
@buddy_info = {}
@group_info = {}
@groupmember_info = {}
api.cookies @cookies
@api = api
@dispatcher = new Dispatcher(@config.plugins)
# @format PROTOCOL `用户分组信息格式`
save_buddy_info: (@buddy_info)->
... | JavaScript | CoffeeScript | xhan/qqbot | src/qqbot.coffee | MIT | 7f3efc0a273c4884826c150c08457399ce225766 | 1,435 | https://github.com/xhan/qqbot/blob/7f3efc0a273c4884826c150c08457399ce225766/src/qqbot.coffee | 13 | 62 |
xhan/qqbot:src/qqbot.coffee:1:completion | completion | class QQBot
constructor: (@cookies, @auth, @config) ->
@buddy_info = {}
@group_info = {}
@groupmember_info = {}
api.cookies @cookies
@api = api
@dispatcher = new Dispatcher(@config.plugins)
# @format PROTOCOL `用户分组信息格式`
save_buddy_info: (@buddy_info)->
... | users.pop()
# 获取群用户信息
get_user_ingroup: (uin, gid)->
info = @groupmember_info[gid]
users = info.minfo.filter (item)-> item.uin == uin
users.pop()
# 获取群信息,只支持群 ,支持多关键词搜索
# @options {key:value}
# @return {gid,code,name,flag}
get_group: (options)->
groups = @group... | CoffeeScript | CoffeeScript | xhan/qqbot | src/qqbot.coffee | MIT | 7f3efc0a273c4884826c150c08457399ce225766 | 1,435 | https://github.com/xhan/qqbot/blob/7f3efc0a273c4884826c150c08457399ce225766/src/qqbot.coffee | 13 | 62 |
xhan/qqbot:src/qqbot.coffee:2:raw_corpus | raw_corpus | # 更新群成员, 似乎获取不到群ID
# @options {key:value}
# @callback (true/false , error)
update_group_member: (options, callback)->
group = @get_group(options)
api.get_group_member group.code , @auth , (ret,e)=>
if ret.retcode == 0
@save_group_member(group,ret.result)
... | CoffeeScript | xhan/qqbot | src/qqbot.coffee | MIT | 7f3efc0a273c4884826c150c08457399ce225766 | 1,435 | https://github.com/xhan/qqbot/blob/7f3efc0a273c4884826c150c08457399ce225766/src/qqbot.coffee | 63 | 112 | ||
xhan/qqbot:src/qqbot.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
# 更新群成员, 似乎获取不到群ID
# @options {key:value}
# @callback (true/false , error)
update_group_member: (options, callback)->
group = @get_group(options)
api.get_group_member group.code , @auth , (ret,e)=>
if ret.retcode == 0
... | // 更新群成员, 似乎获取不到群ID
// @options {key:value}
// @callback (true/false , error)
({
update_group_member: function(options, callback) {
var group;
group = this.get_group(options);
return api.get_group_member(group.code, this.auth, (ret, e) => {
if (ret.retcode === 0) {
this.save_group_member(gro... | CoffeeScript | JavaScript | xhan/qqbot | src/qqbot.coffee | MIT | 7f3efc0a273c4884826c150c08457399ce225766 | 1,435 | https://github.com/xhan/qqbot/blob/7f3efc0a273c4884826c150c08457399ce225766/src/qqbot.coffee | 63 | 112 |
xhan/qqbot:src/qqbot.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
// 更新群成员, 似乎获取不到群ID
// @options {key:value}
// @callback (true/false , error)
({
update_group_member: function(options, callback) {
var group;
group = this.get_group(options);
return api.get_group_member(group.code, this.auth, (ret, e) => {
if (... | # 更新群成员, 似乎获取不到群ID
# @options {key:value}
# @callback (true/false , error)
update_group_member: (options, callback)->
group = @get_group(options)
api.get_group_member group.code , @auth , (ret,e)=>
if ret.retcode == 0
@save_group_member(group,ret.result)
... | JavaScript | CoffeeScript | xhan/qqbot | src/qqbot.coffee | MIT | 7f3efc0a273c4884826c150c08457399ce225766 | 1,435 | https://github.com/xhan/qqbot/blob/7f3efc0a273c4884826c150c08457399ce225766/src/qqbot.coffee | 63 | 112 |
xhan/qqbot:src/qqbot.coffee:2:completion | completion | # 更新群成员, 似乎获取不到群ID
# @options {key:value}
# @callback (true/false , error)
update_group_member: (options, callback)->
group = @get_group(options)
api.get_group_member group.code , @auth , (ret,e)=>
if ret.retcode == 0
@save_group_member(group,ret.result)
... | if message.type == 'group'
api.send_msg_2group message.from_gid , content , @auth, (ret,e)->
callback(ret,e) if callback
else if message.type == 'buddy'
api.send_msg_2buddy message.from_uin , content , @auth , (ret,e)->
callback(ret,e) if callback
# ... | CoffeeScript | CoffeeScript | xhan/qqbot | src/qqbot.coffee | MIT | 7f3efc0a273c4884826c150c08457399ce225766 | 1,435 | https://github.com/xhan/qqbot/blob/7f3efc0a273c4884826c150c08457399ce225766/src/qqbot.coffee | 63 | 112 |
xhan/qqbot:src/qqbot.coffee:3:raw_corpus | raw_corpus | _on_message : (event)->
msg = @_create_message event
if msg.type == 'group'
log.debug "[群消息]","[#{msg.from_group.name}] #{msg.from_user.nick}:#{msg.content} #{msg.time}"
else if msg.type == 'buddy'
log.debug "[好友消息]","#{msg.from_user.nick}:#{msg.content} #{msg.time}"
... | CoffeeScript | xhan/qqbot | src/qqbot.coffee | MIT | 7f3efc0a273c4884826c150c08457399ce225766 | 1,435 | https://github.com/xhan/qqbot/blob/7f3efc0a273c4884826c150c08457399ce225766/src/qqbot.coffee | 113 | 162 | ||
xhan/qqbot:src/qqbot.coffee:3:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
_on_message : (event)->
msg = @_create_message event
if msg.type == 'group'
log.debug "[群消息]","[#{msg.from_group.name}] #{msg.from_user.nick}:#{msg.content} #{msg.time}"
else if msg.type == 'buddy'
log.debug "[好友消息]... | ({
_on_message: function(event) {
var content, msg, replied, reply;
msg = this._create_message(event);
if (msg.type === 'group') {
log.debug("[群消息]", `[${msg.from_group.name}] ${msg.from_user.nick}:${msg.content} ${msg.time}`);
} else if (msg.type === 'buddy') {
log.debug("[好友消息]", `${msg.... | CoffeeScript | JavaScript | xhan/qqbot | src/qqbot.coffee | MIT | 7f3efc0a273c4884826c150c08457399ce225766 | 1,435 | https://github.com/xhan/qqbot/blob/7f3efc0a273c4884826c150c08457399ce225766/src/qqbot.coffee | 113 | 162 |
xhan/qqbot:src/qqbot.coffee:3:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
({
_on_message: function(event) {
var content, msg, replied, reply;
msg = this._create_message(event);
if (msg.type === 'group') {
log.debug("[群消息]", `[${msg.from_group.name}] ${msg.from_user.nick}:${msg.content} ${msg.time}`);
} else if (ms... | _on_message : (event)->
msg = @_create_message event
if msg.type == 'group'
log.debug "[群消息]","[#{msg.from_group.name}] #{msg.from_user.nick}:#{msg.content} #{msg.time}"
else if msg.type == 'buddy'
log.debug "[好友消息]","#{msg.from_user.nick}:#{msg.content} #{msg.time}"
... | JavaScript | CoffeeScript | xhan/qqbot | src/qqbot.coffee | MIT | 7f3efc0a273c4884826c150c08457399ce225766 | 1,435 | https://github.com/xhan/qqbot/blob/7f3efc0a273c4884826c150c08457399ce225766/src/qqbot.coffee | 113 | 162 |
xhan/qqbot:src/qqbot.coffee:3:completion | completion | _on_message : (event)->
msg = @_create_message event
if msg.type == 'group'
log.debug "[群消息]","[#{msg.from_group.name}] #{msg.from_user.nick}:#{msg.content} #{msg.time}"
else if msg.type == 'buddy'
log.debug "[好友消息]","#{msg.from_user.nick}:#{msg.content} #{msg.time}"
... | from_uin: value.from_uin
type : if value.group_code then 'group' else 'buddy'
uid : value.msg_id
if msg.type == 'group'
msg.from_gid = msg.from_uin
msg.group_code = value.group_code
msg.from_uin = value.send_uin # 这才是用户,group消息中 from_uin 是gid
... | CoffeeScript | CoffeeScript | xhan/qqbot | src/qqbot.coffee | MIT | 7f3efc0a273c4884826c150c08457399ce225766 | 1,435 | https://github.com/xhan/qqbot/blob/7f3efc0a273c4884826c150c08457399ce225766/src/qqbot.coffee | 113 | 162 |
xhan/qqbot:src/qqbot.coffee:4:raw_corpus | raw_corpus | groupinfo = @get_group {name:name}
group = new Group(@, groupinfo.gid)
@dispatcher.add_listener [group,"dispatch"]
callback group
###
为hubot专门使用,提供两个方法
- send
- on_message (content,send_fun, bot , message_info) ->
### | CoffeeScript | xhan/qqbot | src/qqbot.coffee | MIT | 7f3efc0a273c4884826c150c08457399ce225766 | 1,435 | https://github.com/xhan/qqbot/blob/7f3efc0a273c4884826c150c08457399ce225766/src/qqbot.coffee | 163 | 173 | ||
xhan/qqbot:src/qqbot.coffee:4:completion | completion | groupinfo = @get_group {name:name}
group = new Group(@, groupinfo.gid)
@dispatcher.add_listener [group,"dispatch"]
callback group | ###
为hubot专门使用,提供两个方法
- send
- on_message (content,send_fun, bot , message_info) ->
### | CoffeeScript | CoffeeScript | xhan/qqbot | src/qqbot.coffee | MIT | 7f3efc0a273c4884826c150c08457399ce225766 | 1,435 | https://github.com/xhan/qqbot/blob/7f3efc0a273c4884826c150c08457399ce225766/src/qqbot.coffee | 163 | 173 |
xhan/qqbot:src/qqbot.coffee:5:raw_corpus | raw_corpus | class Group
constructor: (@bot,@gid)->
send: (content , callback)->
@bot.send_message_to_group @gid , content , (ret,e)->
callback(ret,e) if callback
on_message: (@msg_cb)->
dispatch: (params...)->
@msg_cb(params...) if @msg_cb | CoffeeScript | xhan/qqbot | src/qqbot.coffee | MIT | 7f3efc0a273c4884826c150c08457399ce225766 | 1,435 | https://github.com/xhan/qqbot/blob/7f3efc0a273c4884826c150c08457399ce225766/src/qqbot.coffee | 174 | 182 | ||
xhan/qqbot:src/qqbot.coffee:5:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class Group
constructor: (@bot,@gid)->
send: (content , callback)->
@bot.send_message_to_group @gid , content , (ret,e)->
callback(ret,e) if callback
on_message: (@msg_cb)->
dispatch: (params...)->
@msg_cb(params...) ... | var Group;
Group = class Group {
constructor(bot, gid) {
this.bot = bot;
this.gid = gid;
}
send(content, callback) {
return this.bot.send_message_to_group(this.gid, content, function(ret, e) {
if (callback) {
return callback(ret, e);
}
});
}
on_message(msg_cb) {
this... | CoffeeScript | JavaScript | xhan/qqbot | src/qqbot.coffee | MIT | 7f3efc0a273c4884826c150c08457399ce225766 | 1,435 | https://github.com/xhan/qqbot/blob/7f3efc0a273c4884826c150c08457399ce225766/src/qqbot.coffee | 174 | 182 |
xhan/qqbot:src/qqbot.coffee:5:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var Group;
Group = class Group {
constructor(bot, gid) {
this.bot = bot;
this.gid = gid;
}
send(content, callback) {
return this.bot.send_message_to_group(this.gid, content, function(ret, e) {
if (callback) {
return callback(ret, e... | class Group
constructor: (@bot,@gid)->
send: (content , callback)->
@bot.send_message_to_group @gid , content , (ret,e)->
callback(ret,e) if callback
on_message: (@msg_cb)->
dispatch: (params...)->
@msg_cb(params...) if @msg_cb | JavaScript | CoffeeScript | xhan/qqbot | src/qqbot.coffee | MIT | 7f3efc0a273c4884826c150c08457399ce225766 | 1,435 | https://github.com/xhan/qqbot/blob/7f3efc0a273c4884826c150c08457399ce225766/src/qqbot.coffee | 174 | 182 |
xhan/qqbot:src/qqbot.coffee:5:completion | completion | class Group
constructor: (@bot,@gid)->
send: (content , callback)->
@bot.send_message_to_group @gid , content , (ret,e)-> | callback(ret,e) if callback
on_message: (@msg_cb)->
dispatch: (params...)->
@msg_cb(params...) if @msg_cb | CoffeeScript | CoffeeScript | xhan/qqbot | src/qqbot.coffee | MIT | 7f3efc0a273c4884826c150c08457399ce225766 | 1,435 | https://github.com/xhan/qqbot/blob/7f3efc0a273c4884826c150c08457399ce225766/src/qqbot.coffee | 174 | 182 |
xhan/qqbot:src/qqbot.coffee:3:raw_corpus | raw_corpus | _on_message : (event)->
msg = @_create_message event
if msg.type == 'group'
log.debug "[群消息]","[#{msg.from_group.name}] #{msg.from_user.nick}:#{msg.content} #{msg.time}"
else if msg.type == 'buddy'
log.debug "[好友消息]","#{msg.from_user.nick}:#{msg.content} #{msg.time}"
... | CoffeeScript | xhan/qqbot | src/qqbot.coffee | MIT | 7a315b182835c1b93eff295543911976750cfb4e | 1,435 | https://github.com/xhan/qqbot/blob/7a315b182835c1b93eff295543911976750cfb4e/src/qqbot.coffee | 113 | 162 | ||
xhan/qqbot:src/qqbot.coffee:3:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
_on_message : (event)->
msg = @_create_message event
if msg.type == 'group'
log.debug "[群消息]","[#{msg.from_group.name}] #{msg.from_user.nick}:#{msg.content} #{msg.time}"
else if msg.type == 'buddy'
log.debug "[好友消息]... | ({
_on_message: function(event) {
var content, msg, replied, reply;
msg = this._create_message(event);
if (msg.type === 'group') {
log.debug("[群消息]", `[${msg.from_group.name}] ${msg.from_user.nick}:${msg.content} ${msg.time}`);
} else if (msg.type === 'buddy') {
log.debug("[好友消息]", `${msg.... | CoffeeScript | JavaScript | xhan/qqbot | src/qqbot.coffee | MIT | 7a315b182835c1b93eff295543911976750cfb4e | 1,435 | https://github.com/xhan/qqbot/blob/7a315b182835c1b93eff295543911976750cfb4e/src/qqbot.coffee | 113 | 162 |
xhan/qqbot:src/qqbot.coffee:3:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
({
_on_message: function(event) {
var content, msg, replied, reply;
msg = this._create_message(event);
if (msg.type === 'group') {
log.debug("[群消息]", `[${msg.from_group.name}] ${msg.from_user.nick}:${msg.content} ${msg.time}`);
} else if (ms... | _on_message : (event)->
msg = @_create_message event
if msg.type == 'group'
log.debug "[群消息]","[#{msg.from_group.name}] #{msg.from_user.nick}:#{msg.content} #{msg.time}"
else if msg.type == 'buddy'
log.debug "[好友消息]","#{msg.from_user.nick}:#{msg.content} #{msg.time}"
... | JavaScript | CoffeeScript | xhan/qqbot | src/qqbot.coffee | MIT | 7a315b182835c1b93eff295543911976750cfb4e | 1,435 | https://github.com/xhan/qqbot/blob/7a315b182835c1b93eff295543911976750cfb4e/src/qqbot.coffee | 113 | 162 |
xhan/qqbot:src/qqbot.coffee:3:completion | completion | _on_message : (event)->
msg = @_create_message event
if msg.type == 'group'
log.debug "[群消息]","[#{msg.from_group.name}] #{msg.from_user.nick}:#{msg.content} #{msg.time}"
else if msg.type == 'buddy'
log.debug "[好友消息]","#{msg.from_user.nick}:#{msg.content} #{msg.time}"
... | content : value.content.slice(-1).pop()
time : new Date(value.time * 1000)
from_uin: value.from_uin
type : if value.group_code then 'group' else 'buddy'
if msg.type == 'group'
msg.from_gid = msg.from_uin
msg.group_code = value.group_code
... | CoffeeScript | CoffeeScript | xhan/qqbot | src/qqbot.coffee | MIT | 7a315b182835c1b93eff295543911976750cfb4e | 1,435 | https://github.com/xhan/qqbot/blob/7a315b182835c1b93eff295543911976750cfb4e/src/qqbot.coffee | 113 | 162 |
xhan/qqbot:src/qqbot.coffee:1:raw_corpus | raw_corpus | class QQBot
constructor: (@cookies, @auth, @config) ->
@buddy_info = {}
@group_info = {}
@groupmember_info = {}
api.cookies @cookies
@api = api
@dispatcher = new Dispatcher(config.plugins)
# @format PROTOCOL `用户分组信息格式`
save_buddy_info: (@buddy_info)->
#... | CoffeeScript | xhan/qqbot | src/qqbot.coffee | MIT | ab343a11c18512a46bf2ca5b2f46bd8e1c710019 | 1,435 | https://github.com/xhan/qqbot/blob/ab343a11c18512a46bf2ca5b2f46bd8e1c710019/src/qqbot.coffee | 13 | 62 | ||
xhan/qqbot:src/qqbot.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class QQBot
constructor: (@cookies, @auth, @config) ->
@buddy_info = {}
@group_info = {}
@groupmember_info = {}
api.cookies @cookies
@api = api
@dispatcher = new Dispatcher(config.plugins)
# @format PROTOC... | var QQBot;
QQBot = class QQBot {
constructor(cookies, auth, config1) {
this.cookies = cookies;
this.auth = auth;
this.config = config1;
this.buddy_info = {};
this.group_info = {};
this.groupmember_info = {};
api.cookies(this.cookies);
this.api = api;
this.dispatcher = new Dispatch... | CoffeeScript | JavaScript | xhan/qqbot | src/qqbot.coffee | MIT | ab343a11c18512a46bf2ca5b2f46bd8e1c710019 | 1,435 | https://github.com/xhan/qqbot/blob/ab343a11c18512a46bf2ca5b2f46bd8e1c710019/src/qqbot.coffee | 13 | 62 |
xhan/qqbot:src/qqbot.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var QQBot;
QQBot = class QQBot {
constructor(cookies, auth, config1) {
this.cookies = cookies;
this.auth = auth;
this.config = config1;
this.buddy_info = {};
this.group_info = {};
this.groupmember_info = {};
api.cookies(this.cookies);... | class QQBot
constructor: (@cookies, @auth, @config) ->
@buddy_info = {}
@group_info = {}
@groupmember_info = {}
api.cookies @cookies
@api = api
@dispatcher = new Dispatcher(config.plugins)
# @format PROTOCOL `用户分组信息格式`
save_buddy_info: (@buddy_info)->
#... | JavaScript | CoffeeScript | xhan/qqbot | src/qqbot.coffee | MIT | ab343a11c18512a46bf2ca5b2f46bd8e1c710019 | 1,435 | https://github.com/xhan/qqbot/blob/ab343a11c18512a46bf2ca5b2f46bd8e1c710019/src/qqbot.coffee | 13 | 62 |
xhan/qqbot:src/qqbot.coffee:1:completion | completion | class QQBot
constructor: (@cookies, @auth, @config) ->
@buddy_info = {}
@group_info = {}
@groupmember_info = {}
api.cookies @cookies
@api = api
@dispatcher = new Dispatcher(config.plugins)
# @format PROTOCOL `用户分组信息格式`
save_buddy_info: (@buddy_info)->
#... | users.pop()
# 获取群用户信息
get_user_ingroup: (uin, gid)->
info = @groupmember_info[gid]
users = info.minfo.filter (item)-> item.uin == uin
users.pop()
# 获取群信息,只支持群 ,支持多关键词搜索
# @options {key:value}
# @return {gid,code,name,flag}
get_group: (options)->
groups = @group... | CoffeeScript | CoffeeScript | xhan/qqbot | src/qqbot.coffee | MIT | ab343a11c18512a46bf2ca5b2f46bd8e1c710019 | 1,435 | https://github.com/xhan/qqbot/blob/ab343a11c18512a46bf2ca5b2f46bd8e1c710019/src/qqbot.coffee | 13 | 62 |
xhan/qqbot:src/qqbot.coffee:4:raw_corpus | raw_corpus | groupinfo = @get_group {name:name}
group = new Group(@, groupinfo.gid)
@dispatcher.add_listener group.dispatch
callback group
###
为hubot专门使用,提供两个方法
- send
- on_message (content,send_fun, bot , message_info) ->
### | CoffeeScript | xhan/qqbot | src/qqbot.coffee | MIT | ab343a11c18512a46bf2ca5b2f46bd8e1c710019 | 1,435 | https://github.com/xhan/qqbot/blob/ab343a11c18512a46bf2ca5b2f46bd8e1c710019/src/qqbot.coffee | 163 | 174 | ||
xhan/qqbot:src/qqbot.coffee:4:completion | completion | groupinfo = @get_group {name:name}
group = new Group(@, groupinfo.gid)
@dispatcher.add_listener group.dispatch
callback group | ###
为hubot专门使用,提供两个方法
- send
- on_message (content,send_fun, bot , message_info) ->
### | CoffeeScript | CoffeeScript | xhan/qqbot | src/qqbot.coffee | MIT | ab343a11c18512a46bf2ca5b2f46bd8e1c710019 | 1,435 | https://github.com/xhan/qqbot/blob/ab343a11c18512a46bf2ca5b2f46bd8e1c710019/src/qqbot.coffee | 163 | 174 |
xhan/qqbot:src/qqbot.coffee:3:raw_corpus | raw_corpus | _on_message : (event)->
msg = @_create_message event
if msg.type == 'group'
log.debug "[群消息]","[#{msg.from_group.name}] #{msg.from_user.nick}:#{msg.content} #{msg.time}"
else if msg.type == 'buddy'
log.debug "[好友消息]","#{msg.from_user.nick}:#{msg.content} #{msg.time}"
... | CoffeeScript | xhan/qqbot | src/qqbot.coffee | MIT | 6705e4aadb1922e58515ad09dfadedcd05f3746f | 1,435 | https://github.com/xhan/qqbot/blob/6705e4aadb1922e58515ad09dfadedcd05f3746f/src/qqbot.coffee | 115 | 164 | ||
xhan/qqbot:src/qqbot.coffee:3:completion | completion | _on_message : (event)->
msg = @_create_message event
if msg.type == 'group'
log.debug "[群消息]","[#{msg.from_group.name}] #{msg.from_user.nick}:#{msg.content} #{msg.time}"
else if msg.type == 'buddy'
log.debug "[好友消息]","#{msg.from_user.nick}:#{msg.content} #{msg.time}"
... | content : value.content.slice(-1).pop()
time : new Date(value.time * 1000)
from_uin: value.from_uin
type : if value.group_code then 'group' else 'buddy'
if msg.type == 'group'
msg.from_gid = msg.from_uin
msg.group_code = value.group_code
... | CoffeeScript | CoffeeScript | xhan/qqbot | src/qqbot.coffee | MIT | 6705e4aadb1922e58515ad09dfadedcd05f3746f | 1,435 | https://github.com/xhan/qqbot/blob/6705e4aadb1922e58515ad09dfadedcd05f3746f/src/qqbot.coffee | 115 | 164 |
xhan/qqbot:src/qqbot.coffee:4:raw_corpus | raw_corpus | groupinfo = @get_group {name:name}
group = new Group(@,groupinfo.gid)
@dispatcher.add_listener group.dispatch
callback(group)
###
为hubot专门使用,提供两个方法
- send
- on_message (content,send_fun, bot , message_info) ->
### | CoffeeScript | xhan/qqbot | src/qqbot.coffee | MIT | 6705e4aadb1922e58515ad09dfadedcd05f3746f | 1,435 | https://github.com/xhan/qqbot/blob/6705e4aadb1922e58515ad09dfadedcd05f3746f/src/qqbot.coffee | 165 | 176 | ||
xhan/qqbot:src/qqbot.coffee:4:completion | completion | groupinfo = @get_group {name:name}
group = new Group(@,groupinfo.gid)
@dispatcher.add_listener group.dispatch
callback(group) | ###
为hubot专门使用,提供两个方法
- send
- on_message (content,send_fun, bot , message_info) ->
### | CoffeeScript | CoffeeScript | xhan/qqbot | src/qqbot.coffee | MIT | 6705e4aadb1922e58515ad09dfadedcd05f3746f | 1,435 | https://github.com/xhan/qqbot/blob/6705e4aadb1922e58515ad09dfadedcd05f3746f/src/qqbot.coffee | 165 | 176 |
xhan/qqbot:src/qqbot.coffee:5:raw_corpus | raw_corpus | class Group
constructor: (@bot,@gid)->
send: (content ,callback)->
@bot.send_message_to_group @gid , content , (ret,e)->
callback(ret,e) if callback
on_message: (@msg_cb)->
dispatch: (params...)->
@msg_cb(params...) if @msg_cb | CoffeeScript | xhan/qqbot | src/qqbot.coffee | MIT | 6705e4aadb1922e58515ad09dfadedcd05f3746f | 1,435 | https://github.com/xhan/qqbot/blob/6705e4aadb1922e58515ad09dfadedcd05f3746f/src/qqbot.coffee | 177 | 185 | ||
xhan/qqbot:src/qqbot.coffee:5:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class Group
constructor: (@bot,@gid)->
send: (content ,callback)->
@bot.send_message_to_group @gid , content , (ret,e)->
callback(ret,e) if callback
on_message: (@msg_cb)->
dispatch: (params...)->
@msg_cb(params...) if @msg_cb
``` | var Group;
Group = class Group {
constructor(bot, gid) {
this.bot = bot;
this.gid = gid;
}
send(content, callback) {
return this.bot.send_message_to_group(this.gid, content, function(ret, e) {
if (callback) {
return callback(ret, e);
}
});
}
on_message(msg_cb) {
this... | CoffeeScript | JavaScript | xhan/qqbot | src/qqbot.coffee | MIT | 6705e4aadb1922e58515ad09dfadedcd05f3746f | 1,435 | https://github.com/xhan/qqbot/blob/6705e4aadb1922e58515ad09dfadedcd05f3746f/src/qqbot.coffee | 177 | 185 |
xhan/qqbot:src/qqbot.coffee:5:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var Group;
Group = class Group {
constructor(bot, gid) {
this.bot = bot;
this.gid = gid;
}
send(content, callback) {
return this.bot.send_message_to_group(this.gid, content, function(ret, e) {
if (callback) {
return callback(ret, e... | class Group
constructor: (@bot,@gid)->
send: (content ,callback)->
@bot.send_message_to_group @gid , content , (ret,e)->
callback(ret,e) if callback
on_message: (@msg_cb)->
dispatch: (params...)->
@msg_cb(params...) if @msg_cb | JavaScript | CoffeeScript | xhan/qqbot | src/qqbot.coffee | MIT | 6705e4aadb1922e58515ad09dfadedcd05f3746f | 1,435 | https://github.com/xhan/qqbot/blob/6705e4aadb1922e58515ad09dfadedcd05f3746f/src/qqbot.coffee | 177 | 185 |
xhan/qqbot:src/qqbot.coffee:5:completion | completion | class Group
constructor: (@bot,@gid)->
send: (content ,callback)->
@bot.send_message_to_group @gid , content , (ret,e)-> | callback(ret,e) if callback
on_message: (@msg_cb)->
dispatch: (params...)->
@msg_cb(params...) if @msg_cb | CoffeeScript | CoffeeScript | xhan/qqbot | src/qqbot.coffee | MIT | 6705e4aadb1922e58515ad09dfadedcd05f3746f | 1,435 | https://github.com/xhan/qqbot/blob/6705e4aadb1922e58515ad09dfadedcd05f3746f/src/qqbot.coffee | 177 | 185 |
xhan/qqbot:src/qqbot.coffee:1:raw_corpus | raw_corpus | class QQBot
constructor: (@name ,@auth) ->
@buddy_info = {}
@group_info = {}
@groupmember_info = {}
@plugin_control = plugin
# @format PROTOCOL `用户分组信息格式`
save_buddy_info: (@buddy_info)->
# @format PROTOCOL `群分组信息格式`
save_group_info: (@group_info) ->
# @format... | CoffeeScript | xhan/qqbot | src/qqbot.coffee | MIT | 42842fe6d7fbeafd53e9bacde8cb5a079cdddb0c | 1,435 | https://github.com/xhan/qqbot/blob/42842fe6d7fbeafd53e9bacde8cb5a079cdddb0c/src/qqbot.coffee | 13 | 62 | ||
xhan/qqbot:src/qqbot.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class QQBot
constructor: (@name ,@auth) ->
@buddy_info = {}
@group_info = {}
@groupmember_info = {}
@plugin_control = plugin
# @format PROTOCOL `用户分组信息格式`
save_buddy_info: (@buddy_info)->
# @format PROTOCOL `群分组信... | var QQBot;
QQBot = class QQBot {
constructor(name, auth) {
this.name = name;
this.auth = auth;
this.buddy_info = {};
this.group_info = {};
this.groupmember_info = {};
this.plugin_control = plugin;
}
// @format PROTOCOL `用户分组信息格式`
save_buddy_info(buddy_info) {
this.buddy_info = budd... | CoffeeScript | JavaScript | xhan/qqbot | src/qqbot.coffee | MIT | 42842fe6d7fbeafd53e9bacde8cb5a079cdddb0c | 1,435 | https://github.com/xhan/qqbot/blob/42842fe6d7fbeafd53e9bacde8cb5a079cdddb0c/src/qqbot.coffee | 13 | 62 |
xhan/qqbot:src/qqbot.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var QQBot;
QQBot = class QQBot {
constructor(name, auth) {
this.name = name;
this.auth = auth;
this.buddy_info = {};
this.group_info = {};
this.groupmember_info = {};
this.plugin_control = plugin;
}
// @format PROTOCOL `用户分组信息格式`
s... | class QQBot
constructor: (@name ,@auth) ->
@buddy_info = {}
@group_info = {}
@groupmember_info = {}
@plugin_control = plugin
# @format PROTOCOL `用户分组信息格式`
save_buddy_info: (@buddy_info)->
# @format PROTOCOL `群分组信息格式`
save_group_info: (@group_info) ->
# @format... | JavaScript | CoffeeScript | xhan/qqbot | src/qqbot.coffee | MIT | 42842fe6d7fbeafd53e9bacde8cb5a079cdddb0c | 1,435 | https://github.com/xhan/qqbot/blob/42842fe6d7fbeafd53e9bacde8cb5a079cdddb0c/src/qqbot.coffee | 13 | 62 |
xhan/qqbot:src/qqbot.coffee:1:completion | completion | class QQBot
constructor: (@name ,@auth) ->
@buddy_info = {}
@group_info = {}
@groupmember_info = {}
@plugin_control = plugin
# @format PROTOCOL `用户分组信息格式`
save_buddy_info: (@buddy_info)->
# @format PROTOCOL `群分组信息格式`
save_group_info: (@group_info) ->
# @format... | # 获取群用户信息
get_user_ingroup: (uin, gid)->
info = @groupmember_info[gid]
users = info.minfo.filter (item)-> item.uin == uin
users.pop()
# 获取群信息,只支持群 ,支持多关键词搜索
# @options {key:value}
# @return {gid,code,name,flag}
get_group: (options)->
groups = @group_info.gnamelist.f... | CoffeeScript | CoffeeScript | xhan/qqbot | src/qqbot.coffee | MIT | 42842fe6d7fbeafd53e9bacde8cb5a079cdddb0c | 1,435 | https://github.com/xhan/qqbot/blob/42842fe6d7fbeafd53e9bacde8cb5a079cdddb0c/src/qqbot.coffee | 13 | 62 |
xhan/qqbot:src/qqbot.coffee:2:raw_corpus | raw_corpus | # 回复消息
# @param message 收到的message
# @param content:string 回复信息
# @callback ret, error
reply_message: (message, content, callback)->
log "发送消息:",content
if message.type == 'group'
api.send_msg_2group message.from_gid , content , @auth, (ret,e)->
callback(ret,... | CoffeeScript | xhan/qqbot | src/qqbot.coffee | MIT | 42842fe6d7fbeafd53e9bacde8cb5a079cdddb0c | 1,435 | https://github.com/xhan/qqbot/blob/42842fe6d7fbeafd53e9bacde8cb5a079cdddb0c/src/qqbot.coffee | 63 | 112 | ||
xhan/qqbot:src/qqbot.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
# 回复消息
# @param message 收到的message
# @param content:string 回复信息
# @callback ret, error
reply_message: (message, content, callback)->
log "发送消息:",content
if message.type == 'group'
api.send_msg_2group message.from_gid ,... | // 回复消息
// @param message 收到的message
// @param content:string 回复信息
// @callback ret, error
({
reply_message: function(message, content, callback) {
log("发送消息:", content);
if (message.type === 'group') {
return api.send_msg_2group(message.from_gid, content, this.auth, function(ret, e) {
if (callb... | CoffeeScript | JavaScript | xhan/qqbot | src/qqbot.coffee | MIT | 42842fe6d7fbeafd53e9bacde8cb5a079cdddb0c | 1,435 | https://github.com/xhan/qqbot/blob/42842fe6d7fbeafd53e9bacde8cb5a079cdddb0c/src/qqbot.coffee | 63 | 112 |
xhan/qqbot:src/qqbot.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
// 回复消息
// @param message 收到的message
// @param content:string 回复信息
// @callback ret, error
({
reply_message: function(message, content, callback) {
log("发送消息:", content);
if (message.type === 'group') {
return api.send_msg_2group(message.from_gid, c... | # 回复消息
# @param message 收到的message
# @param content:string 回复信息
# @callback ret, error
reply_message: (message, content, callback)->
log "发送消息:",content
if message.type == 'group'
api.send_msg_2group message.from_gid , content , @auth, (ret,e)->
callback(ret,... | JavaScript | CoffeeScript | xhan/qqbot | src/qqbot.coffee | MIT | 42842fe6d7fbeafd53e9bacde8cb5a079cdddb0c | 1,435 | https://github.com/xhan/qqbot/blob/42842fe6d7fbeafd53e9bacde8cb5a079cdddb0c/src/qqbot.coffee | 63 | 112 |
xhan/qqbot:src/qqbot.coffee:2:completion | completion | # 回复消息
# @param message 收到的message
# @param content:string 回复信息
# @callback ret, error
reply_message: (message, content, callback)->
log "发送消息:",content
if message.type == 'group'
api.send_msg_2group message.from_gid , content , @auth, (ret,e)->
callback(ret,... | else log "unimplemented event",event.poll_type
_on_message : (event)->
msg = @_create_message event
if msg.type == 'group'
log "[群消息]","[#{msg.from_group.name}] #{msg.from_user.nick}:#{msg.content} #{msg.time}"
else if msg.type == 'buddy'
log "[好友消息]","#{msg.from_use... | CoffeeScript | CoffeeScript | xhan/qqbot | src/qqbot.coffee | MIT | 42842fe6d7fbeafd53e9bacde8cb5a079cdddb0c | 1,435 | https://github.com/xhan/qqbot/blob/42842fe6d7fbeafd53e9bacde8cb5a079cdddb0c/src/qqbot.coffee | 63 | 112 |
xhan/qqbot:src/qqbot.coffee:3:raw_corpus | raw_corpus | msg =
content : value.content.slice(-1).pop()
time : new Date(value.time * 1000)
from_uin: value.from_uin
type : if value.group_code then 'group' else 'buddy'
if msg.type == 'group'
msg.from_gid = msg.from_uin
msg.group_code = value.... | CoffeeScript | xhan/qqbot | src/qqbot.coffee | MIT | 42842fe6d7fbeafd53e9bacde8cb5a079cdddb0c | 1,435 | https://github.com/xhan/qqbot/blob/42842fe6d7fbeafd53e9bacde8cb5a079cdddb0c/src/qqbot.coffee | 113 | 133 | ||
xhan/qqbot:src/qqbot.coffee:3:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
msg =
content : value.content.slice(-1).pop()
time : new Date(value.time * 1000)
from_uin: value.from_uin
type : if value.group_code then 'group' else 'buddy'
if msg.type == 'group'
msg.fr... | var msg;
msg = {
content: value.content.slice(-1).pop(),
time: new Date(value.time * 1000),
from_uin: value.from_uin,
type: value.group_code ? 'group' : 'buddy'
};
if (msg.type === 'group') {
msg.from_gid = msg.from_uin;
msg.group_code = value.group_code;
msg.from_uin = value.send_uin; // 这才是用户,group消息中... | CoffeeScript | JavaScript | xhan/qqbot | src/qqbot.coffee | MIT | 42842fe6d7fbeafd53e9bacde8cb5a079cdddb0c | 1,435 | https://github.com/xhan/qqbot/blob/42842fe6d7fbeafd53e9bacde8cb5a079cdddb0c/src/qqbot.coffee | 113 | 133 |
xhan/qqbot:src/qqbot.coffee:3:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var msg;
msg = {
content: value.content.slice(-1).pop(),
time: new Date(value.time * 1000),
from_uin: value.from_uin,
type: value.group_code ? 'group' : 'buddy'
};
if (msg.type === 'group') {
msg.from_gid = msg.from_uin;
msg.group_code = value.group_c... | msg =
content : value.content.slice(-1).pop()
time : new Date(value.time * 1000)
from_uin: value.from_uin
type : if value.group_code then 'group' else 'buddy'
if msg.type == 'group'
msg.from_gid = msg.from_uin
msg.group_code = value.... | JavaScript | CoffeeScript | xhan/qqbot | src/qqbot.coffee | MIT | 42842fe6d7fbeafd53e9bacde8cb5a079cdddb0c | 1,435 | https://github.com/xhan/qqbot/blob/42842fe6d7fbeafd53e9bacde8cb5a079cdddb0c/src/qqbot.coffee | 113 | 133 |
xhan/qqbot:src/qqbot.coffee:3:completion | completion | msg =
content : value.content.slice(-1).pop()
time : new Date(value.time * 1000)
from_uin: value.from_uin
type : if value.group_code then 'group' else 'buddy'
if msg.type == 'group'
msg.from_gid = msg.from_uin
msg.group_code = value.... | msg.from_group = @get_group( {gid:msg.from_gid} )
msg.from_user = @get_user_ingroup( msg.from_uin ,msg.from_gid )
else if msg.type == 'buddy'
msg.from_user = @get_user( msg.from_uin )
msg
# class Message
# constructor: (@struct)->
# @content = @struct.content.slice... | CoffeeScript | CoffeeScript | xhan/qqbot | src/qqbot.coffee | MIT | 42842fe6d7fbeafd53e9bacde8cb5a079cdddb0c | 1,435 | https://github.com/xhan/qqbot/blob/42842fe6d7fbeafd53e9bacde8cb5a079cdddb0c/src/qqbot.coffee | 113 | 133 |
xhan/qqbot:src/qqbot.coffee:2:raw_corpus | raw_corpus | # 回复消息
# @param message 收到的message
# @param content:string 回复信息
# @callback ret, error
reply_message: (message, content, callback)->
log "发送消息:",content
if message.type == 'group'
api.send_msg_2group message.from_gid , content , @auth, (ret,e)->
callback(ret,... | CoffeeScript | xhan/qqbot | src/qqbot.coffee | MIT | fde7320d5c718d68659af61bd82274baac0550a7 | 1,435 | https://github.com/xhan/qqbot/blob/fde7320d5c718d68659af61bd82274baac0550a7/src/qqbot.coffee | 63 | 112 | ||
xhan/qqbot:src/qqbot.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
# 回复消息
# @param message 收到的message
# @param content:string 回复信息
# @callback ret, error
reply_message: (message, content, callback)->
log "发送消息:",content
if message.type == 'group'
api.send_msg_2group message.from_gid ,... | // 回复消息
// @param message 收到的message
// @param content:string 回复信息
// @callback ret, error
({
reply_message: function(message, content, callback) {
log("发送消息:", content);
if (message.type === 'group') {
return api.send_msg_2group(message.from_gid, content, this.auth, function(ret, e) {
if (callb... | CoffeeScript | JavaScript | xhan/qqbot | src/qqbot.coffee | MIT | fde7320d5c718d68659af61bd82274baac0550a7 | 1,435 | https://github.com/xhan/qqbot/blob/fde7320d5c718d68659af61bd82274baac0550a7/src/qqbot.coffee | 63 | 112 |
xhan/qqbot:src/qqbot.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
// 回复消息
// @param message 收到的message
// @param content:string 回复信息
// @callback ret, error
({
reply_message: function(message, content, callback) {
log("发送消息:", content);
if (message.type === 'group') {
return api.send_msg_2group(message.from_gid, c... | # 回复消息
# @param message 收到的message
# @param content:string 回复信息
# @callback ret, error
reply_message: (message, content, callback)->
log "发送消息:",content
if message.type == 'group'
api.send_msg_2group message.from_gid , content , @auth, (ret,e)->
callback(ret,... | JavaScript | CoffeeScript | xhan/qqbot | src/qqbot.coffee | MIT | fde7320d5c718d68659af61bd82274baac0550a7 | 1,435 | https://github.com/xhan/qqbot/blob/fde7320d5c718d68659af61bd82274baac0550a7/src/qqbot.coffee | 63 | 112 |
xhan/qqbot:src/qqbot.coffee:2:completion | completion | # 回复消息
# @param message 收到的message
# @param content:string 回复信息
# @callback ret, error
reply_message: (message, content, callback)->
log "发送消息:",content
if message.type == 'group'
api.send_msg_2group message.from_gid , content , @auth, (ret,e)->
callback(ret,... | when 'message' then @_on_message(event)
else log "unimplemented event",event.poll_type
_on_message : (event)->
msg = @_create_message event
if msg.type == 'group'
log "[群消息]","[#{msg.from_group.name}] #{msg.from_user.nick}:#{msg.content} #{msg.time}"
else if msg.... | CoffeeScript | CoffeeScript | xhan/qqbot | src/qqbot.coffee | MIT | fde7320d5c718d68659af61bd82274baac0550a7 | 1,435 | https://github.com/xhan/qqbot/blob/fde7320d5c718d68659af61bd82274baac0550a7/src/qqbot.coffee | 63 | 112 |
xhan/qqbot:src/qqbot.coffee:3:raw_corpus | raw_corpus | value = event.value
msg =
content : value.content.slice(-1).pop()
time : new Date(value.time * 1000)
from_uin: value.from_uin
type : if value.group_code then 'group' else 'buddy'
if msg.type == 'group'
msg.from_gid = msg.from_uin
... | CoffeeScript | xhan/qqbot | src/qqbot.coffee | MIT | fde7320d5c718d68659af61bd82274baac0550a7 | 1,435 | https://github.com/xhan/qqbot/blob/fde7320d5c718d68659af61bd82274baac0550a7/src/qqbot.coffee | 113 | 134 | ||
xhan/qqbot:src/qqbot.coffee:3:completion | completion | value = event.value
msg =
content : value.content.slice(-1).pop()
time : new Date(value.time * 1000)
from_uin: value.from_uin
type : if value.group_code then 'group' else 'buddy'
if msg.type == 'group'
msg.from_gid = msg.from_uin
... | msg.from_group = @get_group( {gid:msg.from_gid} )
msg.from_user = @get_user_ingroup( msg.from_uin ,msg.from_gid )
else if msg.type == 'buddy'
msg.from_user = @get_user( msg.from_uin )
msg
# class Message
# constructor: (@struct)->
# @content = @struct.content.slice... | CoffeeScript | CoffeeScript | xhan/qqbot | src/qqbot.coffee | MIT | fde7320d5c718d68659af61bd82274baac0550a7 | 1,435 | https://github.com/xhan/qqbot/blob/fde7320d5c718d68659af61bd82274baac0550a7/src/qqbot.coffee | 113 | 134 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.