当前位置: 首页>>代码示例>>Golang>>正文


Golang irc.ParseMessage函数代码示例

本文整理汇总了Golang中github.com/sorcix/irc.ParseMessage函数的典型用法代码示例。如果您正苦于以下问题:Golang ParseMessage函数的具体用法?Golang ParseMessage怎么用?Golang ParseMessage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ParseMessage函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: TestRequestReceivers

func TestRequestReceivers(t *testing.T) {
	success := []struct {
		msg *irc.Message
		rec []string
	}{
		{
			msg: irc.ParseMessage(":Angel PRIVMSG user1, user2 :example message"),
			rec: []string{"Angel"},
		},
		{
			msg: irc.ParseMessage(":Angel PRIVMSG #general :example message"),
			rec: []string{"#general"},
		},
		{
			msg: irc.ParseMessage(":Angel PRIVMSG #general , #privatechannel :example message"),
			rec: []string{"#general", "#privatechannel"},
		},
	}

	for _, args := range success {
		req := &relay.Request{Message: args.msg}
		rec := req.Receivers()

		assert.Equal(t, args.rec, rec)
	}
}
开发者ID:piotrkowalczuk,项目名称:relay,代码行数:26,代码来源:request_test.go

示例2: Raw

func Raw(s ircx.Sender, m *irc.Message, message string) {
	if !isOwner(s, m.Name) {
		return
	}
	log.Printf("RAW: %s\n%+v", message, irc.ParseMessage(message))
	messages.QueueMessages(s, irc.ParseMessage(message))
}
开发者ID:cosban,项目名称:muggy,代码行数:7,代码来源:raw.go

示例3: TestServerQuit

func TestServerQuit(t *testing.T) {
	i, ids := stdIRCServerWithServices()

	i.ProcessMessage(types.RobustId{}, ids["services"], irc.ParseMessage(":services.robustirc.net NICK blorgh 1 1425542735 enforcer services.robustirc.net services.robustirc.net 0 :Services Enforcer"))

	mustMatchMsg(t,
		i.ProcessMessage(types.RobustId{}, ids["services"], irc.ParseMessage(":blorgh QUIT")),
		":[email protected]/0x13c6cdee3e749faf QUIT :")
}
开发者ID:aftran,项目名称:robustirc,代码行数:9,代码来源:server_commands_test.go

示例4: relevantNick

func relevantNick(msg *irc.Message, prev, next logCursor, reset logReset) (bool, error) {
	if len(msg.Params) < 1 {
		return false, nil
	}

	last, err := isLastMessage(prev, next, reset)
	if err != nil {
		return true, err
	}
	if last {
		return false, nil
	}

	// Forever retain the first NICK message so that the connection is logged in.
	earliestNick := true
	for {
		rmsg, err := prev(types.RobustIRCFromClient)
		if err != nil {
			if err == CursorEOF {
				break
			}
			return true, err
		}
		nmsg := irc.ParseMessage(rmsg.Data)
		if strings.ToUpper(nmsg.Command) == irc.NICK {
			earliestNick = false
		}
	}

	if earliestNick {
		return true, err
	}

	reset()

	for {
		rmsg, err := next(types.RobustIRCFromClient)
		if err != nil {
			if err == CursorEOF {
				break
			}
			return true, err
		}
		nmsg := irc.ParseMessage(rmsg.Data)
		// TOPIC relies on the NICK.
		if nmsg.Command == irc.TOPIC {
			return true, nil
		}
		// There is a newer NICK command, so discard this one.
		if nmsg.Command == irc.NICK {
			return false, nil
		}
	}

	return true, nil
}
开发者ID:dopuskh3,项目名称:robustirc,代码行数:56,代码来源:commands.go

示例5: TestServerInvite

func TestServerInvite(t *testing.T) {
	i, ids := stdIRCServerWithServices()

	i.ProcessMessage(types.RobustId{}, ids["secure"], irc.ParseMessage("JOIN #test"))

	mustMatchIrcmsgs(t,
		i.ProcessMessage(types.RobustId{}, ids["services"], irc.ParseMessage(":ChanServ INVITE mero #test")),
		[]*irc.Message{
			irc.ParseMessage(":robustirc.net 341 ChanServ mero #test"),
			irc.ParseMessage(":[email protected] INVITE mero :#test"),
			irc.ParseMessage(":robustirc.net NOTICE #test :ChanServ invited mero into the channel."),
		})

	mustMatchMsg(t,
		i.ProcessMessage(types.RobustId{}, ids["services"], irc.ParseMessage(":ChanServ INVITE moro #test")),
		":robustirc.net 401 ChanServ moro :No such nick/channel")

	i.ProcessMessage(types.RobustId{}, ids["mero"], irc.ParseMessage("JOIN #test"))

	mustMatchMsg(t,
		i.ProcessMessage(types.RobustId{}, ids["services"], irc.ParseMessage(":ChanServ INVITE mero #test")),
		":robustirc.net 443 ChanServ mero #test :is already on channel")

	mustMatchMsg(t,
		i.ProcessMessage(types.RobustId{}, ids["services"], irc.ParseMessage(":ChanServ INVITE mero #toast")),
		":robustirc.net 403 ChanServ #toast :No such channel")
}
开发者ID:aftran,项目名称:robustirc,代码行数:27,代码来源:server_commands_test.go

示例6: stdIRCServerWithServices

func stdIRCServerWithServices() (*IRCServer, map[string]types.RobustId) {
	i, ids := stdIRCServer()
	i.Config.IRC.Services = append(i.Config.IRC.Services, config.Service{
		Password: "mypass",
	})
	ids["services"] = types.RobustId{Id: 0x13c6cdee3e749faf}
	i.CreateSession(ids["services"], "auth-server")
	i.ProcessMessage(types.RobustId{}, ids["services"], irc.ParseMessage("PASS :services=mypass"))
	i.ProcessMessage(types.RobustId{}, ids["services"], irc.ParseMessage("SERVER services.robustirc.net 1 :Services for IRC Networks"))
	return i, ids
}
开发者ID:aftran,项目名称:robustirc,代码行数:11,代码来源:server_commands_test.go

示例7: TestServerPrivmsg

func TestServerPrivmsg(t *testing.T) {
	i, ids := stdIRCServerWithServices()

	i.ProcessMessage(types.RobustId{}, ids["secure"], irc.ParseMessage("JOIN #test"))

	mustMatchMsg(t,
		i.ProcessMessage(types.RobustId{}, ids["services"], irc.ParseMessage(":ChanServ PRIVMSG secure :ohai")),
		":[email protected] PRIVMSG secure :ohai")

	mustMatchMsg(t,
		i.ProcessMessage(types.RobustId{}, ids["services"], irc.ParseMessage(":ChanServ PRIVMSG socoro :ohai")),
		":robustirc.net 401 ChanServ socoro :No such nick/channel")

	mustMatchMsg(t,
		i.ProcessMessage(types.RobustId{}, ids["services"], irc.ParseMessage(":ChanServ PRIVMSG #test :ohai")),
		":[email protected] PRIVMSG #test :ohai")

	mustMatchMsg(t,
		i.ProcessMessage(types.RobustId{}, ids["services"], irc.ParseMessage(":ChanServ PRIVMSG")),
		":robustirc.net 411 ChanServ :No recipient given (PRIVMSG)")

	mustMatchMsg(t,
		i.ProcessMessage(types.RobustId{}, ids["services"], irc.ParseMessage(":ChanServ PRIVMSG #test")),
		":robustirc.net 412 ChanServ :No text to send")

	mustMatchMsg(t,
		i.ProcessMessage(types.RobustId{}, ids["services"], irc.ParseMessage(":ChanServ PRIVMSG #toast :a")),
		":robustirc.net 403 ChanServ #toast :No such channel")

	mustMatchMsg(t,
		i.ProcessMessage(types.RobustId{}, ids["services"], irc.ParseMessage(":ChanServ NOTICE")),
		":robustirc.net 411 ChanServ :No recipient given (NOTICE)")
}
开发者ID:aftran,项目名称:robustirc,代码行数:33,代码来源:server_commands_test.go

示例8: TestServerSvsmode

func TestServerSvsmode(t *testing.T) {
	i, ids := stdIRCServerWithServices()

	mustMatchMsg(t,
		i.ProcessMessage(types.RobustId{}, ids["secure"], irc.ParseMessage("MODE secure")),
		":[email protected]/0x13b5aa0a2bcfb8ad MODE sECuRE :+")

	mustMatchMsg(t,
		i.ProcessMessage(types.RobustId{}, ids["services"], irc.ParseMessage("SVSMODE secure +r")),
		":services.robustirc.net MODE sECuRE :+r")

	mustMatchMsg(t,
		i.ProcessMessage(types.RobustId{}, ids["services"], irc.ParseMessage("SVSMODE socoro +r")),
		":robustirc.net 401 * socoro :No such nick/channel")

	mustMatchIrcmsgs(t,
		i.ProcessMessage(types.RobustId{}, ids["services"], irc.ParseMessage("SVSMODE secure +rq")),
		[]*irc.Message{
			irc.ParseMessage(":robustirc.net 501 * :Unknown MODE flag"),
			irc.ParseMessage(":services.robustirc.net MODE sECuRE :+r"),
		})

	mustMatchMsg(t,
		i.ProcessMessage(types.RobustId{}, ids["services"], irc.ParseMessage("SVSMODE secure +d-r")),
		":services.robustirc.net MODE sECuRE :+")

	mustMatchMsg(t,
		i.ProcessMessage(types.RobustId{}, ids["services"], irc.ParseMessage("SVSMODE secure d-r")),
		":robustirc.net 501 * :Unknown MODE flag")
}
开发者ID:aftran,项目名称:robustirc,代码行数:30,代码来源:server_commands_test.go

示例9: relevantUser

func relevantUser(msg *irc.Message, prev, next logCursor, reset logReset) (bool, error) {
	if len(msg.Params) < 1 {
		return false, nil
	}

	// This is the first USER message. If the next message is a QUIT message,
	// this session cannot have modified any state.
	rmsg, err := next(types.RobustAny)
	if err == nil && isDeleteSession(rmsg) {
		return false, nil
	}
	prev(types.RobustAny)

	for {
		rmsg, err := prev(types.RobustIRCFromClient)
		if err != nil {
			if err == CursorEOF {
				break
			}
			return true, err
		}
		pmsg := irc.ParseMessage(rmsg.Data)
		// There already was a USER message, so discard this one.
		if pmsg.Command == irc.USER {
			return false, nil
		}
	}

	return true, nil
}
开发者ID:dopuskh3,项目名称:robustirc,代码行数:30,代码来源:commands.go

示例10: relevantJoin

func relevantJoin(msg *irc.Message, prev, next logCursor, reset logReset) (bool, error) {
	if len(msg.Params) < 1 {
		return false, nil
	}

	lcnames := multipleChannels(msg.Params[0])
	for {
		rmsg, err := next(types.RobustIRCFromClient)
		if err != nil {
			if err == CursorEOF {
				break
			}
			return true, err
		}
		nmsg := irc.ParseMessage(rmsg.Data)
		if nmsg.Command == irc.TOPIC &&
			len(nmsg.Params) > 0 &&
			lcnames[ChanToLower(nmsg.Params[0])] {
			return true, nil
		}
		// TODO: support KICK
		if nmsg.Command == irc.PART && len(nmsg.Params) > 0 {
			for channelname := range multipleChannels(nmsg.Params[0]) {
				delete(lcnames, channelname)
			}
			if len(lcnames) == 0 {
				return false, nil
			}
		}
	}

	return true, nil
}
开发者ID:dopuskh3,项目名称:robustirc,代码行数:33,代码来源:commands.go

示例11: Handle

func Handle(input string, DB *neoism.Database) {
	msg := irc.ParseMessage(input)
	if msg == nil {
		fmt.Println("Could not parse message")
	}
	store(msg, DB)
}
开发者ID:MDCox,项目名称:spectator,代码行数:7,代码来源:handle.go

示例12: handleAdmin

func handleAdmin(c *sirc.IConn, m *irc.Message) bool {
	matches := adminRE.FindStringSubmatch(m.Trailing)
	if len(matches) == 0 {
		return false
	}
	adminState.Lock()
	// lifo defer order
	defer adminState.Save()
	defer adminState.Unlock()

	host := strings.TrimSpace(matches[2])
	switch matches[1] {
	case "addadmin":
		admins[host] = struct{}{}
		c.Notice(m, "Added host successfully")
	case "deladmin":
		delete(admins, host)
		c.Notice(m, "Removed host successfully")
	case "raw":
		nm := irc.ParseMessage(matches[2])
		if nm == nil {
			c.Notice(m, "Could not parse, are you sure you know the irc protocol?")
		} else {
			go c.Write(nm)
		}
	}

	return true
}
开发者ID:sztanpet,项目名称:obscommits,代码行数:29,代码来源:irc.go

示例13: TestServerSjoin

func TestServerSjoin(t *testing.T) {
	i, ids := stdIRCServerWithServices()

	mustMatchMsg(t,
		i.ProcessMessage(types.RobustId{}, ids["secure"], irc.ParseMessage("SJOIN 1 #test :ChanServ")),
		":robustirc.net 421 sECuRE SJOIN :Unknown command")
}
开发者ID:aftran,项目名称:robustirc,代码行数:7,代码来源:server_commands_test.go

示例14: TestServerWelcome

func TestServerWelcome(t *testing.T) {
	events := make(chan Event, 10)
	srv := NewServer(testServerName)
	srv.Subscribe(events)
	defer srv.Close()

	send, receive := make(chan *irc.Message, 10), make(chan *irc.Message, 10)
	u := NewUserMock(send, receive)
	go srv.Connect(u)
	receive <- irc.ParseMessage("NICK foo")
	receive <- irc.ParseMessage("USER root 0 * :Foo Bar")
	if msg := <-send; msg.Command != irc.RPL_WELCOME {
		t.Errorf("got %v; want %v", msg, irc.RPL_WELCOME)
	}
	expectEvent(t, events, ConnectEvent)
}
开发者ID:42wim,项目名称:mm-go-irckit,代码行数:16,代码来源:server_test.go

示例15: PrivacyFilterMsg

func PrivacyFilterMsg(message *types.RobustMessage) *types.RobustMessage {
	return &types.RobustMessage{
		Id:      message.Id,
		Session: message.Session,
		Type:    message.Type,
		Data:    PrivacyFilterIrcmsg(irc.ParseMessage(message.Data)).String(),
	}
}
开发者ID:aftran,项目名称:robustirc,代码行数:8,代码来源:util.go


注:本文中的github.com/sorcix/irc.ParseMessage函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。