GithubHelp home page GithubHelp logo

stalmanu's Introduction

Richardo "GNU/dad" Stalmanu

Codeship Status

I'd just like to interject for a moment. What you're referring to as Linux, is in fact, GNU/Linux, or as I've recently taken to calling it, GNU plus Linux. Linux is not an operating system unto itself, but rather another free component of a fully functioning GNU system made useful by the GNU corelibs, shell utilities and vital system components comprising a full OS as defined by POSIX.

Many computer users run a modified version of the GNU system every day, without realizing it. Through a peculiar turn of events, the version of GNU which is widely used today is often called Linux, and many of its users are not aware that it is basically the GNU system, developed by the GNU Project.

There really is a Linux, and these people are using it, but it is just a part of the system they use. Linux is the kernel: the program in the system that allocates the machine's resources to the other programs that you run. The kernel is an essential part of an operating system, but useless by itself; it can only function in the context of a complete operating system. Linux is normally used in combination with the GNU operating system: the whole system is basically GNU with Linux added, or GNU/Linux. All the so-called Linux distributions are really distributions of GNU/Linux.

Installing and running

Stalmanu is a rather opinionated Slack bot. His hobbies include just interjecting for a moment, and... well that's about it. This is mostly an experiment in interfacing with Slack.io. Stalmanu uses Boot, which will be assumed installed in the remainder of the README.

You can compile Stalmanu into a runnable jar using

boot build

and then start him using

java -jar target/stalmanu-0.1.0.jar my-super-secret-token

where you supply the Slack bot token.

Extending

Stalmanu is most easily extended by hooking into the emit! and handle flow that his current functions are built on. Essentially, whenever anything happens on the channels that Stalmanu is monitoring, he will call (emit!) and supply a topic and some data:

(emit! "message"
  {:type "message" :channel "..." :user "..." :ts "..." :text "Hi, friends!"})

The topic will match the :type from the parsed JSON if present. You can emit events as well, supplying whatever topic and data you want to. To actually process events, you'll define some handlers:

(handle "message"
  (fn [msg]
    (when (> (count (:text msg)) 500)
      (send! websocket "Woah! That's a lot of text, mate."))))

(handle "presence_change"
  (fn [presence]
    (println (:user presence) "is now" (:presence presence) "!")))

This assumes you've saved the websocket returned when calling client!. That's probably what you want, though, as it's the only way to send messages to the Slack server.

It is perfectly acceptable for your handlers to emit additional events, but you probably want to condition them in a way that doesn't lead to infinite loops. You should also remember that calling send! will result in a new emit!, which makes creating an infinite loop simple:

;; Don't do this unless your goal is to be kicked from the server for flooding.
(handle "message"
  (fn [msg]
    (send! websocket "I just saw '" (pr-str msg) "'!")))

stalmanu's People

Contributors

emiln avatar

Watchers

 avatar

stalmanu's Issues

Figure out logging

Slacker is already using clojure.tools.logging so it would make sense to hook into this to log relevant events to disk.

Use emit/handle flow for the channels

Inspired by re-frame it would be cool to try out their emit and handle flow. Basically you can only communicate over the internal channels by calling

(emit! :message {:user "..." :channel "..."})

and handle this event by creating a handler for the topic :message:

(handle :message
  (fn [json] "..."))

which will (for every matching handler) be passed any arguments beyond this first from the call to emit!.

Switch from string topics to keyword topics

The client will currently emit! topics of type String, like "message". The only reason it isn't emitting the more idiomatic keyword type is laziness. It would be very easy to convert the limited range of Strings used by Slack to keywords.

Something along these lines:

(fn [string]
  (-> string
    (clojure.string/replace #"_" "-")
    (keyword)))

Only give the full rant every so often

The full rant takes up a great deal of space in the chat. It would be nice if Stalmanu only responded in full every few minutes and used a slightly less verbose rant for any necessary reminders between the full rants. I suggest the following:

  • He may rant at length if he hasn't done so for 5 minutes.
  • His short rant reads: It's GNU+Linux.

Words to avoid

While Stalmanu's effort to correct improper use of Linux without paying proper homage to GNU is applaudable, he is only scratching the surface of improper word usage. I think he should be extended to cover the most obviously software-centric terms on this list.

Update docstrings

The rapid progress of Stalmanu has left most docstrings rather outdated. This should be fixed, and particularly for stalmanu.client where many important functions reside.

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.