示例#1
0
func newActionJOIN(srv *string, channel *string) *api.Action {
	result := new(api.Action)
	result.Server = *srv
	result.Channel = *channel
	result.Type = api.A_JOIN
	return result
}
示例#2
0
func newActionPART(srv *string, channel *string, msg *string) *api.Action {
	result := new(api.Action)
	result.Server = *srv
	result.Channel = *channel
	if msg != nil {
		result.Data = *msg
	}
	result.Type = api.A_PART
	return result
}
示例#3
0
func newActionKICK(srv *string, channel *string, user *string, msg *string) *api.Action {
	result := new(api.Action)
	result.Server = *srv
	result.Channel = *channel
	result.User = *user
	if msg != nil {
		result.Data = *msg
	}
	result.Type = api.A_KICK
	return result
}
示例#4
0
func newActionPRIVMSG(srv *string, channel *string, msg *string) *api.Action {
	result := new(api.Action)
	result.Server = *srv
	if strings.Index(*channel, "#") == 0 {
		result.Channel = *channel
	} else {
		result.User = *channel
	}
	result.Data = *msg
	result.Type = api.A_SAY
	return result
}
示例#5
0
// creates a new api.action from what was sent on the admin port
func netAdminCraftAction(output string) api.Action {
	var a api.Action
	shellapi := strings.SplitN(output, " ", 3)
	a.Type = api.A_RAW
	if len(shellapi) == 3 {
		a.Server = shellapi[0]
		a.Priority, _ = strconv.Atoi(shellapi[1])
		if a.Priority != api.PRIORITY_LOW &&
			a.Priority != api.PRIORITY_MEDIUM &&
			a.Priority != api.PRIORITY_HIGH {
			a.Priority = api.PRIORITY_LOW
		}
		a.Data = shellapi[2]
	} else {
		a.Data = output
		a.Priority = api.PRIORITY_LOW
	}
	return a
}