Пример #1
0
 bit("should let you remove Channel objects", function(done) {
   var chan = new irc.Channel("#removechanobj");
   var bot  = this;
   bot.join(chan, function(ch) {
     bot.channels.has(chan.id).should.equal(true);
     server.on("message", function ok(m) {
       if (!/PART/.test(m)) {
         return;
       }
       server.removeListener("message", ok);
       m.should.equal(f("PART %s\r\n", chan));
     });
     bot.part(chan);
     var handler = function(a) {
       bot.channels.has(chan.id).should.equal(false);
       bot.ignore(COMMAND.PART, handler);
     }
     bot.match(COMMAND.PART, handler);
     server.recite(f(":%s!~a@b.c PART %s\r\n", bot.user.nick, chan));
     done();
   });
   server.recite(f(":%s!~a@b.c JOIN %s\r\n", this.user.nick, chan));
   server.recite(f(":card.freenode.net 353 %s @ %s :%s\r\n",
     this.user.nick, chan, this.user.nick));
 });
Пример #2
0
 server.on("message", function ok(m) {
   if (!/MODE #modez/.test(m)) {
     return;
   }
   server.removeListener("message", ok);
   m.should.equal(f("MODE %s %s\r\n", chan, mode));
   server.recite(f(":lol@omg.com MODE %s %s\r\n", chan, mode));
 });
Пример #3
0
 server.on("message", function ok(m) {
   if (!/PART/.test(m)) {
     return;
   }
   server.removeListener("message", ok);
   m.should.equal(f("PART %s\r\n", chan));
   server.recite(f(":%s!~a@b.c PART %s\r\n", bot.user.nick, chan));
   done();
 });
Пример #4
0
 bit("should remove people from its list of users", function(done) {
   var chan = irc.channel("#removepeople");
   var bot  = this;
   chan.client = bot;
   chan.join();
   server.recite(f(":%s!~a@b.c JOIN %s\r\n", bot.user.nick, chan));
   // Hit and run lol
   server.recite(":protobot1!~protobot@rogers.com JOIN #removepeople\r\n");
   server.recite(":protobot1!~protobot@rogers.com PART #removepeople\r\n");
   // getting kicked should also remove the person
   server.recite(":protobot2!~protobot@rogers.com JOIN #removepeople\r\n");
   server.recite(":evilbot!~nemesis@rogers.com KICK #removepeople protobot2\r\n");
   // also quitting
   bot.join("#quitters");
   server.recite(f(":%s!~a@b.c JOIN %s\r\n", bot.user.nick, "#quitters"));
   server.recite(":protobot3!~protobot@rogers.com JOIN #removepeople\r\n");
   server.recite(":protobot3!~protobot@rogers.com JOIN #quitters\r\n");
   server.recite(":protobot3!~protobot@rogers.com QUIT :Laterz\r\n");
   done();return;
   setTimeout(function() {
     should.not.exist(bot.channels.get(irc.id("#removepeople"))
       .people.get(irc.id("protobot1")));
     should.not.exist(bot.channels.get(irc.id("#removepeople"))
       .people.get(irc.id("protobot2")));
     should.not.exist(bot.channels.get(irc.id("#removepeople"))
       .people.get(irc.id("protobot3")));
     should.not.exist(bot.channels.get(irc.id("#quitters"))
       .people.get(irc.id("protobot3")));
     done();
   }, 10);
 });
Пример #5
0
 bit("should keep its topic updated", function(done) {
   const chan  = this.join("#updatetopic");
   const topic = "This topic is so up to date";
   chan.client = this;
   server.recite(f(":%s!~a@b.c JOIN %s\r\n", this.user.nick, chan));
   server.recite(f(":topic@setter.com TOPIC %s :%s\r\n", chan, topic));
   setTimeout(function() {
     chan.topic.should.equal(topic);
     done();
   }, 10);
 });
Пример #6
0
 bit("should know that LOL[]\\~ is the same name as lol{}|^", function(done) {
   var lol = "#LOL[]\\~";
   var bot = this;
   this.join(lol, function(ch) {
     bot.channels.has("#lol{}|^").should.equal(true);
     done();
   });
   server.recite(f(":%s@wee JOIN %s\r\n", this.user.nick, lol));
   server.recite(f(":card.freenode.net 353 %s @ %s :%s nlogax\r\n",
     this.user.nick, lol, this.user.nick));
 });
Пример #7
0
 bit("should let you add channels by name", function(done) {
   var bot  = this;
   var chan = this.join("#addchanname", function() {
     bot.channels.has(chan.id).should.equal(true);
     bot.channels.get(chan.id).should.equal(chan);
     done();
   });
   server.recite(f(":%s!~a@b.c JOIN %s\r\n", this.user.nick, chan));
   server.recite(f(":card.freenode.net 353 %s @ %s :%s nlogax\r\n",
     this.user.nick, chan, this.user.nick));
 });
Пример #8
0
 server.on("message", function ok(m) {
   if (!/TOPIC #setowntopic/.test(m)) {
     return;
   }
   server.removeListener("message", ok);
   server.recite(f(":topic@setter.com TOPIC %s :%s\r\n", chan, topic));
   setTimeout(function() {
     chan.topic.should.equal(topic);
     done();
   }, 10);
 });
Пример #9
0
 bit("should record the channel mode", function(done) {
   const chan = irc.channel("#gotmodez");
   this.join(chan);
   server.recite(f(":%s!~a@b.c JOIN %s\r\n", this.user.nick, chan));
   server.recite(":the.server.com MODE #gotmodez +ami\r\n");
   server.recite(":the.server.com MODE #gotmodez -i\r\n");
   setTimeout(function() {
     chan.mode.has('a').should.equal(true);
     chan.mode.has('m').should.equal(true);
     chan.mode.has('i').should.equal(false);
     done();
   }, 10);
 });
Пример #10
0
 bit("should handle chopped up messages", function(done) {
   var bot = this;
   let got = 0;
   bot.match(COMMAND.PRIVMSG, function handler(msg) {
     if (msg.params[1] === ":Mad chopz") {
       bot.ignore(COMMAND.PRIVMSG, handler);
       if (2 === ++got) {
         done();
       }
     }
   });
   bot.match(COMMAND.NOTICE, function handler(msg) {
     if (msg.params[1] === ":*** Looking up your hostnamez...") {
       bot.ignore(COMMAND.NOTICE, handler);
       if (2 === ++got) {
         done();
       }
     }
   });
   server.recite(":chop!chop@choppers PR");
   setTimeout(function() {
     server.recite("IVMSG #choppy :Mad chopz\r\nNOTICE AUTH :*** Looking up your hostna");
   },10);
   setTimeout(function() {
     server.recite("mez...\r\n");
   },20);
 });
Пример #11
0
 bit("should rename the channel if forwarded", function(done) {
   var c1 = irc.channel("#fwdfrom");
   var c2 = irc.channel("#fwdto");
   var bot = this;
   this.join(c1, function(err, ch) {
     err.should.be.an.instanceof(Error);
     err.message.should.equal("Forwarding to another channel");
     ch.name.should.equal(c2.name);
     bot.channels.has(c2.id).should.equal(true);
     bot.channels.has(irc.id("#fwdfrom")).should.equal(false);
     done();
   });
   server.recite(f(":holmes.freenode.net 470 %s %s %s :Forwarding to another channel\r\n",
     this.user.nick, c1, c2));
   server.recite(f(":%s@wee JOIN %s\r\n", this.user.nick, c2));
 });
Пример #12
0
 bit("should create only one Person instance per user", function(done) {
   var nick = "unique";
   var bot  = this;
   bot.join("#channelone")
   var ch = bot.join("#channeltwo", function() {
     ch.people.get(irc.id(nick)).should.equal(
       bot.channels.get(irc.id("#channelone")).people.get(irc.id(nick)));
     done();
   });
   server.recite(f(":%s@wee JOIN %s\r\n", this.user.nick, "#channelone"));
   server.recite(f(":%s@wee JOIN %s\r\n", this.user.nick, "#channeltwo"));
   server.recite(f(":card.freenode.net 353 %s @ %s :%s nlogax\r\n",
     this.user.nick, "#channelone", nick));
   server.recite(f(":card.freenode.net 353 %s @ %s :%s nlogax\r\n",
     this.user.nick, "#channeltwo", nick));
 });
Пример #13
0
 server.on("message", function ok(d) {
   if (/PRIVMSG #longassstrings/.test(d)) {
     server.removeListener("message", ok);
     d.length.should.equal(512);
     done();
   }
 });
Пример #14
0
 server.on("message", function ok(m) {
   if (!/PART/.test(m)) {
     return;
   }
   server.removeListener("message", ok);
   m.should.equal(f("PART %s\r\n", chan));
 });
Пример #15
0
  db.connect(function(err) {
    if (!err) {

      // THIS NEEDS TO HAPPEN AFTER DB IS CONNECTED
      let strategies = {
        local: require(config.dir.config + 'passport/local')(app)
      };

      passport.use(strategies.local);

      router.init(); // INITIALIZE ROUTER
      util.server.start(app); // FIRE UP THE SERVER
    } else {
      util.server.error(err);
    }
  })
Пример #16
0
	.oncreate( function( request ) {
		console.log( JSON.stringify( { assertion: "strictEqual", arguments: [
			"target" in request, false, "Server: Create request has no target"
		] } ) );
		ocf.server.register( request.data )
			.then(
				function( resource ) {
					return request.respond( resource );
				},
				function( error ) {
					return request.respondWithError( error );
				} )
			.then(
				function() {
					console.log( JSON.stringify( { assertion: "ok", arguments: [
						true, "Server: Response successfully sent"
					] } ) );
				},
				function( anError ) {
					console.log( JSON.stringify( { assertion: "ok", arguments: [
						false, "Server: Error: " +
							( "" + anError ) + "\n" + JSON.stringify( anError, null, 4 )
					] } ) );
				} );
	} );
Пример #17
0
 server.on("message", function ok(m) {
   if (!/JOIN/.test(m)) {
     return;
   }
   server.removeListener("message", ok);
   m.should.equal(f("JOIN %s %s\r\n", chan.name, key));
 });
Пример #18
0
  describe('client', function() {

    var server = jayson.server.fork(__dirname + '/support/fork', support.options);

    var client = jayson.client.fork(server, {
      reviver: support.options.reviver,
      replacer: support.options.replacer
    });
    
    it('should be an instance of jayson.client', support.clientInstance(client));

    it('should be able to request a success-method on the server', support.clientRequest(client));

    it('should be able to request an error-method on the server', support.clientError(client));

    it('should support reviving and replacing', support.clientReviveReplace(client));

    it('should be able to handle a notification', support.clientNotification(client));

    it('should be able to handle a batch request', support.clientBatch(client));

    after(function() {
      server.kill();
    });

  });
Пример #19
0
 bit("should join a Channel object", function(done) {
   const chan = irc.channel("#joiners");
   chan.client = this;
   server.on("message", function ok(m) {
     if (!/JOIN/.test(m)) {
       return;
     }
     server.removeListener("message", ok);
     m.should.equal(f("JOIN %s\r\n", chan.name));
     done();
   });
   chan.join();
   server.recite(f(":%s!~a@b.c JOIN %s\r\n", this.user.nick, chan));
   server.recite(f(":card.freenode.net 353 %s @ %s :%s nlogax\r\n",
     this.user.nick, chan, this.user.nick));
 });
Пример #20
0
 bit("should disconnect and end the socket", function(done) {
   var bot = this;
   server.on("end", function ok() {
     server.removeListener("message", ok);
     bot.connect(function() { done() });
   });
   this.quit();
 });
Пример #21
0
 server.on("message", function ok(m) {
   if (!/PRIVMSG gf3/.test(m)) {
     return;
   }
   server.removeListener("message", ok);
   m.should.equal("PRIVMSG gf3 :Is these a bug?\r\n");
   done();
 });
Пример #22
0
 server.on("message", function ok(m) {
   if (!/KICK/.test(m)) {
     return;
   }
   server.removeListener("message", ok);
   m.should.equal(f("KICK %s %s\r\n", chan.name, prsn.nick));
   done();
 });
Пример #23
0
 server.on("message", function ok(m) {
   if (!/NOTICE/.test(m)) {
     return;
   }
   server.removeListener("message", ok);
   m.should.equal(f("NOTICE %s :%s\r\n", chan, notice));
   done();
 });
Пример #24
0
 server.on("message", function ok(m) {
   if (!/PRIVMSG #nlogax/.test(m)) {
     return;
   }
   server.removeListener("message", ok);
   m.should.equal("PRIVMSG #nlogax :Message, send thyself\r\n");
   done();
 });
Пример #25
0
 server.on("message", function ok(m) {
   if (!/INVITE/.test(m)) {
     return;
   }
   server.removeListener("message", ok);
   m.should.equal(f("INVITE %s %s\r\n", user.nick, chan));
   done();
 });
Пример #26
0
 bit("should invite people by name", function(done) {
   const chan = irc.channel("#peoplewithnames");
   const user = "******";
   chan.client = this;
   server.on("message", function ok(m) {
     if (!/INVITE/.test(m)) {
       return;
     }
     server.removeListener("message", ok);
     m.should.equal(f("INVITE %s %s\r\n", user, chan));
     done();
   });
   server.recite(f(":%s!~a@b.c JOIN %s\r\n", this.user.nick, chan));
   server.recite(f(":card.freenode.net 353 %s @ %s :%s nlogax\r\n",
     this.user.nick, chan, this.user.nick));
   chan.invite(user);
 });
Пример #27
0
 server.on("message", function ok(m) {
   if (!/PRIVMSG/.test(m)) {
     return;
   }
   server.removeListener("message", ok);
   m.should.equal("PRIVMSG #asl :Sending stuff\r\n");
   done();
 });
Пример #28
0
 setTimeout(function() {
   bot.channels.has(irc.id("#kickedfrom")).should.equal(true);
   server.recite(f(":kicky@kick.com KICK #lol,%s @other,%s,+another\r\n", chan.name, bot.user.nick));
   setTimeout(function() {
     bot.channels.has(irc.id("#kickedfrom")).should.equal(false);
     done();
   }, 10);
 }, 10);
Пример #29
0
 server.on("message", function ok(m) {
   if (!/QUIT/.test(m)) {
     return;
   }
   m.should.equal("QUIT\r\n");
   bot.connect(function() { done() });
   server.removeListener("message", ok);
 });
Пример #30
0
 server.on("message", function ok(m) {
   if (!/MODE/.test(m)) {
     return;
   }
   server.removeListener("message", ok);
   m.should.equal(f("MODE %s -o\r\n", bot.user.nick));
   done();
 });