README.md (view raw)
1# Golang Telegram bot using the Bot API
2A simple Golang bot for the Telegram Bot API
3
4Really simple bot for interacting with the Telegram Bot API, not nearly done yet. Expect frequent breaking changes!
5
6All methods have been added, and all features should be available.
7If you want a feature that hasn't been added yet, open an issue and I'll see what I can do.
8
9There's a few plugins in here, named as `plugin_*.go`.
10
11## Getting started
12
13After installing all the dependencies, run
14
15```
16go build
17./telegram-bot-api -newbot
18```
19
20Fill in any asked information, enable whatever plugins, etc.
21
22## Plugins
23
24All plugins implement the `Plugin` interface.
25
26```go
27type Plugin interface {
28 GetName() string
29 GetCommands() []string
30 GetHelpText() []string
31 GotCommand(string, Message, []string)
32 Setup()
33}
34```
35
36`GetName` should return the plugin's name. This must be unique!
37
38`GetCommands` should return a slice of strings, each command should look like `/help`, it must have the forward slash!
39
40`GetHelpText` should return a slice of strings with each command and usage. You many include any number of items in here.
41
42`GotCommand` is called when a command is executed for this plugin, the parameters are the command name, the Message struct, and a list of arguments passed to the command. The original text is available in the Message struct.
43
44`Setup` is called when the bot first starts, if it needs any configuration, ask here.
45
46To add your plugin, you must edit a line of code and then run the `go build` again.
47
48```go
49// current version
50plugins = []Plugin{&HelpPlugin{}, &ManagePlugin{}}
51
52// add your own plugins
53plugins = []Plugin{&HelpPlugin{}, &FAPlugin{}, &ManagePlugin{}}
54```