3 Commits
5 changed files with 36 additions and 3 deletions
Generated
+1 -1
View File
@@ -10,7 +10,7 @@
"isupport", "isupport",
"list" "list"
] ]
revision = "c1e97eb9d2e383147662ddd649fcab1bdaf295b4" revision = "7233516f87eaa81dbf5772aeefa229ddb4aa8330"
[[projects]] [[projects]]
name = "github.com/dgrijalva/jwt-go" name = "github.com/dgrijalva/jwt-go"
+22 -2
View File
@@ -85,8 +85,6 @@ func (channel *Channel) loop() {
select { select {
case post := <-channel.ch: case post := <-channel.ch:
{ {
log.Printf("Received %s post from %s", post.Kind, post.Nick)
// Handle bot commands, or add to queue otherwise. // Handle bot commands, or add to queue otherwise.
if cmd := post.botCommand(); cmd != nil { if cmd := post.botCommand(); cmd != nil {
switch cmd.Verb { switch cmd.Verb {
@@ -128,6 +126,25 @@ func (channel *Channel) loop() {
log.Println("Could not set event name:", err) log.Println("Could not set event name:", err)
} }
} }
case "register":
{
target := channel.client.Channel(channel.name)
if target != nil {
me, ok := target.UserList().User(channel.client.Nick())
if !ok || !strings.ContainsRune(me.Modes, 'o') {
channel.client.Say(channel.name, "This unit require operator privileges to serve this request.")
break
}
chanServNick := config.Get().Names.ChanServ
if chanServNick == "" {
channel.client.Say(channel.name, "This function is not enabled.")
break
}
channel.client.Sayf(chanServNick, "REGISTER %s", target.Name())
}
}
} }
} else { } else {
queue = append(queue, post) queue = append(queue, post)
@@ -137,6 +154,9 @@ func (channel *Channel) loop() {
} }
} }
// Posts after here aren't going to be bot commands, so log its reception.
log.Printf("Received %s post from %s", post.Kind, post.Nick)
// Stop here if there's nothing to post. // Stop here if there's nothing to post.
if len(queue) == 0 { if len(queue) == 0 {
break break
+6
View File
@@ -96,6 +96,12 @@ func handler(event *irc.Event, client *irc.Client) {
text = util.RemoveNPCAttribution(event.Text) text = util.RemoveNPCAttribution(event.Text)
} }
// Do not dispatch empty messages.
if len(text) < 1 || len(nick) < 1 || len(kind) < 1 {
log.Println("Ignoring empty message from:", event.Nick)
break
}
// Dispatch it. // Dispatch it.
bot.handlePost(channel.Name(), ChannelPost{ bot.handlePost(channel.Name(), ChannelPost{
Account: account, Account: account,
+3
View File
@@ -29,6 +29,9 @@ type Config struct {
Commands struct { Commands struct {
OnJoinOp []string `json:"onJoinOp"` OnJoinOp []string `json:"onJoinOp"`
OnReady []string `json:"onReady"` OnReady []string `json:"onReady"`
} `json:"commands"`
Names struct {
ChanServ string `json:"chanserv"`
} }
} }
+4
View File
@@ -28,6 +28,10 @@ func TestRemoveNPCAttribution(t *testing.T) {
Input: "((*Correction))", Input: "((*Correction))",
Output: "((*Correction))", Output: "((*Correction))",
}, },
{
Input: "((Remove :01 goofs!*))",
Output: "((Remove :01 goofs!*))",
},
} }
for i, row := range table { for i, row := range table {