go fmt
This commit is contained in:
parent
41c1c27b1f
commit
2cd84df2ba
5 changed files with 36 additions and 36 deletions
21
boddle.go
21
boddle.go
|
|
@ -1,12 +1,13 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"database/sql"
|
||||
"math/rand"
|
||||
"fmt"
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
"math/rand"
|
||||
"net"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var begin_char = []byte{'-'}
|
||||
|
|
@ -31,7 +32,7 @@ func filter(msg string, conn net.Conn, db *sql.DB, nickname string) cmd {
|
|||
c.add = false
|
||||
}
|
||||
|
||||
if (strings.Contains(msg, "[") && strings.Contains(msg, "]")) {
|
||||
if strings.Contains(msg, "[") && strings.Contains(msg, "]") {
|
||||
re, _ := regexp.Compile(`\s*(\w*)\s*\[(.+)\]\s*(.*)\s*`)
|
||||
res := re.FindStringSubmatch(msg)
|
||||
if len(res) < 4 {
|
||||
|
|
@ -167,7 +168,7 @@ func checkSorter(db *sql.DB, msg *irc_msg, c *cmd) bool {
|
|||
group_sel, err := db.Prepare("select group_id from sorter_groups where sorter_id = ?")
|
||||
checkErr(err)
|
||||
sorter_groups_row, err := group_sel.Query(sorter_id)
|
||||
//sorter_groups_row, err := db.Query(fmt.Sprintf("select group_id from sorter_groups where sorter_id = '%s'", sorter_id))
|
||||
//sorter_groups_row, err := foo.db.Query(fmt.Sprintf("select group_id from sorter_groups where sorter_id = '%s'", sorter_id))
|
||||
checkErr(err)
|
||||
if sorter_groups_row.Next() {
|
||||
var group_id int
|
||||
|
|
@ -223,7 +224,7 @@ func addLine(db *sql.DB, msg *irc_msg, line string, groups []string, cmd string)
|
|||
LOG_WARN.Printf("added line to table.\n")
|
||||
|
||||
// get ID of content...
|
||||
line_id, err := res.LastInsertId();
|
||||
line_id, err := res.LastInsertId()
|
||||
checkErr(err)
|
||||
|
||||
LOG_WARN.Printf("line_id: %d, tag_id: %s, groups: %s\n", line_id, cmd, strings.Join(groups, "-"))
|
||||
|
|
@ -293,7 +294,7 @@ func parsemsg(msg *irc_msg, conn net.Conn, db *sql.DB, nickname string) bool {
|
|||
}
|
||||
// hard code 'groups' to add new groups to the groups-table
|
||||
if c.add && (c.cmd == "groups" || c.cmd == "group") {
|
||||
if (c.groups != nil) {
|
||||
if c.groups != nil {
|
||||
(*msg).retmsg = "Ignoring groups for the groups-adding. Well, what were you expecting...?"
|
||||
}
|
||||
addgroups(db, strings.Fields((&c).suffix), msg)
|
||||
|
|
@ -308,8 +309,8 @@ func parsemsg(msg *irc_msg, conn net.Conn, db *sql.DB, nickname string) bool {
|
|||
// new line for database
|
||||
if c.add {
|
||||
// if there is nothing to add, just return. :-)
|
||||
if (len(c.suffix) <= 0) {
|
||||
return false;
|
||||
if len(c.suffix) <= 0 {
|
||||
return false
|
||||
}
|
||||
c.suffix = strings.Replace(c.suffix, "\"", "'", -1)
|
||||
sendmsg(conn, "horscchtey", addLine(db, msg, c.suffix, c.groups, c.cmd))
|
||||
|
|
|
|||
11
bot.go
11
bot.go
|
|
@ -1,15 +1,14 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"fmt"
|
||||
"net"
|
||||
"time"
|
||||
"bufio"
|
||||
"strings"
|
||||
"database/sql"
|
||||
configo "github.com/distributedio/configo"
|
||||
"flag"
|
||||
"fmt"
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
"net"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func sendmsg(conn net.Conn, channel string, msg string) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue