github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/service/bot.go (about)

     1  package service
     2  
     3  import (
     4  	"context"
     5  	bot "github.com/keybase/client/go/bot"
     6  	"github.com/keybase/client/go/libkb"
     7  	keybase1 "github.com/keybase/client/go/protocol/keybase1"
     8  	"github.com/keybase/go-framed-msgpack-rpc/rpc"
     9  )
    10  
    11  type BotHandler struct {
    12  	*BaseHandler
    13  	libkb.Contextified
    14  }
    15  
    16  func NewBotHandler(xp rpc.Transporter, g *libkb.GlobalContext) *BotHandler {
    17  	return &BotHandler{
    18  		BaseHandler:  NewBaseHandler(g, xp),
    19  		Contextified: libkb.NewContextified(g),
    20  	}
    21  }
    22  
    23  func (h *BotHandler) BotTokenList(ctx context.Context) (res []keybase1.BotTokenInfo, err error) {
    24  	mctx := libkb.NewMetaContext(ctx, h.G()).WithLogTag("BOT")
    25  	return bot.ListTokens(mctx)
    26  }
    27  
    28  func (h *BotHandler) BotTokenCreate(ctx context.Context) (res keybase1.BotToken, err error) {
    29  	mctx := libkb.NewMetaContext(ctx, h.G()).WithLogTag("BOT")
    30  	return bot.CreateToken(mctx)
    31  }
    32  
    33  func (h *BotHandler) BotTokenDelete(ctx context.Context, tok keybase1.BotToken) (err error) {
    34  	mctx := libkb.NewMetaContext(ctx, h.G()).WithLogTag("BOT")
    35  	return bot.DeleteToken(mctx, tok)
    36  }