How to use karma method in stryker-parent

Best JavaScript code snippet using stryker-parent

karma_vx.x.x.js

Source:karma_vx.x.x.js Github

copy

Full Screen

1// flow-typed signature: f958bb00ddab099fb2762fed1eeb20642// flow-typed version: <<STUB>>/karma_v^3.0.0/flow_v0.82.03/**4 * This is an autogenerated libdef stub for:5 *6 * 'karma'7 *8 * Fill this stub out by replacing all the `any` types.9 *10 * Once filled out, we encourage you to share your work with the11 * community by sending a pull request to:12 * https://github.com/flowtype/flow-typed13 */14declare module 'karma' {15 declare module.exports: any;16}17/**18 * We include stubs for each file inside this npm package in case you need to19 * require those files directly. Feel free to delete any files that aren't20 * needed.21 */22declare module 'karma/common/stringify' {23 declare module.exports: any;24}25declare module 'karma/common/util' {26 declare module.exports: any;27}28declare module 'karma/config.tpl' {29 declare module.exports: any;30}31declare module 'karma/context/karma' {32 declare module.exports: any;33}34declare module 'karma/context/main' {35 declare module.exports: any;36}37declare module 'karma/gruntfile' {38 declare module.exports: any;39}40declare module 'karma/lib/browser_collection' {41 declare module.exports: any;42}43declare module 'karma/lib/browser_result' {44 declare module.exports: any;45}46declare module 'karma/lib/browser' {47 declare module.exports: any;48}49declare module 'karma/lib/cli' {50 declare module.exports: any;51}52declare module 'karma/lib/completion' {53 declare module.exports: any;54}55declare module 'karma/lib/config' {56 declare module.exports: any;57}58declare module 'karma/lib/constants' {59 declare module.exports: any;60}61declare module 'karma/lib/detached' {62 declare module.exports: any;63}64declare module 'karma/lib/emitter_wrapper' {65 declare module.exports: any;66}67declare module 'karma/lib/events' {68 declare module.exports: any;69}70declare module 'karma/lib/executor' {71 declare module.exports: any;72}73declare module 'karma/lib/file-list' {74 declare module.exports: any;75}76declare module 'karma/lib/file' {77 declare module.exports: any;78}79declare module 'karma/lib/helper' {80 declare module.exports: any;81}82declare module 'karma/lib/index' {83 declare module.exports: any;84}85declare module 'karma/lib/init' {86 declare module.exports: any;87}88declare module 'karma/lib/init/color_schemes' {89 declare module.exports: any;90}91declare module 'karma/lib/init/formatters' {92 declare module.exports: any;93}94declare module 'karma/lib/init/log-queue' {95 declare module.exports: any;96}97declare module 'karma/lib/init/state_machine' {98 declare module.exports: any;99}100declare module 'karma/lib/launcher' {101 declare module.exports: any;102}103declare module 'karma/lib/launchers/base' {104 declare module.exports: any;105}106declare module 'karma/lib/launchers/capture_timeout' {107 declare module.exports: any;108}109declare module 'karma/lib/launchers/process' {110 declare module.exports: any;111}112declare module 'karma/lib/launchers/retry' {113 declare module.exports: any;114}115declare module 'karma/lib/logger' {116 declare module.exports: any;117}118declare module 'karma/lib/middleware/common' {119 declare module.exports: any;120}121declare module 'karma/lib/middleware/karma' {122 declare module.exports: any;123}124declare module 'karma/lib/middleware/proxy' {125 declare module.exports: any;126}127declare module 'karma/lib/middleware/runner' {128 declare module.exports: any;129}130declare module 'karma/lib/middleware/source_files' {131 declare module.exports: any;132}133declare module 'karma/lib/middleware/stopper' {134 declare module.exports: any;135}136declare module 'karma/lib/middleware/strip_host' {137 declare module.exports: any;138}139declare module 'karma/lib/plugin' {140 declare module.exports: any;141}142declare module 'karma/lib/preprocessor' {143 declare module.exports: any;144}145declare module 'karma/lib/reporter' {146 declare module.exports: any;147}148declare module 'karma/lib/reporters/base_color' {149 declare module.exports: any;150}151declare module 'karma/lib/reporters/base' {152 declare module.exports: any;153}154declare module 'karma/lib/reporters/dots_color' {155 declare module.exports: any;156}157declare module 'karma/lib/reporters/dots' {158 declare module.exports: any;159}160declare module 'karma/lib/reporters/multi' {161 declare module.exports: any;162}163declare module 'karma/lib/reporters/progress_color' {164 declare module.exports: any;165}166declare module 'karma/lib/reporters/progress' {167 declare module.exports: any;168}169declare module 'karma/lib/runner' {170 declare module.exports: any;171}172declare module 'karma/lib/server' {173 declare module.exports: any;174}175declare module 'karma/lib/stopper' {176 declare module.exports: any;177}178declare module 'karma/lib/temp_dir' {179 declare module.exports: any;180}181declare module 'karma/lib/url' {182 declare module.exports: any;183}184declare module 'karma/lib/utils/bundle-utils' {185 declare module.exports: any;186}187declare module 'karma/lib/utils/crypto-utils' {188 declare module.exports: any;189}190declare module 'karma/lib/utils/file-utils' {191 declare module.exports: any;192}193declare module 'karma/lib/utils/json-utils' {194 declare module.exports: any;195}196declare module 'karma/lib/utils/net-utils' {197 declare module.exports: any;198}199declare module 'karma/lib/utils/path-utils' {200 declare module.exports: any;201}202declare module 'karma/lib/watcher' {203 declare module.exports: any;204}205declare module 'karma/lib/web-server' {206 declare module.exports: any;207}208declare module 'karma/requirejs.config.tpl' {209 declare module.exports: any;210}211declare module 'karma/static/context' {212 declare module.exports: any;213}214declare module 'karma/static/debug' {215 declare module.exports: any;216}217declare module 'karma/static/karma' {218 declare module.exports: any;219}220declare module 'karma/wallaby' {221 declare module.exports: any;222}223// Filename aliases224declare module 'karma/common/stringify.js' {225 declare module.exports: $Exports<'karma/common/stringify'>;226}227declare module 'karma/common/util.js' {228 declare module.exports: $Exports<'karma/common/util'>;229}230declare module 'karma/config.tpl.js' {231 declare module.exports: $Exports<'karma/config.tpl'>;232}233declare module 'karma/context/karma.js' {234 declare module.exports: $Exports<'karma/context/karma'>;235}236declare module 'karma/context/main.js' {237 declare module.exports: $Exports<'karma/context/main'>;238}239declare module 'karma/gruntfile.js' {240 declare module.exports: $Exports<'karma/gruntfile'>;241}242declare module 'karma/lib/browser_collection.js' {243 declare module.exports: $Exports<'karma/lib/browser_collection'>;244}245declare module 'karma/lib/browser_result.js' {246 declare module.exports: $Exports<'karma/lib/browser_result'>;247}248declare module 'karma/lib/browser.js' {249 declare module.exports: $Exports<'karma/lib/browser'>;250}251declare module 'karma/lib/cli.js' {252 declare module.exports: $Exports<'karma/lib/cli'>;253}254declare module 'karma/lib/completion.js' {255 declare module.exports: $Exports<'karma/lib/completion'>;256}257declare module 'karma/lib/config.js' {258 declare module.exports: $Exports<'karma/lib/config'>;259}260declare module 'karma/lib/constants.js' {261 declare module.exports: $Exports<'karma/lib/constants'>;262}263declare module 'karma/lib/detached.js' {264 declare module.exports: $Exports<'karma/lib/detached'>;265}266declare module 'karma/lib/emitter_wrapper.js' {267 declare module.exports: $Exports<'karma/lib/emitter_wrapper'>;268}269declare module 'karma/lib/events.js' {270 declare module.exports: $Exports<'karma/lib/events'>;271}272declare module 'karma/lib/executor.js' {273 declare module.exports: $Exports<'karma/lib/executor'>;274}275declare module 'karma/lib/file-list.js' {276 declare module.exports: $Exports<'karma/lib/file-list'>;277}278declare module 'karma/lib/file.js' {279 declare module.exports: $Exports<'karma/lib/file'>;280}281declare module 'karma/lib/helper.js' {282 declare module.exports: $Exports<'karma/lib/helper'>;283}284declare module 'karma/lib/index.js' {285 declare module.exports: $Exports<'karma/lib/index'>;286}287declare module 'karma/lib/init.js' {288 declare module.exports: $Exports<'karma/lib/init'>;289}290declare module 'karma/lib/init/color_schemes.js' {291 declare module.exports: $Exports<'karma/lib/init/color_schemes'>;292}293declare module 'karma/lib/init/formatters.js' {294 declare module.exports: $Exports<'karma/lib/init/formatters'>;295}296declare module 'karma/lib/init/log-queue.js' {297 declare module.exports: $Exports<'karma/lib/init/log-queue'>;298}299declare module 'karma/lib/init/state_machine.js' {300 declare module.exports: $Exports<'karma/lib/init/state_machine'>;301}302declare module 'karma/lib/launcher.js' {303 declare module.exports: $Exports<'karma/lib/launcher'>;304}305declare module 'karma/lib/launchers/base.js' {306 declare module.exports: $Exports<'karma/lib/launchers/base'>;307}308declare module 'karma/lib/launchers/capture_timeout.js' {309 declare module.exports: $Exports<'karma/lib/launchers/capture_timeout'>;310}311declare module 'karma/lib/launchers/process.js' {312 declare module.exports: $Exports<'karma/lib/launchers/process'>;313}314declare module 'karma/lib/launchers/retry.js' {315 declare module.exports: $Exports<'karma/lib/launchers/retry'>;316}317declare module 'karma/lib/logger.js' {318 declare module.exports: $Exports<'karma/lib/logger'>;319}320declare module 'karma/lib/middleware/common.js' {321 declare module.exports: $Exports<'karma/lib/middleware/common'>;322}323declare module 'karma/lib/middleware/karma.js' {324 declare module.exports: $Exports<'karma/lib/middleware/karma'>;325}326declare module 'karma/lib/middleware/proxy.js' {327 declare module.exports: $Exports<'karma/lib/middleware/proxy'>;328}329declare module 'karma/lib/middleware/runner.js' {330 declare module.exports: $Exports<'karma/lib/middleware/runner'>;331}332declare module 'karma/lib/middleware/source_files.js' {333 declare module.exports: $Exports<'karma/lib/middleware/source_files'>;334}335declare module 'karma/lib/middleware/stopper.js' {336 declare module.exports: $Exports<'karma/lib/middleware/stopper'>;337}338declare module 'karma/lib/middleware/strip_host.js' {339 declare module.exports: $Exports<'karma/lib/middleware/strip_host'>;340}341declare module 'karma/lib/plugin.js' {342 declare module.exports: $Exports<'karma/lib/plugin'>;343}344declare module 'karma/lib/preprocessor.js' {345 declare module.exports: $Exports<'karma/lib/preprocessor'>;346}347declare module 'karma/lib/reporter.js' {348 declare module.exports: $Exports<'karma/lib/reporter'>;349}350declare module 'karma/lib/reporters/base_color.js' {351 declare module.exports: $Exports<'karma/lib/reporters/base_color'>;352}353declare module 'karma/lib/reporters/base.js' {354 declare module.exports: $Exports<'karma/lib/reporters/base'>;355}356declare module 'karma/lib/reporters/dots_color.js' {357 declare module.exports: $Exports<'karma/lib/reporters/dots_color'>;358}359declare module 'karma/lib/reporters/dots.js' {360 declare module.exports: $Exports<'karma/lib/reporters/dots'>;361}362declare module 'karma/lib/reporters/multi.js' {363 declare module.exports: $Exports<'karma/lib/reporters/multi'>;364}365declare module 'karma/lib/reporters/progress_color.js' {366 declare module.exports: $Exports<'karma/lib/reporters/progress_color'>;367}368declare module 'karma/lib/reporters/progress.js' {369 declare module.exports: $Exports<'karma/lib/reporters/progress'>;370}371declare module 'karma/lib/runner.js' {372 declare module.exports: $Exports<'karma/lib/runner'>;373}374declare module 'karma/lib/server.js' {375 declare module.exports: $Exports<'karma/lib/server'>;376}377declare module 'karma/lib/stopper.js' {378 declare module.exports: $Exports<'karma/lib/stopper'>;379}380declare module 'karma/lib/temp_dir.js' {381 declare module.exports: $Exports<'karma/lib/temp_dir'>;382}383declare module 'karma/lib/url.js' {384 declare module.exports: $Exports<'karma/lib/url'>;385}386declare module 'karma/lib/utils/bundle-utils.js' {387 declare module.exports: $Exports<'karma/lib/utils/bundle-utils'>;388}389declare module 'karma/lib/utils/crypto-utils.js' {390 declare module.exports: $Exports<'karma/lib/utils/crypto-utils'>;391}392declare module 'karma/lib/utils/file-utils.js' {393 declare module.exports: $Exports<'karma/lib/utils/file-utils'>;394}395declare module 'karma/lib/utils/json-utils.js' {396 declare module.exports: $Exports<'karma/lib/utils/json-utils'>;397}398declare module 'karma/lib/utils/net-utils.js' {399 declare module.exports: $Exports<'karma/lib/utils/net-utils'>;400}401declare module 'karma/lib/utils/path-utils.js' {402 declare module.exports: $Exports<'karma/lib/utils/path-utils'>;403}404declare module 'karma/lib/watcher.js' {405 declare module.exports: $Exports<'karma/lib/watcher'>;406}407declare module 'karma/lib/web-server.js' {408 declare module.exports: $Exports<'karma/lib/web-server'>;409}410declare module 'karma/requirejs.config.tpl.js' {411 declare module.exports: $Exports<'karma/requirejs.config.tpl'>;412}413declare module 'karma/static/context.js' {414 declare module.exports: $Exports<'karma/static/context'>;415}416declare module 'karma/static/debug.js' {417 declare module.exports: $Exports<'karma/static/debug'>;418}419declare module 'karma/static/karma.js' {420 declare module.exports: $Exports<'karma/static/karma'>;421}422declare module 'karma/wallaby.js' {423 declare module.exports: $Exports<'karma/wallaby'>;...

Full Screen

Full Screen

karmabot.js

Source:karmabot.js Github

copy

Full Screen

1// Description:2// Track arbitrary karma3//4// Dependencies:5// None6//7// Configuration:8// KARMA_ALLOW_SELF9//10// Commands:11// karmabot create @Slackname - create karma keeping for a slack user12// karmabot empty @Slackname - empty someone's total karma13// @Slackname++ to give someone some karma14// @Slackname-- to take away someone's karma15// karmabot @Slackname - check someone's karma (if @Slackname is omitted, show the top 5)16// karmabot best - show the five with the most karma17// karmabot least - show the five with the least karma18class Karma {19 constructor(robot) {20 this.robot = robot;21 this.cache = {};22 this.increment_responses = [23 "+1!", "got some karma! Woohoo!", "is so loved. You go, girl.", "leveled up! Yassss!"24 ];25 this.decrement_responses = [26 "just lost some karma! So sad.", "has been downgraded.", "-1 karma point. Ouch!"27 ];28 this.robot.brain.on('loaded', () => {29 if (this.robot.brain.data.karma) {30 return this.cache = this.robot.brain.data.karma;31 }32 });33 }34 exists(slackname) {35 // Object.keys(this.cache).includes(slackname);36 return (slackname in this.cache)37 }38 create(slackname) {39 if (this.cache[slackname] == null) { this.cache[slackname] = 0; }40 return this.robot.brain.data.karma = this.cache;41 }42 delete(slackname) {43 delete this.cache[slackname];44 return this.robot.brain.data.karma = this.cache;45 }46 increment(slackname) {47 if (this.cache[slackname] == null) { this.cache[slackname] = 0; }48 this.cache[slackname] += 1;49 return this.robot.brain.data.karma = this.cache;50 }51 decrement(slackname) {52 if (this.cache[slackname] == null) { this.cache[slackname] = 0; }53 this.cache[slackname] -= 1;54 return this.robot.brain.data.karma = this.cache;55 }56 adjust(slackname, amount) {57 if (this.cache[slackname] == null) { this.cache[slackname] = 0; }58 this.cache[slackname] += amount;59 return this.robot.brain.data.karma = this.cache;60 }61 incrementResponse() {62 return this.increment_responses[Math.floor(Math.random() * this.increment_responses.length)];63 }64 decrementResponse() {65 return this.decrement_responses[Math.floor(Math.random() * this.decrement_responses.length)];66 }67 selfDeniedResponses(name) {68 return this.self_denied_responses = [69 "You can't self-award karma.",70 "Um, no.",71 `Nope. Try getting someone else to give you some karma, ${name}.`72 ];73 }74 get(slackname) {75 const k = this.cache[slackname] ? this.cache[slackname] : 0;76 return k;77 }78 sort() {79 const s = [];80 for (let key in this.cache) {81 const val = this.cache[key];82 s.push({ name: key, karma: val });83 }84 return s.sort((a, b) => b.karma - a.karma);85 }86 top(n) {87 if (n == null) { n = 10; }88 const sorted = this.sort();89 return sorted.slice(0, n);90 }91 bottom(n) {92 if (n == null) { n = 10; }93 const sorted = this.sort();94 return sorted.slice(-n).reverse();95 }96 cleanSubject(subject) {97 // remove any prefix characters (e.g. @, ", ', etc.)98 return subject.trim().replace(/^[^a-z]+/, '').replace(/:$/, '');99 }100}101module.exports = (robot) => {102 const karma = new Karma(robot);103 const allow_self = process.env.KARMA_ALLOW_SELF || false;104 robot.hear(/(@[^@+:]+|[^-+:\s]*)[:\s]*(\+\+|--)/g, (msg) => {105 const output = [];106 for (let subject of Array.from(msg.match)) {107 const user = msg.message.user.name.toLowerCase();108 subject = subject.trim();109 const increasing = subject.slice(-2) === "++";110 subject = karma.cleanSubject(subject.slice(0, +-3 + 1 || undefined).toLowerCase());111 if (subject === '') {112 continue;113 }114 if ((allow_self === false) && (user === subject)) {115 output.push(msg.random(karma.selfDeniedResponses(msg.message.user.name)));116 continue;117 }118 if (!karma.exists(subject)) {119 output.push(`Karma does not exist for '${subject}'. Use \`${robot.name} create ${subject}\` to make it right.`);120 continue;121 }122 if (increasing) {123 karma.increment(subject);124 output.push(`${subject} ${karma.incrementResponse()} (Karma: ${karma.get(subject)})`);125 } else {126 karma.decrement(subject);127 output.push(`${subject} ${karma.decrementResponse()} (Karma: ${karma.get(subject)})`);128 }129 }130 if (output.length > 0) {131 return msg.send(output.join('\n'));132 }133 });134 robot.respond(/create ?(@[^@+:]+|[^-+:\s]*)$/i, (msg) => {135 const subject = karma.cleanSubject(msg.match[1].toLowerCase());136 if (karma.exists(subject)) {137 msg.send(`Karma already exists for ${subject}`);138 return;139 }140 karma.create(subject);141 return msg.send(`${subject} is now ready to receive karma! Use \`${subject}++\` and \`${subject}--\` to give and take karma.`);142 });143 robot.respond(/empty ?(@[^@+:]+|[^-+:\s]*)$/i, (msg) => {144 const subject = karma.cleanSubject(msg.match[1].toLowerCase());145 karma.delete(subject);146 return msg.send(`${subject}'s karma has been scattered to the winds.`);147 });148 robot.respond(/best$/i, (msg) => {149 const verbiage = ["The Best"];150 const iterable = karma.top();151 for (let rank = 0; rank < iterable.length; rank++) {152 const item = iterable[rank];153 verbiage.push(`${rank + 1}. ${item.name} - ${item.karma}`);154 }155 return msg.send(verbiage.join("\n"));156 });157 robot.respond(/least$/i, (msg) => {158 const verbiage = ["The Least"];159 const iterable = karma.bottom();160 for (let rank = 0; rank < iterable.length; rank++) {161 const item = iterable[rank];162 verbiage.push(`${rank + 1}. ${item.name} - ${item.karma}`);163 }164 return msg.send(verbiage.join("\n"));165 });166 return robot.respond(/(@[^@+:]+|[^-+:\s]*)$/i, (msg) => {167 const match = karma.cleanSubject(msg.match[1].toLowerCase());168 if ((match !== "best") && (match !== "least") && (match.substr(0, 6) !== "create") && (match.substr(0, 5) !== "empty")) {169 if (karma.exists(match)) {170 return msg.send(`\"${match}\" has ${karma.get(match)} karma.`);171 } else {172 if (match === 'ping') {173 return;174 }175 return msg.send(`Karma does not exist for '${match}'. Use \`${robot.name} create ${match}\` to make it right.`);176 }177 }178 });...

Full Screen

Full Screen

karma.js

Source:karma.js Github

copy

Full Screen

1let r;2let bot;3const event = require('./events/chat-message.js');4const db = require('./lib/db');5function onChat(data) {6 const lastChars = data.message.slice(-2);7 if ((lastChars !== "++")) {8 return;9 }10 if (data.message.split(" ").length > 1) {11 return;12 }13 14 let username = data.message.slice(0, -2);15 if (username.substr(0, 1) === "@") {16 username = username.substr(1);17 }18 bot.util.getUserIDFromName(username, (nameErr, dubid) => {19 if (nameErr != null) {20 bot.sendChat(`@${data.user.username}, Dubtrack doesn't know who ${username} is!`);21 return;22 }23 const whore = data.user.id === dubid;24 const offsetKarma = whore ? -1 : 1;25 db.query(`UPDATE dubtrack_users SET karma = karma + $2 where dub_id = $1 RETURNING karma`, [dubid, offsetKarma], (err, res) => {26 if (bot.checkError(err, "pgsql", 'could not update karma++')) {27 bot.sendChat("Could not update karma++.");28 return;29 } else if (res.rowCount === 0) {30 bot.sendChat(`@${data.user.username}, I don't know who ${username} is!`);31 return;32 }33 const suffix = whore ? "No karma whoring for you!" : "";34 bot.sendChat(`${username} is now at ${res.rows[0].karma} karma! ${suffix}`);35 });36 });37}38function commandSet(data) {39 if (bot.ranks.indexOf(data.user.role) === -1) {40 return;41 }42 43 bot.moderateDeleteChat(data.id);44 if (data.params[1] == null) {45 bot.sendChat("Syntax: `!karma set @username AMOUNT`. Amount can be prefixed with a sign to update it relatively.");46 return;47 }48 let username = data.params[0].toLowerCase();49 if (username.substr(0, 1) === "@") {50 username = username.substr(1);51 }52 53 const newKarma = parseInt(data.params[1], 10);54 if (isNaN(newKarma)) {55 bot.sendChat("Invalid number supplied");56 return;57 }58 let query = "$2";59 // if is relative60 if ((newKarma < 0) || (data.params[1].substr(0, 1) === "+")) {61 query = "karma + $2";62 }63 bot.util.getUserIDFromName(username, (nameErr, dubid) => {64 if (nameErr != null) {65 bot.sendChat("Could not find user.");66 return;67 }68 db.query(`UPDATE dubtrack_users SET karma = ${query} where dub_id = $1`, [dubid, newKarma], (err, res) => {69 if (bot.checkError(err, "pgsql", 'could not update karma')) {70 bot.sendChat("Could not update karma.");71 return;72 } else if (res.rowCount === 0) {73 bot.sendChat("Could not find user in database.");74 return;75 }76 });77 });78}79const shop = {80 front: {81 cost: 1500,82 action: person => {83 const pos = 2;84 bot.moderateMoveDJ(person.id, pos - 1);85 },86 },87 boost: {88 cost: 500,89 action: person => {90 const pos = bot.getQueuePosition(person.id) - 1;91 bot.moderateMoveDJ(person.id, pos);92 },93 },94};95function commandBuy(data) { 96 bot.moderateDeleteChat(data.id);97 const item = shop[data.params[0]];98 if (item == null) {99 bot.sendChat("Syntax: `!karma buy boost` (500 karma) to jump a spot, `!karma buy front` (1500 karma) to jump to spot 2.");100 return;101 }102 db.query(103 `UPDATE dubtrack_users SET karma = karma - $2 where (dub_id = $1) and (karma > $2);`,104 [data.user.id, item.cost],105 (err, res) => {106 if (bot.checkError(err, "pgsql", 'could not buy with karma')) {107 bot.sendChat("Could not buy item, internal error.");108 return;109 }110 if (res.rowCount === 0) {111 bot.sendChat(`You do not have enough karma, @${data.user.username}!`);112 return;113 }114 item.action(data.user);115 }116 );117}118function onCommand(_, data) {119 switch (data.params[0]) {120 case "help":121 bot.sendChat("Karma is rewarded for new plays and well-received plays. Use `!karma @user` to find the karma of a friend, or omit the username to find your own karma. It can be spent using `!karma buy front` or `!karma buy boost`. Soon: Karma can be gifted using `!karma gift @user amount`.");122 return;123 case "gift":124 // todo;125 return;126 case "buy":127 data.params.shift();128 commandBuy(data);129 return;130 case "set":131 data.params.shift();132 commandSet(data);133 return;134 default:135 break;136 }137 let username = data.user.username.toLowerCase();138 if (data.params[0] != null) {139 username = data.params[0].toLowerCase();140 if (username.substr(0, 1) === "@") {141 username = username.substr(1);142 }143 }144 bot.util.getUserIDFromName(username, (nameErr, dubid) => {145 if (nameErr != null) {146 bot.sendChat(`@${data.user.username}, ${username} doesn't use Dubtrack!`);147 return;148 }149 db.query(150 `SELECT karma FROM dubtrack_users WHERE (dub_id = $1)`,151 [dubid],152 (err, res) => {153 if (bot.checkError(err, "pgsql", 'could not get karma')) {154 bot.sendChat("Could not find user, internal error");155 return;156 }157 158 if (res.rowCount === 0) {159 bot.sendChat(`@${data.user.username}, I don't know who ${username} is!`);160 return;161 }162 const outName = (username === data.user.username.toLowerCase()) ? "you are" : `@${username} is`;163 bot.sendChat(`@${data.user.username}, ${outName} at ${res.rows[0].karma} karma!`);164 }165 );166 }); 167}168module.exports.init = function init(receivedBot) {169 bot = receivedBot;170 171 event.AddCommand('karma', onCommand);172 // event.AddHandler("karma", onChat);...

Full Screen

Full Screen

karma.conf.maker.js

Source:karma.conf.maker.js Github

copy

Full Screen

1// This configures Karma, describing how to run the tests and where to output code coverage reports.2//3// For more information, see http://karma-runner.github.io/1.0/config/configuration-file.html4var _ = require('lodash');5var webpackConf = require('./webpack.conf');6var path = require('path')7var karmaConstants = require('karma').constants;8function newWebpackConfig(codeCoverage) {9 // Make a clone here because we plan on mutating this object, and don't want parallel tasks to trample each other.10 var webpackConfig = _.cloneDeep(webpackConf);11 // remove optimize plugin for tests12 webpackConfig.plugins.pop()13 webpackConfig.devtool = 'inline-source-map';14 if (codeCoverage) {15 webpackConfig.module.rules.push({16 enforce: 'post',17 exclude: /(node_modules)|(test)|(integrationExamples)|(build)|polyfill.js|(src\/adapters\/analytics\/ga.js)/,18 loader: 'istanbul-instrumenter-loader',19 test: /\.js$/20 })21 }22 return webpackConfig;23}24function newPluginsArray(browserstack) {25 var plugins = [26 'karma-chrome-launcher',27 'karma-coverage-istanbul-reporter',28 'karma-es5-shim',29 'karma-expect',30 'karma-mocha',31 'karma-requirejs',32 'karma-sinon-ie',33 'karma-sourcemap-loader',34 'karma-spec-reporter',35 'karma-webpack',36 ];37 if (browserstack) {38 plugins.push('karma-browserstack-launcher');39 plugins.push('karma-sauce-launcher');40 plugins.push('karma-firefox-launcher');41 plugins.push('karma-opera-launcher');42 plugins.push('karma-safari-launcher');43 plugins.push('karma-script-launcher');44 plugins.push('karma-ie-launcher');45 }46 return plugins;47}48function setReporters(karmaConf, codeCoverage, browserstack) {49 // In browserstack, the default 'progress' reporter floods the logs.50 // The karma-spec-reporter reports failures more concisely51 if (browserstack) {52 karmaConf.reporters = ['spec'];53 karmaConf.specReporter = {54 suppressSkipped: false,55 suppressPassed: true56 };57 } else {58 karmaConf.reporters = ['progress'];59 }60 if (codeCoverage) {61 karmaConf.reporters.push('coverage-istanbul');62 karmaConf.coverageIstanbulReporter = {63 reports: ['html', 'lcovonly', 'text-summary'],64 dir: path.join(__dirname, 'build', 'coverage'),65 'report-config': {66 html: {67 subdir: 'karma_html',68 urlFriendlyName: true, // simply replaces spaces with _ for files/dirs69 }70 }71 }72 }73}74function setBrowsers(karmaConf, browserstack) {75 if (browserstack) {76 karmaConf.browserStack = {77 username: process.env.BROWSERSTACK_USERNAME,78 accessKey: process.env.BROWSERSTACK_KEY79 }80 karmaConf.customLaunchers = require('./browsers.json')81 karmaConf.browsers = Object.keys(karmaConf.customLaunchers);82 } else {83 karmaConf.browsers = ['ChromeHeadless'];84 }85}86module.exports = function(codeCoverage, browserstack, watchMode, file) {87 var webpackConfig = newWebpackConfig(codeCoverage);88 var plugins = newPluginsArray(browserstack);89 var files = [90 'test/helpers/prebidGlobal.js',91 file ? file : 'test/**/*_spec.js'92 ];93 // This file opens the /debug.html tab automatically.94 // It has no real value unless you're running --watch, and intend to do some debugging in the browser.95 if (watchMode) {96 files.push('test/helpers/karma-init.js');97 }98 var config = {99 // base path that will be used to resolve all patterns (eg. files, exclude)100 basePath: './',101 webpack: webpackConfig,102 webpackMiddleware: {103 noInfo: true104 },105 // frameworks to use106 // available frameworks: https://npmjs.org/browse/keyword/karma-adapter107 frameworks: ['es5-shim', 'mocha', 'expect', 'sinon'],108 files: files,109 // preprocess matching files before serving them to the browser110 // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor111 preprocessors: {112 'test/**/*_spec.js': ['webpack', 'sourcemap'],113 'test/helpers/prebidGlobal.js': ['webpack', 'sourcemap']114 },115 // web server port116 port: 9876,117 // enable / disable colors in the output (reporters and logs)118 colors: true,119 // level of logging120 // possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG121 logLevel: karmaConstants.LOG_INFO,122 // enable / disable watching file and executing tests whenever any file changes123 autoWatch: true,124 reporters: ['progress'],125 // Continuous Integration mode126 // if true, Karma captures browsers, runs the tests and exits127 singleRun: !watchMode,128 browserDisconnectTimeout: 10000, // default 2000129 browserDisconnectTolerance: 1, // default 0130 browserNoActivityTimeout: 4 * 60 * 1000, // default 10000131 captureTimeout: 4 * 60 * 1000, // default 60000132 plugins: plugins133 }134 setReporters(config, codeCoverage, browserstack);135 setBrowsers(config, browserstack);136 return config;...

Full Screen

Full Screen

utils.js

Source:utils.js Github

copy

Full Screen

1const { getDatabase } = require("../database/database")2const { logger } = require("../logger")3const { MStoTime } = require("../utils")4const db = getDatabase()5let karmaShop = false6/**7 *8 * @param {GuildMember} member9 * @returns {Number}10 */11function getKarma(member) {12 let id = member13 if (member.user) id = member.user.id14 const query = db.prepare("SELECT karma FROM karma WHERE id = ?").get(id)15 if (!query) {16 db.prepare("INSERT INTO karma (id, karma, last_command) VALUES (?, ?, ?)").run(id, 1, Date.now())17 return 118 } else {19 return query.karma20 }21}22exports.getKarma = getKarma23/**24 *25 * @param {GuildMember} member26 * @param {Number} amount27 */28function addKarma(member, amount) {29 let id = member30 if (member.user) id = member.user.id31 const query = db.prepare("SELECT karma FROM karma WHERE id = ?").get(id)32 if (!query) {33 db.prepare("INSERT INTO karma (id, karma, last_command) VALUES (?, ?, ?)").run(id, amount + 1, Date.now())34 } else {35 db.prepare("UPDATE karma SET karma = karma + ? WHERE id = ?").run(amount, id)36 }37}38exports.addKarma = addKarma39/**40 *41 * @param {GuildMember} member42 * @param {Number} amount43 */44function removeKarma(member, amount) {45 let id = member46 if (member.user) id = member.user.id47 const query = db.prepare("SELECT karma FROM karma WHERE id = ?").get(id)48 if (!query) {49 db.prepare("INSERT INTO karma (id, karma, last_command) VALUES (?, ?, ?)").run(id, 1, Date.now())50 } else {51 if (amount > query.karma) {52 amount = query.karma - 153 }54 db.prepare("UPDATE karma SET karma = karma - ? WHERE id = ?").run(amount, id)55 }56}57exports.removeKarma = removeKarma58/**59 *60 * @param {GuildMember} member61 */62function updateLastCommand(member) {63 let id = member64 if (member.user) id = member.user.id65 const query = db.prepare("SELECT karma FROM karma WHERE id = ?").get(id)66 if (!query) {67 db.prepare("INSERT INTO karma (id, last_command) VALUES (?, ?)").run(id, Date.now())68 } else {69 db.prepare("UPDATE karma SET karma = ? WHERE id = ?").run(id, Date.now())70 }71}72exports.updateLastCommand = updateLastCommand73/**74 *75 * @returns {Boolean}76 */77function isKarmaShopOpen() {78 return karmaShop79}80exports.isKarmaShopOpen = isKarmaShopOpen81function openKarmaShop() {82 karmaShop = true83}84exports.openKarmaShop = openKarmaShop85function closeKarmaShop() {86 karmaShop = false87}88exports.closeKarmaShop = closeKarmaShop89function deteriorateKarma() {90 const now = Date.now()91 const threshold = now - 720000092 /**93 * @type {Array<{id: String, karma: Number, last_command: Number}>}94 */95 const users = db.prepare("SELECT * FROM karma WHERE karma > 10 AND last_command < ?").all(threshold)96 let total = 097 for (const user of users) {98 let karmaToRemove = 599 if (now - 864000000 > user.last_command) {100 karmaToRemove = 25101 }102 if (karmaToRemove > user.karma) {103 karmaToRemove = user.karma - 1104 }105 total += karmaToRemove106 db.prepare("UPDATE karma SET karma = karma - ? WHERE id = ?").run(karmaToRemove, user.id)107 }108 logger.auto(`${total} total karma deteriorated`)109}110// prettier-ignore111(() => {112 const now = new Date()113 let d = `${now.getMonth() + 1}/${now.getDate() + 1}/${now.getUTCFullYear()}`114 if (now.getHours() < 3) {115 d = `${now.getMonth() + 1}/${now.getDate()}/${now.getUTCFullYear()}`116 }117 const needed = new Date(Date.parse(d) + 10800000)118 setTimeout(async () => {119 setInterval(() => {120 deteriorateKarma()121 }, 86400000)122 deteriorateKarma()123 }, needed - now)124 logger.auto(`karma deterioration will run in ${MStoTime(needed - now)}`)...

Full Screen

Full Screen

karma-webpack_vx.x.x.js

Source:karma-webpack_vx.x.x.js Github

copy

Full Screen

1// flow-typed signature: 16bd5550768de9b5408059a03f71af8b2// flow-typed version: <<STUB>>/karma-webpack_v^5.0.0/flow_v0.161.03/**4 * This is an autogenerated libdef stub for:5 *6 * 'karma-webpack'7 *8 * Fill this stub out by replacing all the `any` types.9 *10 * Once filled out, we encourage you to share your work with the11 * community by sending a pull request to:12 * https://github.com/flowtype/flow-typed13 */14declare module 'karma-webpack' {15 declare module.exports: any;16}17/**18 * We include stubs for each file inside this npm package in case you need to19 * require those files directly. Feel free to delete any files that aren't20 * needed.21 */22declare module 'karma-webpack/lib' {23 declare module.exports: any;24}25declare module 'karma-webpack/lib/karma-webpack/controller' {26 declare module.exports: any;27}28declare module 'karma-webpack/lib/karma-webpack/framework' {29 declare module.exports: any;30}31declare module 'karma-webpack/lib/karma-webpack/preprocessor' {32 declare module.exports: any;33}34declare module 'karma-webpack/lib/karma/plugin' {35 declare module.exports: any;36}37declare module 'karma-webpack/lib/karma/validation' {38 declare module.exports: any;39}40declare module 'karma-webpack/lib/utils/hash' {41 declare module.exports: any;42}43declare module 'karma-webpack/lib/webpack/defaults' {44 declare module.exports: any;45}46declare module 'karma-webpack/lib/webpack/plugin' {47 declare module.exports: any;48}49// Filename aliases50declare module 'karma-webpack/lib/index' {51 declare module.exports: $Exports<'karma-webpack/lib'>;52}53declare module 'karma-webpack/lib/index.js' {54 declare module.exports: $Exports<'karma-webpack/lib'>;55}56declare module 'karma-webpack/lib/karma-webpack/controller.js' {57 declare module.exports: $Exports<'karma-webpack/lib/karma-webpack/controller'>;58}59declare module 'karma-webpack/lib/karma-webpack/framework.js' {60 declare module.exports: $Exports<'karma-webpack/lib/karma-webpack/framework'>;61}62declare module 'karma-webpack/lib/karma-webpack/preprocessor.js' {63 declare module.exports: $Exports<'karma-webpack/lib/karma-webpack/preprocessor'>;64}65declare module 'karma-webpack/lib/karma/plugin.js' {66 declare module.exports: $Exports<'karma-webpack/lib/karma/plugin'>;67}68declare module 'karma-webpack/lib/karma/validation.js' {69 declare module.exports: $Exports<'karma-webpack/lib/karma/validation'>;70}71declare module 'karma-webpack/lib/utils/hash.js' {72 declare module.exports: $Exports<'karma-webpack/lib/utils/hash'>;73}74declare module 'karma-webpack/lib/webpack/defaults.js' {75 declare module.exports: $Exports<'karma-webpack/lib/webpack/defaults'>;76}77declare module 'karma-webpack/lib/webpack/plugin.js' {78 declare module.exports: $Exports<'karma-webpack/lib/webpack/plugin'>;...

Full Screen

Full Screen

karma.conf.js

Source:karma.conf.js Github

copy

Full Screen

1module.exports = function(config) {2 config.set({3 // base path that will be used to resolve all patterns4 // (eg. files, exclude)5 basePath: '..',6 // frameworks to use7 // available frameworks: https://npmjs.org/browse/keyword/karma-adapter8 frameworks: ['mocha', 'chai', 'sinon'],9 // list of files / patterns to load in the browser10 files: [11 //Include any components needed12 //'.bower_components/angular/angular.js',13 //Include the files to test14 //'app/static/**/*.js',15 //Include the test files16 'test/unit/frontend/**/*.js',17 //{pattern: 'tests/fixtures/**/*.json', watched: true, served: true, included: false}18 ],19 // list of files to exclude20 //note: karma HATES files with requires in them21 exclude: [22 //'exclude.js',23 ],24 // preprocess matching files before serving them to the browser25 // available preprocessors:26 // https://npmjs.org/browse/keyword/karma-preprocessor27 preprocessors: {28 'app/static/**/*.js': ['coverage'],29 },30 // configure the reporter31 coverageReporter: {32 type: 'html',33 dir: 'coverage',34 },35 // test results reporter to use36 // possible values: "dots", "progress"37 // available reporters: https://npmjs.org/browse/keyword/karma-reporter38 // install these with npm39 reporters: ['junit', 'spec', 'coverage', 'progress', 'dots'],40 junitReporter: {41 outputDir: 'test',42 },43 plugins: [44 //'karma-chrome-launcher',45 //'karma-firefox-launcher',46 //'karma-ie-launcher',47 //'karma-safari-launcher',48 'karma-phantomjs-launcher',49 'karma-mocha',50 'karma-chai',51 'karma-sinon',52 'karma-spec-reporter',53 'karma-junit-reporter',54 'karma-coverage',55 'karma-jasmine',56 ],57 // web server port58 port: 9876,59 // enable / disable colors in the output (reporters and logs)60 colors: true,61 // level of logging62 // possible values: config.LOG_DISABLE || config.LOG_ERROR ||63 // config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG64 logLevel: config.LOG_DEBUG,65 // enable / disable watching file and executing66 // tests whenever any file changes67 autoWatch: true,68 // start these browsers69 // available browser launchers:70 // https://npmjs.org/browse/keyword/karma-launcher71 browsers: ['PhantomJS'],72 // Continuous Integration mode73 // if true, Karma captures browsers, runs the tests and exits74 singleRun: true,75 detectBrowsers: {76 // enable/disable, default is true, set to false to use above browsers array.77 enabled: false,78 // enable/disable phantomjs support, default is true79 usePhantomJS: true,80 },81 });...

Full Screen

Full Screen

karma-chrome-launcher_vx.x.x.js

Source:karma-chrome-launcher_vx.x.x.js Github

copy

Full Screen

1// flow-typed signature: 62d70c149471b08ee191d3468d5a1ca92// flow-typed version: <<STUB>>/karma-chrome-launcher_v^2.2.0/flow_v0.82.03/**4 * This is an autogenerated libdef stub for:5 *6 * 'karma-chrome-launcher'7 *8 * Fill this stub out by replacing all the `any` types.9 *10 * Once filled out, we encourage you to share your work with the11 * community by sending a pull request to:12 * https://github.com/flowtype/flow-typed13 */14declare module 'karma-chrome-launcher' {15 declare module.exports: any;16}17/**18 * We include stubs for each file inside this npm package in case you need to19 * require those files directly. Feel free to delete any files that aren't20 * needed.21 */22declare module 'karma-chrome-launcher/examples/simple/index.spec' {23 declare module.exports: any;24}25declare module 'karma-chrome-launcher/examples/simple/karma.conf' {26 declare module.exports: any;27}28declare module 'karma-chrome-launcher/gruntfile' {29 declare module.exports: any;30}31declare module 'karma-chrome-launcher/test/jsflags.spec' {32 declare module.exports: any;33}34// Filename aliases35declare module 'karma-chrome-launcher/examples/simple/index.spec.js' {36 declare module.exports: $Exports<'karma-chrome-launcher/examples/simple/index.spec'>;37}38declare module 'karma-chrome-launcher/examples/simple/karma.conf.js' {39 declare module.exports: $Exports<'karma-chrome-launcher/examples/simple/karma.conf'>;40}41declare module 'karma-chrome-launcher/gruntfile.js' {42 declare module.exports: $Exports<'karma-chrome-launcher/gruntfile'>;43}44declare module 'karma-chrome-launcher/index' {45 declare module.exports: $Exports<'karma-chrome-launcher'>;46}47declare module 'karma-chrome-launcher/index.js' {48 declare module.exports: $Exports<'karma-chrome-launcher'>;49}50declare module 'karma-chrome-launcher/test/jsflags.spec.js' {51 declare module.exports: $Exports<'karma-chrome-launcher/test/jsflags.spec'>;...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var Stryker = require('stryker');2var StrykerKarmaTestRunner = require('stryker-karma-runner');3var stryker = new Stryker({4 karma: {5 config: {6 }7 }8});9stryker.runMutationTest();10module.exports = function (config) {11 config.set({12 preprocessors: {},13 });14};15module.exports = function (config) {16 config.set({17 preprocessors: {},18 });19};

Full Screen

Using AI Code Generation

copy

Full Screen

1const { Stryker } = require('stryker-parent');2const { ConfigReader } = require('stryker-parent');3const config = ConfigReader.readConfig();4const stryker = new Stryker(config);5stryker.runMutationTest();6const { StrykerKarmaConfig } = require('stryker-parent');7module.exports = function (config) {8 const strykerConfig = StrykerKarmaConfig.readConfig();9 config.set(strykerConfig);10};11const { StrykerJestConfig } = require('stryker-parent');12module.exports = StrykerJestConfig.readConfig();13const { StrykerMochaConfig } = require('stryker-parent');14module.exports = StrykerMochaConfig.readConfig();15const { StrykerProtractorConfig } = require('stryker-parent');16module.exports = StrykerProtractorConfig.readConfig();17const { ConfigReader } = require('stryker-parent');18module.exports = ConfigReader.readConfig();19const { StrykerTsConfig } = require('stryker-parent');20module.exports = StrykerTsConfig.readConfig();21const { StrykerRollupConfig } = require('stryker-parent');22module.exports = StrykerRollupConfig.readConfig();

Full Screen

Using AI Code Generation

copy

Full Screen

1const karmaConfig = require('stryker-parent/karma.conf.js');2module.exports = function(config) {3 config.set(karmaConfig(config));4};5module.exports = function(config) {6 config.set({7 preprocessors: {8 },9 })10}

Full Screen

Using AI Code Generation

copy

Full Screen

1const stryker = require('stryker-parent');2module.exports = stryker.config.set({3 karmaConfig: {4 }5});6module.exports = function (config) {7 config.set({8 });9};10const stryker = require('stryker-parent');11module.exports = stryker.config.set({12});13module.exports = function(config) {14 config.set({15 karmaConfig: {16 }17 });18};

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run stryker-parent automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful