Giter Club home page Giter Club logo

stocksbot's Introduction

stocksbot

A telegram bot to report stocks and currency conversion rate values, written in Go.

How to customise it

The code is configured to send messages in times defined by me, suiting my needs. For this, I used robfig/cron library to create cron schedules. The configuration is the same as a crontab. If you need help to create a cron, here is a link to help you.

Also, if you want to add another stock or replace the current one, just do the following:

applStock, err := quote.Get("APPL")
if err != nil {
    return nil, err
}
values = append(values, types.NewFinance(applStock))

In this example, I used Apple stock symbol to fetch information about their stocks.

For currencies, the code is almost the same:

eurBrl, err := forex.Get("EURBRL=X")
if err != nil {
    return nil, err
}
values = append(values, types.NewFinance(&eurBrl.Quote))

The code above will fetch information about how much does a EUR costs in BRL.

Don't forget to update the container timezone accordingly. The default is set to my location America/Sao_Paulo. All you need is to update this line from the Dockerfile:

ENV TZ=America/Sao_Paulo

How to use it

If you don't have a bot and/or group

Before executing the code, you need to set up a bot and have a telegram group. You will need a group ID in which the bot will send messages to and a token for your bot. To get the group ID, just add the IDBot to the group and send a /getgroupid message. For the bot, just follow this tutorial and at the end of the set up, a token will be generated for you.

Last step is to consume the group ID and the bot token. Just replace these lines on main.go:

telegramToken  = "<my-bot-token>"
telegramChatID = int64(<my-group-id>)

How to run

  • The simple way (if you have Golang already installed in your machine)
    • go run main.go
  • The simple way with Docker (yeah, you don't have to install any dependencies)
    • docker build . then
    • docker run --detach --name stocksbot <image-name>

That's it. Feel free to provide feedback and/or report issues.

stocksbot's People

Contributors

viniscoelho7 avatar viniscoelho 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.