Giter Site home page Giter Site logo

tebriz159 / gopherbot Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lnxjedi/gopherbot

0.0 0.0 0.0 5.06 MB

A chat bot written in Go, inspired by Hubot and designed for ChatOps.

License: MIT License

Go 80.90% PowerShell 8.74% Python 2.62% Ruby 3.44% Shell 4.30%

gopherbot's Introduction

+

Server

Gophers + Robot by Renee French (cropped) licensed under Creative Commons License 3.0

Gopherbot

CircleCI Coverage Status GoDoc

Enterprise Slack(*) ChatOps bot for Linux and Windows, supporting plugins in Python, Ruby, Bash and PowerShell

Download the current release for your platform from: https://github.com/lnxjedi/gopherbot/releases/latest

To try out Gopherbot for yourself and write your first plugin, see the Quick Start Guide

(*) with a modular interface for writing other protocol connectors in Go

A few of Gopherbot's features:

  • Built-in support for elevated commands requiring MFA (ala 'sudo')
  • A prompting API for interactive plugins
  • Comprehensive set of administrative commands
  • Simple single-file script plugins

Sample Plugin with the Ruby API

#!/usr/bin/ruby
require 'net/http'
require 'json'

# To install:
# 1) Copy this file to plugins/weather.rb
# 2) Enable in gopherbot.yaml like so:
#ExternalScripts:
#- Name: weather
#  Path: plugins/weather.rb
# 3) Put your configuration in conf/plugins/weather.yaml:
#Config:
#  APIKey: <your openweathermap key>
#  TemperatureUnits: imperial # or 'metric'
#  DefaultCountry: 'us' # or other ISO 3166 country code

# load the Gopherbot ruby library and instantiate the bot
require ENV["GOPHER_INSTALLDIR"] + '/lib/gopherbot_v1'
bot = Robot.new()

defaultConfig = <<'DEFCONFIG'
Help:
- Keywords: [ "weather" ]
  Helptext: [ "(bot), weather in <city(,country) or zip code> - fetch the weather from OpenWeatherMap" ]
CommandMatchers:
- Command: weather
  Regex: '(?i:weather (?:in|for) (.+))'
DEFCONFIG

command = ARGV.shift()

case command
when "configure"
	puts defaultConfig
	exit
when "weather"
    c = bot.GetTaskConfig()
    location = ARGV.shift()
    location += ",#{c["DefaultCountry"]}" unless location.include?(',')
    uri = URI("http://api.openweathermap.org/data/2.5/weather?q=#{location}&units=#{c["TemperatureUnits"]}&APPID=#{c["APIKey"]}")
    d = JSON::parse(Net::HTTP.get(uri))
    if d["message"]
        bot.Say("Sorry: \"#{d["message"]}\", maybe try the zip code?")
    else
        w = d["weather"][0]
        t = d["main"]
        bot.Say("The weather in #{d["name"]} is currently \"#{w["description"]}\" and #{t["temp"]} degrees, with a forecast low of #{t["temp_min"]} and high of #{t["temp_max"]}")
    end
end

The goal is for Gopherbot to support multiple scripting languages with built-in security features, to make secure ChatOps functions easy to write for most Systems and DevOps engineers.

Examples of work Gopherbot is already doing:

  • Building, backing up, restoring, stopping and starting instances in the AWS cloud
  • Disabling / reenabling user web directories when requested by security engineers
  • Adding users and updating passwords on servers using Ansible

Development Status

Gopherbot 1.x is stable and running in production in several environments.

Development has started for Gopherbot 2.x, which adds features for scheduled jobs and pipelines. See the development notes.

Contributing

Check out Github's documentation on forking and creating pull requests. Feel free to shoot me an email for an invite to the LinuxJedi Slack team.

Documentation

NOTE: This is the documentation for Gopherbot v1.1. For older versions, see the documentation included in the distribution archive.

Also see the full Documentation Index

gopherbot's People

Contributors

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