irclog: move common function to lib.go

Signed-off-by: Boqun Feng <boqun.feng@gmail.com>