kunt

golang IRC bot
git clone git://git.2f30.org/kunt
Log | Files | Refs | LICENSE

commit c98ea3fe405e9c30d673aa40f9d22bd910dcf249
parent ee1225ee1e1bb6c180db252f3f1b5eda8aa78064
Author: sin <sin@2f30.org>
Date:   Sun, 21 Apr 2013 14:36:12 +0100

Update fsdb init function - remove unnecessary newlines from
!randquote and !randcmd

Diffstat:
Msrc/fsdb/fsdb.go | 14+++++++-------
Msrc/kunt/kunt.go | 4+++-
2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/fsdb/fsdb.go b/src/fsdb/fsdb.go @@ -24,13 +24,13 @@ type Fsdb struct { } func NewFsdb(name string, path string, prefix string) *Fsdb { - d := new(Fsdb) - d.dbMap = make(map[int][]byte) - d.name = name - d.path = path - d.prefix = prefix - d.lastKey = -1 - return d + return &Fsdb{ + name: name, + path: path, + prefix: prefix, + dbMap: make(map[int][]byte), + lastKey: -1, + } } func (d *Fsdb) FsRead(quote int) ([]byte, error) { diff --git a/src/kunt/kunt.go b/src/kunt/kunt.go @@ -102,8 +102,9 @@ func cmdRandQuote(msg irc.IrcMessage) { return } quote, idx := quoteDb.Rand() + quote = []byte(strings.TrimSpace(string(quote))) // Print idx in red - text := fmt.Sprintf("%s%02d[%d]%s %s\r\n", + text := fmt.Sprintf("%s%02d[%d]%s %s", "\003", '5', idx, "\003", string(quote)) kunt.ircCtx.SendPrivmsg(msg.Params[0], text) } @@ -141,6 +142,7 @@ func cmdRandUrl(msg irc.IrcMessage) { return } url, idx := urlDb.Rand() + url = []byte(strings.TrimSpace(string(url))) // Print idx in red r := fmt.Sprintf("%s%02d[%d]%s %s", "\003", '5', idx, "\003", string(url))