Skip to content

ras0q/traq-chat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

traq-chat

Make creating traQBot easier.

Example

package main

import (
        "fmt"
        "os"
        "regexp"

        traqchat "github.com/ras0q/traq-chat"
)

func main() {
        q := traqchat.New(
                os.Getenv("BOT_ID"),
                os.Getenv("BOT_USER_ID"),
                os.Getenv("BOT_ACCESS_TOKEN"),
                os.Getenv("BOT_VERIFICATION_TOKEN"),
        )

        q.Hear(regexp.MustCompile(`ping`), func(res *traqchat.Response) error {
                res.Send("pong!")

                return nil
        })

        q.Respond(regexp.MustCompile(`Hello`), hello)

        q.Start(80)
}

func hello(res *traqchat.Response) error {
        res.Reply(fmt.Sprintf("Hello, %s\n", res.Message.User.DisplayName))

        return nil
}

More Information for traQ Bot