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


Golang Line.Copy方法代码示例

本文整理汇总了Golang中github.com/fluffle/sp0rkle/sp0rkle/base.Line.Copy方法的典型用法代码示例。如果您正苦于以下问题:Golang Line.Copy方法的具体用法?Golang Line.Copy怎么用?Golang Line.Copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/fluffle/sp0rkle/sp0rkle/base.Line的用法示例。


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

示例1: ud_privmsg

func ud_privmsg(bot *bot.Sp0rkle, line *base.Line) {
	ud := bot.GetDriver(driverName).(*urlDriver)

	// If we're not being addressed directly, short-circuit to scan.
	if !line.Addressed {
		ud_scan(bot, ud, line)
		return
	}

	nl := line.Copy()
	switch {
	case util.StripAnyPrefix(&nl.Args[1],
		[]string{"url find ", "urlfind ", "url search ", "urlsearch "}):
		ud_find(bot, ud, nl)
	case util.HasAnyPrefix(nl.Args[1], []string{"random url", "randurl"}):
		nl.Args[1] = ""
		ud_find(bot, ud, nl)
	case util.StripAnyPrefix(&nl.Args[1],
		[]string{"shorten that", "shorten"}):
		ud_shorten(bot, ud, nl)
	case util.StripAnyPrefix(&nl.Args[1],
		[]string{"cache that", "save that", "cache ", "save "}):
		ud_cache(bot, ud, nl)
	default:
		ud_scan(bot, ud, line)
	}
}
开发者ID:b33f,项目名称:sp0rkle,代码行数:27,代码来源:handlers.go

示例2: qd_privmsg

func qd_privmsg(bot *bot.Sp0rkle, line *base.Line) {
	qd := bot.GetDriver(driverName).(*quoteDriver)

	if !line.Addressed {
		return
	}

	nl := line.Copy()
	switch {
	// Quote add: qadd | quote add | add quote
	case util.StripAnyPrefix(&nl.Args[1], []string{"quote add ", "qadd ", "add quote "}):
		qd_add(bot, qd, nl)
	// Quote delete: qdel | quote del | del quote  #?QID
	case util.StripAnyPrefix(&nl.Args[1], []string{"quote del ", "qdel ", "del quote "}):
		// Strip optional # before qid
		if nl.Args[1][0] == '#' {
			nl.Args[1] = nl.Args[1][1:]
		}
		qd_delete(bot, qd, nl)
	// Quote lookup: quote #QID
	case util.StripAnyPrefix(&nl.Args[1], []string{"quote #"}):
		qd_fetch(bot, qd, nl)
	// Quote lookup: quote | quote regex
	case strings.ToLower(nl.Args[1]) == "quote":
		nl.Args[1] = ""
		fallthrough
	// This needs to come after the other cases as it will strip just "quote "
	case util.StripAnyPrefix(&nl.Args[1], []string{"quote "}):
		qd_lookup(bot, qd, nl)
	}
}
开发者ID:b33f,项目名称:sp0rkle,代码行数:31,代码来源:handlers.go

示例3: fd_privmsg

func fd_privmsg(bot *bot.Sp0rkle, line *base.Line) {
	fd := bot.GetDriver(driverName).(*factoidDriver)

	// If we're not being addressed directly, short-circuit to lookup.
	if !line.Addressed {
		fd_lookup(bot, fd, line)
		return
	}

	nl := line.Copy()
	// Test for various possible courses of action.
	switch {
	// Factoid add: 'key := value' or 'key :is value'
	case util.ContainsAny(nl.Args[1], []string{":=", ":is"}):
		fd_add(bot, fd, nl)

	// Factoid delete: 'forget|delete that' => deletes fd.lastseen[chan]
	case util.HasAnyPrefix(nl.Args[1], []string{"forget that", "delete that"}):
		fd_delete(bot, fd, nl)

	// Factoid replace: 'replace that with' => updates fd.lastseen[chan]
	case util.StripAnyPrefix(&nl.Args[1], []string{"replace that with "}):
		fd_replace(bot, fd, nl)

	// Factoid chance: 'chance of that is' => sets chance of fd.lastseen[chan]
	case util.StripAnyPrefix(&nl.Args[1], []string{"chance of that is "}):
		fd_chance(bot, fd, nl)

	// Factoid literal: 'literal key' => info about factoid
	case util.StripAnyPrefix(&nl.Args[1], []string{"literal "}):
		fd_literal(bot, fd, nl)

	// Factoid search: 'fact search regexp' => list of possible key matches
	case util.StripAnyPrefix(&nl.Args[1], []string{"fact search "}):
		fd_search(bot, fd, nl)

	// Factoid info: 'fact info key' => some information about key
	case util.StripAnyPrefix(&nl.Args[1], []string{"fact info "}):
		fd_info(bot, fd, nl)

	// If we get to here, none of the other FD command possibilities
	// have matched, so try a lookup...
	default:
		fd_lookup(bot, fd, nl)
	}
}
开发者ID:b33f,项目名称:sp0rkle,代码行数:46,代码来源:handlers.go


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