Coder Social home page Coder Social logo

ash's Introduction

Ash

Cute bot

It's a robot. Ash is a god damn robot!

A simple IRC bot, based on pircbotx, started as a fork of clj-irc.

Why another one?

Because I need one that works with grove.io, that is very simple, extensible, supports webhooks and has some simple persistance solution embedded.

See plugins for examples. You can add your own event listeners by extending the qbits.ash.bot/listen multimethod.

See echoweb for a basic example of webhook integration.

Installation

[cc.qbits/ash "0.2.6"]

Usage

(require
  '[qbits.ash :as ash]
  '[qbits.ash.webhooks :as webhooks]

  '[qbits.ash.plugins.clojure :as clj]
  '[qbits.ash.plugins.google :as goog]
  '[qbits.ash.plugins.echoweb :as echoweb])

(-> (ash/make-bot :server-password "meh"
                  :nick "just-a-bot"
                  :name "just-a-bot"
                  :password "1234"
                  :host "meh.irc.grove.io"
                  :port 6667
                  :channels ["#foo" "#bar"]
                  :auto-reconnect true)
    clj/handler
    goog/handler
    echoweb/handler)

(webhooks/start-server)

Plugins

Plugins are very easy to implement:

(ns yourbot.plugins.meh
    (:require [qbits.ash :as ash]))

(defn handler
  [bot]
  (ash/listen bot :on-message
      (fn [event]
          (when (re-find #"sayhi" (:content event))
              ;; reply knows about context form the event passed
              ;; (privmsg, channel msg, etc)
              (ash/reply bot event "Hello world"))))))

For a webook:

(defn handler [bot]
  (ash/listen bot :on-webhook
              :post #"^/say-hi"
              (fn [request]
                (ash/send-message "#somechan" "hohai")))

  (ash/listen bot :on-webhook
              :get #"^/say-hi-foo"
              (fn [request]
                (ash/send-message "foo" "hohai foo")))

Clojure plugin: clojail sandboxing

Because clojail employs the JVM's built in sandboxing, you'll need to have a ~/.java.policy file to define permissions for your own code. If you don't do this, you'll get security exceptions.

You can find an example here.

License

Copyright © 2012 FIXME

Distributed under the Eclipse Public License, the same as Clojure.

ash's People

Contributors

mpenet avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

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