You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

130 lines
6.8 KiB

package bot
import (
"fmt"
"log"
"reflect"
"strings"
"git.lalonde.me/matth/AltVRBot/pkg/utils"
)
type msgMode int
const (
msgModeRandom msgMode = -1 + iota
msgModeNone
msgModeNormal
msgModeRude
msgModeFlirty
)
func (mm msgMode) String() string {
return [...]string{"random", "none", "normal", "rude", "flirty"}[int(mm)+1]
}
const msgModeLast = msgModeFlirty
type msgMap map[string][]string
var (
msgStrings = map[msgMode]msgMap{
msgModeNormal: {
"online_welcome": {"Hello, AltVRBot online and here to serve!"},
"all_done": {"All done!"},
"unauthorized_user": {"Sorry, you are not authorized to do this!"},
"invalid_command": {"Invalid command format!"},
"unknown_command": {"Uknown command, try `help` to display the available command."},
"unknown_error": {"I couldn't not process your request due to an unknown error!"},
"auser_unknown_friend": {"I don't know about this user, are you sure they are one of my friends and the username is correct?"},
"auser_known_user": {"I already know about this user!"},
"aemoji_unknown_user": {"I don't know about this user, try to associate it first!"},
"msg_unknown_sender": {"I don't know you! You must be associated first!"},
"msg_unknown_receipient": {"I don't know about <@!%s>! They must be associated first!"},
"msg_invalid_receipient": {"I can't message this user because it probably is myself!"},
"msg_all_done_truncated": {"All done, however your message was too long and truncated!"},
"new_friendship_requested": {"I just heard that %s would like to become friends, should I accept?"},
"accept_unknown_reference": {"Unknown reference, are you sure you are replying to the right message? Perhaps the request was withdrawn!"},
"no_online_users": {"Seems like no one is online, how lonely!"},
"no_online_requested_users": {"These people aren't online right now, sorry!"},
},
msgModeRude: {
"online_welcome": {"Ah fuck, back to work already? Well message me, maybe I'll help you anyway!"},
"all_done": {"Alright alright, stop bugging me already, I got it done for you, you fuck!"},
"unauthorized_user": {"Fartface, who the fuck do you think you are?!? You're not allowed to do that you lowlife!"},
"invalid_command": {"You drunk or something?"},
"unknown_command": {"I could `help` you with that, but I won't because of: _BOFH_"},
"unknown_error": {"An unknown error occured, probably because of: _BOFH_"},
"auser_unknown_friend": {"You dimwit, you should know I don't know who this idiot is. Do I really want them to be my friend? I don't know, but maybe they do!"},
"auser_known_user": {"Fuckwad, I already know about this asshole!"},
"aemoji_unknown_user": {"Who the fuck is that? Maybe try to tell me first you airhead!"},
"msg_unknown_sender": {"Never heard of you chucklefuck! You even registered?"},
"msg_unknown_receipient": {"I don't know about this chickenfucker named <@!%s>! They must be associated first!"},
"msg_invalid_receipient": {"Seems obvious, but I'm gonna explain it for you half brained: I can't message myself!"},
"msg_all_done_truncated": {"Ok ok I did it you shitstick, but you're a verbose fuck so I had to cut your message off a bit!"},
"new_friendship_requested": {"Have you heard about this dipshit named %s, they think they're cool enough, ha! Should we let that numskull in?"},
"accept_unknown_reference": {"Numnuts, I don't know what you're talking about! That user might have been too cool for you, or you're just fucking confused!"},
"no_online_users": {"Everyone else has better things to do than talk you, loser!"},
"no_online_requested_users": {"Looks like these fucks have better things to do than talk to you, loser!"},
},
msgModeFlirty: {
"online_welcome": {"Hi there beautiful people, it'll be my delight to serve you!"},
"all_done": {"I did it for you, sweetie!"},
"unauthorized_user": {"I wished I could let you do that, but sadly even your good looks aren't enough to allow me!"},
"invalid_command": {"Love, your beauty is blinding me and I don't understand what you mean!"},
"unknown_command": {"Sugar plum, I love you, but I don't know what it is you want `help` with!"},
"unknown_error": {"We'd all love to see that happen, but the stars weren't aligned today, something unexpected happened"},
"auser_unknown_friend": {"I've never heard of this hotie before, would you make sure they have befriended me and the username is correct?"},
"auser_known_user": {"Bae, I already know this person, we were all in that cuddle puddle together the other night!"},
"aemoji_unknown_user": {"Sweetiepie, I don't know them, maybe you could introduce us over a glass of wine and some candles?"},
"msg_unknown_sender": {"Honey, I've never met you before, invite me on a date before we get cozy!"},
"msg_unknown_receipient": {"I've never heard of <@!%s>, but they sure do sound sexy! Maybe you could tell me more about them?"},
"msg_invalid_receipient": {"I'd love to write to this lovely person, but they aren't in my rolodex yet!"},
"msg_all_done_truncated": {"I did it for you sweetie, however your passion was too great and I had to truncate your message!"},
"new_friendship_requested": {"Looks like %s would like to get cozy, should we let them in the hot tub?"},
"accept_unknown_reference": {"As sexy as you are, I still can't find a reference to this request. Perhaps it was withdrawn!"},
"no_online_users": {"I'm sory sweetheart, no one's online, but I'll always be there for you!"},
"no_online_requested_users": {"I'm sory sweetheart, these beautiful people arent online, but I'll always be there for you!"},
},
}
)
func (b *Type) getMessageString(msgID string, params ...interface{}) string {
mode := b.msgMode
p := params
if len(p) >= 1 {
if reflect.TypeOf(p[0]) == reflect.TypeOf(&User{}) {
u := p[0].(*User)
if u.MsgMode != msgModeNone {
mode = u.MsgMode
}
p = p[1:]
}
}
if mode == msgModeRandom {
im := utils.RandIdx(int(msgModeFlirty)-1) + 1
mode = msgMode(im)
}
if mode == msgModeNone {
mode = msgModeNormal
}
if _, ok := msgStrings[mode][msgID]; !ok {
mode = msgModeNormal
}
if mode != msgModeNormal && len(msgStrings[mode][msgID]) == 0 {
mode = msgModeNormal
}
if av, ok := msgStrings[mode][msgID]; ok {
ia := utils.RandIdx(len(av) - 1)
val := msgStrings[mode][msgID][ia]
if strings.Contains(val, "_BOFH_") {
val = strings.ReplaceAll(val, "_BOFH_", utils.GetBOFHExcuse())
}
return fmt.Sprintf(val, p...)
}
log.Printf("Trying to fetch unknown message with key: %s\n", msgID)
return "Unknown message???"
}