Update repository
This commit is contained in:
parent
e5a935a85b
commit
df2a986286
7 changed files with 35 additions and 24 deletions
29
bot.go
29
bot.go
|
|
@ -18,23 +18,22 @@ func sendmsg (conn net.Conn, channel string, msg string) {
|
|||
conn.Write([]byte(mesg))
|
||||
}
|
||||
|
||||
func scanline_privmsg (msg string) irc_msg {
|
||||
var irc irc_msg
|
||||
func scanline_privmsg (msg string, irc *irc_msg) {
|
||||
LOG_ERR.Printf(msg)
|
||||
|
||||
msg = msg[1:]
|
||||
t := strings.Split(msg, "!")
|
||||
irc.author, irc.channel = t[0], t[1]
|
||||
t = strings.Split(irc.channel, "PRIVMSG ")
|
||||
irc.channel = t[1]
|
||||
t = strings.Split(irc.channel, " :")
|
||||
irc.channel, irc.msg = t[0], t[1]
|
||||
t = strings.Split(irc.msg, "\r\n")
|
||||
irc.msg = strings.TrimSpace(t[0])
|
||||
if ! strings.HasPrefix(irc.channel, "#") {
|
||||
irc.channel = irc.author
|
||||
(*irc).author, (*irc).channel = t[0], t[1]
|
||||
t = strings.Split((*irc).channel, "PRIVMSG ")
|
||||
(*irc).channel = t[1]
|
||||
t = strings.Split((*irc).channel, " :")
|
||||
(*irc).channel, (*irc).msg = t[0], t[1]
|
||||
t = strings.Split((*irc).msg, "\r\n")
|
||||
(*irc).msg = strings.TrimSpace(t[0])
|
||||
if ! strings.HasPrefix((*irc).channel, "#") {
|
||||
(*irc).channel = (*irc).author
|
||||
}
|
||||
irc.retmsg = ""
|
||||
return irc
|
||||
(*irc).retmsg = ""
|
||||
}
|
||||
|
||||
func bot_connect(bot *bot) {
|
||||
|
|
@ -113,7 +112,9 @@ func bot_listen(bot *bot) <-chan string {
|
|||
time.Sleep(10 * time.Second)
|
||||
bot_register(bot)
|
||||
} else if strings.Contains(line, "PRIVMSG") {
|
||||
msg := scanline_privmsg(line)
|
||||
var msg irc_msg
|
||||
scanline_privmsg(line, &msg)
|
||||
LOG_ERR.Printf(msg.author)
|
||||
parsemsg(&msg, (*bot))
|
||||
if msg.retmsg != "" {
|
||||
sendmsg((*bot).conn, msg.channel, msg.retmsg)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue