[go: up one dir, main page]

Skip to content

JILeXanDR/skypebot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SKYPE BOT

Example

See working example in example.go. Just set before the following env variables:

  • SKYPE_APP_ID // bot id
  • SKYPE_APP_SECRET // bot token
  • PORT // web server port (used for hook)

How to find bot app credentials?

Features

  • send text messages
  • receive text messages (setting of webhook is required)
  • receive conversation events (setting of webhook is required)

TODO

  • tests
  • refactoring
  • add command handler
  • send/receive attachments

Example

package main

import (
	"fmt"
	"log"
	"net/http"
	"os"
	"testing"

	"github.com/JILeXanDR/skypebot/bot"
	"github.com/JILeXanDR/skypebot/bot/message"
)

func main() {
	b := bot.New(bot.Config{
		AppID:     os.Getenv("SKYPE_APP_ID"),
		AppSecret: os.Getenv("SKYPE_APP_SECRET"),
		Logger:    log.New(os.Stdout, "", 0),
	})

	b.On(bot.EventMessage, func(activity *bot.Activity) {
		b.Send(activity, message.TextMessage(fmt.Sprintf(`Ваше сообщение "%s."`, activity.Text())))
	})

	b.On(bot.Command("ping"), func(activity *bot.Activity) {
		b.Send(activity, message.TextMessage("pong"))
	})

	b.On(bot.EventAddedToContacts, func(activity *bot.Activity) {
		b.Send(activity, message.TextMessage("привет! спасибо что добавил!"))
	})

	if err := b.Run(); err != nil {
		log.Fatal(err)
	}

	http.HandleFunc("/hook", b.WebHookHandler())

	log.Fatal(http.ListenAndServe(":"+os.Getenv("PORT"), nil))
}

About

Skype bot client written in Golang

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages