Giter Site home page Giter Site logo

revolt-cobol-api's Introduction

COBOL bindings for Revolt API

Introduction

Create a file named token.txt and paste your token there.

Pre-requisites:

  • GnuCOBOL
  • WebSockets
  • curl

On Debian based systems it's easy as:

sudo apt install libwebsockets-dev libcurl4-dev gnucobol

Example

Here is a small bot which will print "hello world!" every 5 seconds to an specific channel id.

      *> Main entry point for application
       identification division.
       program-id. rv-test-main.
       data division.
       working-storage section.
       copy "rcfg.cpy" replacing ==:pref:== by ==ws==
                       ==:levl:== by ==01==.
       procedure division.
           initialize ws-config.
           set ws-onrun-pgm to entry "rv-onrun".
           call "rv-init" using by content ws-config end-call.
           goback.
       end program rv-test-main.
      *> Function called on every "running step" of the querying loop
       identification division.
       program-id. rv-onrun.
       data division.
       working-storage section.
       copy "rmsg.cpy" replacing ==:pref:== by ==ws==
                       ==:levl:== by ==01==.
       linkage section.
       copy "rcfg.cpy" replacing ==:pref:== by ==ls==
                       ==:levl:== by ==01==.
       procedure division using by reference ls-config.
           initialize ws-msg.
           move "Hello world!" to ws-content in ws-msg.
           *> Function call to send a message - notice how we're sending
           *> a "ws-msg" which we defined from the "rmsg.cpy" copybook!
           call static "rv-send-msg" using by reference ls-config
               *> Important to fill this out with a correct channel id!
               by value "Channel-id-to-send-message-at"
               by reference ws-msg end-call.
           *> Just send at an interval of 5 seconds
           call "C$SLEEP" using by content "5" end-call.
           goback.
       end program rv-onrun.

If we do not fill out "ws-token" - then the library will do it for us - by reading from a file called "token.txt" - make sure it exists beforehand or the program will crash. This is the recommended way of doing things however as embedding tokens directly into the source code of a bot isn't a good idea. Additionaly the instance URL is fetched from "server.txt" file automatically.

Resources

Noteworthy resources to aid in development:

revolt-cobol-api's People

Contributors

kabylake1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 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.