Git Product home page Git Product logo

Comments (4)

parsley42 avatar parsley42 commented on June 7, 2024

There's no generic support for callbacks yet, and currently none planned, but you could write a Go plugin for this. When gopherbot starts the connector or does a reload, it calls each plugin with the command "init". In the processing for init, you'd check to see if your http listener is already running (in the case of a reload), and then fire off a goroutine with the bot object that would create a listener.

from gopherbot.

pasali avatar pasali commented on June 7, 2024

i created listener on main.go like this:

go func() {
		http.Handle("/metrics", handler)
                http.ListenAndServe(":8080", nil)
	}()

İs this a bad practice ? Should i really need a plugin for this?

from gopherbot.

parsley42 avatar parsley42 commented on June 7, 2024

I don't have any problem with this, if it works for you. The main reason to do it in a plugin would be getting the robot object from init, and storing it so you could later use one of the "Send*Message" methods, and also to store stuff in the brain, etc. If you're just adding the listener in main, how is your handler interacting with the robot?

from gopherbot.

pasali avatar pasali commented on June 7, 2024

I understand what you mean but i don't interact with bot directly. So it works for me this way. Thanks for reply.

from gopherbot.

Related Issues (20)

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.