Coder Social home page Coder Social logo

arduinoslack's Introduction

ArduinoSlack

Run a slack bot on your esp8266 wifi hardware. Useful for triggering digital I/O or reading sensors from your slack channel.


Functions

begin

void begin(const char *token,const char *id);

Begin setups the bot with slack token and bot id

connect

bool connect();

Connect connects to slack (handled by begin)

update

void update();

update bot ping and reconnect if needed

replyMsg

void replyMsg(const char *msg);

reply to channel

sendMsg

void sendMsg(const char *channel,const char *msg);

send msg to a channel

hears

void hears(const char *regex, std::function<void()> callback);

parse bot command and response

fails

void fails(const char *failMsg);

setup default message if bot doesn't understand


Example:

  /****************************************************/
void botCommands() {

  //syntax for bot.hears(regex, reponse function). Try it with a C++11 lambda 
  bot.hears("hello|hi|yo|howdy",[](){ 
    bot.replyMsg("hey hey!"); 
  });

  //try a more complex regex and a longer response function
  bot.hears("(get|read).*(a0|sensor|air.*quality)",readAirSensor);
  
  //if the bot doesn't understand (match) reply with a default message
  bot.fails("Sorry I didn't get that.");

}

/****************************************************/
void readAirSensor() {
    int sensorValue = analogRead(A0); //read analog input

    String valueMsg = String("Ok, the current the value is: "); //format the message
    valueMsg = valueMsg + String(sensorValue);

    bot.replyMsg(valueMsg.c_str()); //reply only takes c style strings
}

arduinoslack's People

Contributors

nullboundary avatar per1234 avatar rcamera avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

seco rcamera mcluk

arduinoslack's Issues

Library won't compile, due to typos

The library won't compile, throwing errors. Log:

Arduino: 1.6.11 (Linux), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, 115200, 4M (3M SPIFFS)"

In file included from /home/rcs/Arduino/libraries/ArduinoSlackBot/examples/arduinoSlackBot/arduinoSlackBot.ino:18:0:
/home/rcs/Arduino/libraries/ArduinoSlackBot/ArduinoSlackBot.h:68:10: error: 'EspSlackBot' does not name a type
   static EspSlackBot* ptrBot; //static ptr to EspSlackBot class for the webSocketEvent handler
          ^
exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).

I submitted a PR to fix this: #1

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.