mirror of
https://github.com/gissleh/irc.git
synced 2026-10-15 17:42:53 +00:00
Fixed /m and /npc(a)c handlers, added SendRate to client config, added more testing.
This commit is contained in:
+11
-9
@@ -12,6 +12,8 @@ func Input(event *irc.Event, client *irc.Client) {
|
||||
// /msg sends an action to a target specified before the message.
|
||||
case "input.msg":
|
||||
{
|
||||
event.Kill()
|
||||
|
||||
targetName, text := ircutil.ParseArgAndText(event.Text)
|
||||
if targetName == "" || text == "" {
|
||||
client.EmitNonBlocking(irc.NewErrorEvent("input", "Usage: /msg <target> <text...>"))
|
||||
@@ -23,13 +25,13 @@ func Input(event *irc.Event, client *irc.Client) {
|
||||
for _, cut := range cuts {
|
||||
client.Sendf("PRIVMSG %s :%s", targetName, cut)
|
||||
}
|
||||
|
||||
event.Kill()
|
||||
}
|
||||
|
||||
// /text (or text without a command) sends a message to the target.
|
||||
case "input.text":
|
||||
{
|
||||
event.Kill()
|
||||
|
||||
if event.Text == "" {
|
||||
client.EmitNonBlocking(irc.NewErrorEvent("input", "Usage: /text <text...>"))
|
||||
break
|
||||
@@ -46,13 +48,13 @@ func Input(event *irc.Event, client *irc.Client) {
|
||||
for _, cut := range cuts {
|
||||
client.SendQueuedf("PRIVMSG %s :%s", target.Name(), cut)
|
||||
}
|
||||
|
||||
event.Kill()
|
||||
}
|
||||
|
||||
// /me and /action sends a CTCP ACTION.
|
||||
case "input.me", "input.action":
|
||||
{
|
||||
event.Kill()
|
||||
|
||||
if event.Text == "" {
|
||||
client.EmitNonBlocking(irc.NewErrorEvent("input", "Usage: /me <text...>"))
|
||||
break
|
||||
@@ -69,13 +71,13 @@ func Input(event *irc.Event, client *irc.Client) {
|
||||
for _, cut := range cuts {
|
||||
client.SendCTCP("ACTION", target.Name(), false, cut)
|
||||
}
|
||||
|
||||
event.Kill()
|
||||
}
|
||||
|
||||
// /describe sends an action to a target specified before the message, like /msg.
|
||||
case "input.describe":
|
||||
{
|
||||
event.Kill()
|
||||
|
||||
targetName, text := ircutil.ParseArgAndText(event.Text)
|
||||
if targetName == "" || text == "" {
|
||||
client.EmitNonBlocking(irc.NewErrorEvent("input", "Usage: /describe <target> <text...>"))
|
||||
@@ -87,20 +89,20 @@ func Input(event *irc.Event, client *irc.Client) {
|
||||
for _, cut := range cuts {
|
||||
client.SendCTCP("ACTION", targetName, false, cut)
|
||||
}
|
||||
|
||||
event.Kill()
|
||||
}
|
||||
|
||||
// /m is a shorthand for /mode that targets the current channel
|
||||
case "input.m":
|
||||
{
|
||||
event.Kill()
|
||||
|
||||
if event.Text == "" {
|
||||
client.EmitNonBlocking(irc.NewErrorEvent("input", "Usage: /m <text...>"))
|
||||
break
|
||||
}
|
||||
|
||||
channel := event.ChannelTarget()
|
||||
if channel != nil {
|
||||
if channel == nil {
|
||||
client.EmitNonBlocking(irc.NewErrorEvent("input", "Target is not a channel"))
|
||||
break
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ func MRoleplay(event *irc.Event, client *irc.Client) {
|
||||
}
|
||||
|
||||
overhead := ircutil.MessageOverhead("\x1f"+nick+"\x1f", client.Nick(), "npc.fakeuser.invalid", channel.Name(), isAction)
|
||||
cuts := ircutil.CutMessage(event.Text, overhead)
|
||||
cuts := ircutil.CutMessage(text, overhead)
|
||||
|
||||
for _, cut := range cuts {
|
||||
npcCommand := "NPCA"
|
||||
@@ -57,7 +57,7 @@ func MRoleplay(event *irc.Event, client *irc.Client) {
|
||||
npcCommand = "NPC"
|
||||
}
|
||||
|
||||
client.SendQueuedf("%s %s :%s", npcCommand, channel.Name(), cut)
|
||||
client.SendQueuedf("%s %s %s :%s", npcCommand, channel.Name(), nick, cut)
|
||||
}
|
||||
|
||||
event.Kill()
|
||||
|
||||
Reference in New Issue
Block a user