Skip to content

GorokuUserbot modules in Go

A module is a struct with a name and some commands. Everything else has a default.

A whole module

go
package modules

import "goroku/goroku"

type HTML struct{ goroku.Base }

func (m *HTML) Name() string { return "HTML" }

func (m *HTML) Commands() map[string]goroku.CommandHandler {
	return map[string]goroku.CommandHandler{"html": m.HTMLCmd}
}

func (m *HTML) HTMLCmd(msg *goroku.Message) error {
	code := msg.ArgsOrReply()
	if code == "" {
		return msg.Answer(m.T("no_args", "❌ <b>Send text or reply to a message</b>"))
	}
	return msg.Answer(code)
}

That is the complete file. .html <b>hi</b> renders bold text; replying to a message with .html renders that message instead.

Where to go

You want toRead
Get something working in five minutesYour first module
Understand what each method is forAnatomy of a module
Restrict a command to groups, admins, or repliesCommandMeta
Persist data between restartsStorage
Let users configure your moduleConfiguration
Ship it to other peopleInstalling a module

Released under the GNU AGPL v3 License.