GithubHelp home page GithubHelp logo

likoo / gotelebot Goto Github PK

View Code? Open in Web Editor NEW

This project forked from eternnoir/gotelebot

0.0 0.0 0.0 648 KB

Home Page: http://godoc.org/github.com/eternnoir/gotelebot

License: GNU General Public License v2.0

Go 100.00%

gotelebot's Introduction

gotelebot

GoDoc

Golang (Go) implementation for the Telegram Bot API.

This project provide a wrapper around the Telegram Bot API with golang. You can easy to ues telegram bot api in golang way by use this project. And gotelebot provided polling method let developer easy to get new messages.

Almost all method in Telegram bot api have been implement. While official telegram bot api update, this project will update as soon as possible.

Installation

go get github.com/eternnoir/gotelebot

Document

Full godoc document http://godoc.org/github.com/eternnoir/gotelebot

Echo Bot Example

package main

import (
	"fmt"
	"github.com/eternnoir/gotelebot"
)

func main() {
	// Echo Bot example.

	// Create gotelebot instance
	bot := gotelebot.InitTeleBot("TOKEN")
	// Start get new message whit goroutine and 60s timeout.
	go bot.StartPolling(true, 60)
	go processNewMessage(bot)
	processNewInlineQuery(bot)
}

func processNewMessage(bot *gotelebot.TeleBot) {
	newMsgChan := bot.Messages
	for {
		m := <-newMsgChan // Get new messaage, when new message arrive.
		fmt.Printf("Get Message:%#v \n", m)
		if m.Text != "" { // Check message is text message.
			bot.SendMessage(int(m.Chat.Id), m.Text, nil)
		}
	}
}

func processNewInlineQuery(bot *gotelebot.TeleBot) {
	newQuery := bot.InlineQuerys
	for {
		q := <-newQuery
		fmt.Printf("Get NewInlineQuery:%#v \n", q)
		if q.Query != "" {	// Only return result when query string not empty.
			result1 := types.NewInlineQueryResultArticl()
			result1.Id = "1"
			result1.Title = "Example"
			result1.MessageText = "Hi" + q.Query
			_, err := bot.AnswerInlineQuery(q.Id, []interface{}{result1}, nil)
			if err != nil {
				fmt.Println(err)
			}
		}
	}
}

Telegram Bot API Support

Methods

Telegram Bot API Method gotelebot Method Status
getMe GetMe Supported
sendMessage SendMessage Supported
forwardMessage ForwardMessage Supported
sendPhoto SendPhoto Supported
sendAudio SendAudio Supported
sendDocument SendDocument Supported
sendSticker SendSticker Supported
sendVideo SendVideo Supported
sendVoice SendVoice Supported
sendLocation SendLocation Supported
sendChatAction SendChatAction Supported
getUserProfilePhotos GetUserProfilePhotos Supported
getUpdates GetUpdates Supported
getFile GetFile Supported
inline mode inline mode Supported

Change Log

2015-10-12

gotelebot's People

Contributors

eternnoir avatar

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.