Code Monkey home page Code Monkey logo

hangupsbot's Introduction

HangupsBot

Bot for Google Hangouts

Requirements

Usage

Run hangupsbot --help to see all available options. Start HangupsBot by running hangupsbot.

You can configure basic settings in config.json file. This file will be copied to user data directory (e.g. ~/.local/share/hangupsbot/ on Linux) after first start of HangupsBot.

The first time you start HangupsBot, you will be prompted to open a link in your web browser where you log into your Google account. After logging in and clicking on "SIGN IN", you should see authorization code. Copy this code to clipboard and paste it into HangupsBot to complete the process. Your credentials will only be sent to Google, and only OAuth 2 refresh token will be stored locally.

Help

usage: hangupsbot [-h] [-d] [--log LOG] [--token TOKEN] [--config CONFIG]
                  [--version]

optional arguments:
  -h, --help       show this help message and exit
  -d, --debug      log detailed debugging messages (default: False)
  --log LOG        log file path (default:
                   ~/.local/share/hangupsbot/hangupsbot.log)
  --token TOKEN    OAuth refresh token storage path (default:
                   ~/.local/share/hangupsbot/refresh_token.txt)
  --config CONFIG  config storage path (default:
                   ~/.local/share/hangupsbot/config.json)
  --version        show program's version number and exit

Features (event handlers)

  • autoreplies - automatically reply to specified keywords in messages
  • commands - run /bot commands (type /bot help for list of available commands)
  • forwarding - forward messages from one conversation to another
  • membership - watch conversations for added/removed users
  • rename - watch for renamed conversations (only example plugin for now)

Development

You can extend HangupsBot in two ways - by writing handlers or commands plugins. Every Python file (which doesn't start with _) in handlers and commands directories is loaded automatically.

Handlers

Functions in plugins can be registered as event handlers by decorating them with @handler.register(priority=10, event=None) decorator.

If event parameter is None (default), all event types are forwarded to handler. If you want to handle only some specific type of event, you can set event to hangups.ChatMessageEvent, hangups.MembershipChangeEvent or hangups.RenameEvent.

You can change priority of handler by specifying priority parameter (default is 10). A lower number means higher priority. If you raise StopEventHandling exception in your handler, current event will not be handled by any other handler.

Commands

Functions in plugins can be registered as /bot commands by decorating them with @command.register(admin=False) decorator.

If admin parameter is False (default), anyone can run the command. If admin is True, only admins (as set in config.json) can run it.

See existing commands for examples.

hangupsbot's People

Contributors

xmikos avatar

Watchers

Coda avatar James Cloos 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.