Giter Club home page Giter Club logo

go-wechaty-getting-started's Introduction

go-wechaty-getting-started Go Version Go

Go Wechaty

Gitpod Ready-to-Code Go Playground Wechaty in Go

Go Wechaty Starter Project Template that Works Out-of-the-Box

Connecting Chatbots

Powered by Wechaty

Wechaty is a RPA SDK for Wechat Individual Account that can help you create a chatbot in 6 lines of Go.

The World's Shortest Go ChatBot: 7 lines of Code

package main

import (
  "fmt"

  "github.com/wechaty/go-wechaty/wechaty"
)

func main() {
	_ = wechaty.NewWechaty().
		OnScan(func(ctx *wechaty.Context, qrCode string, status schemas.ScanStatus, data string) {
			fmt.Printf("Scan QR Code to login: %s\nhttps://wechaty.github.io/qrcode/%s\n", status, qrCode)
		}).
		OnLogin(func(ctx *wechaty.Context, user *user.ContactSelf) { fmt.Printf("User %s logined\n", user) }).
		OnMessage(func(ctx *wechaty.Context, message *user.Message) { fmt.Printf("Message: %s\n", message) }).
		Start()
}

Requirements

  1. Go 1.14+

Install

make install

Run

Get a Token for your Bot first. Learn more from our Wechaty Developers Program

export WECHATY_PUPPET_SERVICE_TOKEN=your_token_at_here

make bot

Wechaty Getting Started in Multiple Languages

Badge

Wechaty in Go

[![Wechaty in Go](https://img.shields.io/badge/Wechaty-Go-7de)](https://github.com/wechaty/go-wechaty)

Maintainers

@wechaty/go

Copyright & License

  • Code & Docs © 2020 - now Wechaty Contributors https://github.com/wechaty
  • Code released under the Apache-2.0 License
  • Docs released under Creative Commons

go-wechaty-getting-started's People

Contributors

dchaofei avatar dependabot-preview[bot] avatar dingdayu avatar github-actions[bot] avatar huan avatar nebell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

go-wechaty-getting-started's Issues

Let's make this repo to be the easiest way to run a ding-dong-bot.go bot!

This repository is for any Go developers who want to build a chatbot based on our great Go Wechaty library.

It will be a great help for all Go developers if we can make this repository to be able to ready for use by running:

  1. git clone
  2. make install
  3. make bot

Then everything will be set up.

I have set up the skeleton of this repo, with the examples/ding-dong-bot.go, let's finish this repo so that it can be run out-of-the-box! @wechaty/go

Related to: wechaty/wechaty#1927

无法启动

获取不到endpoint

[root@macro go-wechaty-getting-started]# WECHATY_PUPPET_HOSTIE_TOKEN=puppet_padplus_xxxxx go run examples/ding-dong-bot.go
2020/07/01 18:09:45 PuppetHostie Start()
2020/07/01 18:09:46 puppet start err: PuppetHostie Start() rejection: no endpoint
panic: PuppetHostie Start() rejection: no endpoint
goroutine 1 [running]:
main.main()
/tmp/go-wechaty-getting-started/examples/ding-dong-bot.go:45 +0x212
exit status 2

wechaty Puppet Service requires a SNI as prefix of the token

ERRO[2024-01-29 17:42:28.012] w.initPuppet err: wechaty Puppet Service requires a SNI as prefix of the token.
You can add the "insecure_" prefix to your token
like: "insecure_xxx
and try again module=wechaty
panic: wechaty Puppet Service requires a SNI as prefix of the token.
You can add the "insecure_" prefix to your token
like: "insecure_xxx
and try again

Support to use `WECHATY_PUPPET_HOSTIE_TOKEN` to set Token

Currently, we are using a hardcoded Token in our ding-dong-bot.go to specify the hostie token.

It would be better to let the user be able to use the environment variable to archive the same goal.

I'd like to suggest that we can add this support to this project so that the user can use the following shell command to start the bot:

WECHATY_PUPPET_HOSTIE_TOKEN=xxx make bot

Run our ding-dong-bot.go in Go Playground

I have put our beautiful Go Wechaty bot at Go Playground: https://play.golang.org/p/JGw_2TrVQeg

However, when I run it, it shows the following error messages:

go: finding module for package github.com/wechaty/go-wechaty/wechaty-puppet
go: finding module for package github.com/wechaty/go-wechaty/wechaty
go: finding module for package github.com/wechaty/go-wechaty/wechaty/user
go: finding module for package github.com/wechaty/go-wechaty/wechaty-puppet/schemas
go: downloading github.com/wechaty/go-wechaty v0.1.0
prog.go:23:2: module github.com/wechaty/go-wechaty@latest found (v0.1.0), but does not contain package github.com/wechaty/go-wechaty/wechaty
prog.go:24:2: module github.com/wechaty/go-wechaty@latest found (v0.1.0), but does not contain package github.com/wechaty/go-wechaty/wechaty-puppet
prog.go:25:2: module github.com/wechaty/go-wechaty@latest found (v0.1.0), but does not contain package github.com/wechaty/go-wechaty/wechaty-puppet/schemas
prog.go:26:2: module github.com/wechaty/go-wechaty@latest found (v0.1.0), but does not contain package github.com/wechaty/go-wechaty/wechaty/user

Go build failed.

It would be wonderful if we can run our Go Wechaty ding-dong-bot.go directly in this Playground.

Looking forward to finding a way to make it works, because it will be very convenient for the newcomers who want to have a quick try!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.