Giter Site home page Giter Site logo

hangoutsbot's Introduction

Introduction

Hangupsbot is a chat bot designed for working with Google Hangouts.

Please see:

Repository Links

Features

  • Mentions : If somebody mentions you in a room, receive a private hangout from the bot with details on the mention, including context, room and person who mentioned you.
  • Syncouts : A syncout is two Hangout group chats that have their messages forwarded to each other, allowing seamless interaction between the two rooms. Primarily used to beat the 150-member chat limit, but it can also be used for temporarily connecting teams together to interact.
  • Cross-chat Syncouts : Half of your team is on Slack? No problem! You can connect them into the same room to communicate. Checkout telesync for using Telegram with the hangoutsbot.
  • Hubot Integration: Hangupsbot allows you to connect to Hubot, instantly providing you access to hundreds of developed chat tools and plugins.
  • Plugins and sinks : The bot has instructions for developing your own plugins and sinks, allowing the bot to interact with external services such as your company website, Google scripts and much more.
  • Plugin mania : games, nickname support, subscribed keywords, customizable API - the list goes on!

Running The Bot

Note: First run? See the installation instructions

run /path/to/venv/bin/hangupsbot with these optional arguments:

usage: hangupsbot [-h] [-d] [-s] [--base_dir BASE_DIR] [--log LOG]
                  [--cookies COOKIES] [--memory MEMORY] [--config CONFIG]
                  [--retries RETRIES] [--version]

optional arguments:
  -h, --help           show this help message and exit
  -d, --debug          log detailed debugging messages
                       (default: False)
  -s, --service        strip the timestamp from the stdout-log
                       (default: False)
  --base_dir BASE_DIR  base dir for the log-, cookies-, config- and memory-path
                       (default: ~/.local/share/hangupsbot)
  --log LOG            log file path
                       (default: ~/.local/share/hangupsbot/hangupsbot.log)
  --cookies COOKIES    cookie storage path
                       (default: ~/.local/share/hangupsbot/cookies.json)
  --memory MEMORY      memory storage path
                       (default: ~/.local/share/hangupsbot/memory.json)
  --config CONFIG      config storage path
                       (default: ~/.local/share/hangupsbot/config.json)
  --retries RETRIES    Maximum disconnect / reconnect retries before quitting
                       (default: 5)
  --version            show program's version number and exit

Example: /opt/venv/bin/hangupsbot --cookies ~/mybot/cookies.secret

Bot Configuration for Administrators

Configuration directives can be specified in config.json.

Please note that the config.json file supplied with the repository is not supposed to be edited/changed. It is the reference file used by the bot to create the actual configuration file located elsewhere in the system. To find out where the actual file is, please see the Additional Configuration section in the installation instructions.

Most configuration directives are specified globally

  • Global directives are always specified in the "root" of config.json.
  • To specify a per-conversation directive, the same configuration option should be defined as config.conversations[<conversation-id>].<configuration option>.
  • Per-conversation directives override global settings, if both are set.

Plugins

The plugins key in config.json allows you to optionally specify a list of plugins that will be loaded by the bot on startup. If this option is left as null, then all available plugins will be loaded.

To specify the plugins to be loaded, first ensure that the correct .py files are inside your hangupsbot/plugin/ directory, then modify the plugins key in config.json to reflect which plugins/files you want to load e.g. plugins: ["mentions", "default", "chance", "syncrooms"]

Some plugins may require extra configuration. config.json is the the configuration provider for the bot and its plugins.

Some interesting plugins:

  • mentions plugin
    • alert users when their names are mentioned in a chat
  • subscribe plugin
    • alert users when keywords they are subscribed to are said in a chat
  • syncout / syncrooms plugins
    • relay chat messages between different hangout group conversations (syncrooms)
    • configure via bot commands (syncrooms_config)

The wiki has a more comprehensive list of plugins

Interacting with the Bot

There are two general types of interactions with the bot:

  • /bot commands begin with /bot e.g. /bot dosomething
    • some bot commands are admin-only
  • custom interactions (usage and accessibility varies by plugin)

The base bot supports some basic command even without any plugins loaded. Here is a partial list:

/bot help

  • Bot lists all supported commands in a private message with the user

/bot ping

  • Bot replies with a pong.

/bot version

  • Bot replies with the version number of the framework

A full list of commands supported by the base framework is available at the Core Commands wiki page.

Updating

  1. Navigate to the repository directory (eg. cd ~/hangupsbot)

  2. git pull to pull the latest version of hangupsbot

  3. Install lastest features

    make install
    

    You can specify a custom location for the virtual environment:

    make install venv=/my/path
    
  4. Restart the bot

Debugging

  • Run the bot with the -d parameter e.g.
    ./venv/bin/hangupsbot -d
    
    • this lowers the log level to DEBUG for a more verbose and informative log file.
  • tail -F the log file, which is probably located at /<user>/.local/share/hangupsbot/hangupsbot.log - the location varies by distro!
  • A second log file <name of the default logfile>_warnings.log is created to catch log messages on level WARNING and above to find break points faster.
  • Console output (STDOUT) is limited to level WARNING and above in normal mode, level DEBUG is applied in debug mode.

Tips for troubleshooting

Program isn't running:

  • Update hangupsbot and its dependecies
  • Run ./venv/bin/hangups to check if the original hangups library is working
    • If there are errors, delete the cookie at ~/.local/share/hangupsbot/cookies.json and try again
    • Log into your Google Account from the server's address.

Bot isn't responding to messages:

  • Check that the chats are not going into the 'Invites' section of Hangouts.

Extending

Please see https://github.com/hangoutsbot/hangoutsbot/wiki/Authoring-Bot-Extensions

Credits / History

Hangoutsbot is derived from hangoutsbot

On 2017-07-17, this fork was made standalone

hangoutsbot's People

Contributors

am1ru1 avatar cd334 avatar cybot avatar danielcasner avatar das7pad avatar deffnull avatar dependabot-preview[bot] avatar dependabot-support avatar deuteu avatar endofline avatar fkloft avatar gurumadmat avatar infradom avatar j16sdiz avatar jfx41 avatar jhonnyam avatar jhonnyam123 avatar makiftasova avatar mzeman avatar neon-ninja avatar nylonee avatar phoerious avatar pleasantone avatar printerelf avatar pyup-bot avatar riptides avatar tapionx avatar terrance avatar vigoren avatar xmikos avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

hangoutsbot's Issues

Rare sending errors

Description

In rare occasions a sending request with hangups fails with a generic error message like Unexpected error. These are probably hiccups of the server and a retry should yield to a successful response.

Output of /bot version

Bot Version: 3.5.7+das7pad
Python Version: 3.6.8
running outside a virtual environment

  • aiohttp 3.5.4
  • appdirs 1.4.3
  • emoji 0.5.1
  • hangups 0.4.6.6+das7pad
  • telepot 12.6.1+das7pad

Expected behavior

The message gets delivered.

Actual behavior

An error is logged and the message gets discarded.

Steps to reproduce:

  1. Send many messages
  2. Send even more messages

Log output

NetworkError: Request failed with status 3: 'Unexpected error'
  File "hangupsbot/hangups_conversation.py", line 228, in send_message
    await self._client.send_chat_message(request)
  File "hangups/client.py", line 601, in send_chat_message
    send_chat_message_request, response)
  File "hangups/client.py", line 445, in _pb_request
    .format(status, description)

send_message failed 139778718572168: NetworkError: Request failed with status 3: 'Unexpected error'

https://sentry.das7pad.de/sentry/hangoutsbot/issues/33/

Your .dependabot/config.yml contained invalid details

Dependabot encountered the following error when parsing your .dependabot/config.yml:

The property '#/update_configs/0/allowed_updates/0' contains additional properties ["update_type"] outside of the schema when none are allowed
The property '#/update_configs/0/allowed_updates/0/match' of type null did not match the following type: object

Please update the config file to conform with Dependabot's specification.

You can mention @dependabot in the comments below to contact the Dependabot team.

The twitter plugin does not cover all KeyErrors

Description

The twitter plugin does not cover KeyError from missing secrets in the config/memory. Instead they are propagated to the parent.

Output of /bot version

Bot Version: 3.5.7+das7pad
Python Version: 3.6.8
running outside a virtual environment

  • aiohttp 3.5.4
  • appdirs 1.4.3
  • emoji 0.5.1
  • hangups 0.4.6.6+das7pad
  • telepot 12.6.1+das7pad

Expected behavior

The twitter plugin should gracefully check for a configured secret.

Actual behavior

The twitter plugin raises a KeyError for a missing path.

Steps to reproduce:

  1. remove the twitter config
  2. send a twitter link into a conversation

Log output

KeyError: 'twitter'
  File "hangupsbot/config.py", line 280, in get_by_path
    return self._get_by_path(self.defaults, keys_list)
  File "hangupsbot/config.py", line 332, in _get_by_path
    return functools.reduce(operator.getitem, path[:-1], source)[path[-1]]

KeyError: "hangupsbot.memory has no path ['twitter', 'key'] and there is no default set"
  File "hangupsbot/handlers.py", line 411, in _run_single_handler
    await result
  File "hangupsbot/plugins/twitter/__init__.py", line 111, in _watch_twitter_link
    key = bot.memory.get_by_path(['twitter', 'key'])
  File "hangupsbot/config.py", line 283, in get_by_path
    (self.logger.name, keys_list))

message_once: plugins.twitter._watch_twitter_link 139753966388136: handler error

https://sentry.das7pad.de/sentry/hangoutsbot/issues/50/

plugincontrol can destroy the plugin tracking

Description

The commands.plugincontrol commands can destroy the content of plugins.tracking

Output of /bot version

Bot Version: 3.1.0-das7pad
Python Version: 3.5.3

  • aiohttp 2.1.0
  • appdirs 1.4.3
  • emoji 0.4.5
  • hangups 0.4.2.1-das7pad
  • telepot 12.1

Expected behaviour

plugins.tracking can not be modified from outside via simple commands

Actual behaviour

plugins.tracking gets reset

Steps to reproduce:

  1. /bot pluginload plugins
  2. /bot pluginreload plugins

[v4] split startup

  • delay access on the hangups.Client and conv/user list
  • decouple hangupsbot.core.HangupsBot.run and hangups.Client.connect
  • split hangupsbot.core.HangupsBot._on_connect into smaller parts

[telesync] sending to upgraded group failed

Description

Telegram may interrupt sending to a group that has been upgraded to a supergroup recently.

The server response includes the new chat_id of the supergroup.

{'ok': False, 'error_code': 400, 'description': 'Bad Request: group chat was upgraded to a supergroup chat', 'parameters': {'migrate_to_chat_id': -1001393272233}}

Output of /bot version

Bot Version: 3.8.1+das7pad
Python Version: 3.6.8
running outside a virtual environment
- aiohttp 3.5.4
- appdirs 1.4.3
- emoji 0.5.2
- hangups 0.4.9.3+das7pad
- telepot 12.6.1+das7pad

Expected behavior

Sending is redirected

Actual behavior

Sending failed with error

Steps to reproduce:

  1. Get a telegram group id
  2. Upgrade the group to a supergroup
  3. Send a message to the noted group id

Log output

2019-05-19 09:00:00,729 INFO hangupsbot.plugins.telesync.core: sending html 139732983660168: chat '-2<SNIP>', content '<SNIP>'
2019-05-19 09:00:00,729 ERROR hangupsbot.plugins.telesync.core: sending html 139732983660168: failed with TelegramError('Bad Request: group chat was upgraded to a supergroup chat', 400, {'ok': False, 'error_code': 400, 'description': 'Bad Request: group chat was upgraded to a supergroup chat', 'parameters': {'migrate_to_chat_id': -10<SNIP>}})

REF https://sentry.das7pad.de/sentry/hangoutsbot/issues/171/

Dependabot can't evaluate your Python dependency files

Dependabot can't evaluate your Python dependency files.

As a result, Dependabot couldn't check whether any of your dependencies are out-of-date.

The error Dependabot encountered was:

InstallationError("Could not open requirements file: [Errno 2] No such file or directory: '/home/dependabot/dependabot-updater/dependabot_tmp_dir/../hangupsbot/requirements.in'",)

You can mention @dependabot in the comments below to contact the Dependabot team.

The config command should cover KeyError

Description

The config does not cover KeyError from invalid paths. Instead they are propagated to the parent.

Output of /bot version

Bot Version: 3.5.7+das7pad
Python Version: 3.6.8
running outside a virtual environment

  • aiohttp 3.5.4
  • appdirs 1.4.3
  • emoji 0.5.1
  • hangups 0.4.6.6+das7pad
  • telepot 12.6.1+das7pad

Expected behavior

A user friendly message saying that the path does not exist.

Actual behavior

A generic message is sent by the hangupsbot.commands.CommandDispatcher: config KeyError.

Steps to reproduce:

  1. /bot config get INVALID_KEY
  2. check logs/conversation

Log output

KeyError: 'SOME_KEY'
  File "hangupsbot/config.py", line 280, in get_by_path
    return self._get_by_path(self.defaults, keys_list)
  File "hangupsbot/config.py", line 332, in _get_by_path
    return functools.reduce(operator.getitem, path[:-1], source)[path[-1]]

KeyError: "hangupsbot.config has no path ['SOME_KEY', '...'] and there is no default set"
  File "hangupsbot/commands/__init__.py", line 216, in run
    bot.config['command_timeout'])
  File "asyncio/tasks.py", line 358, in wait_for
    return fut.result()
  File "hangupsbot/plugins/default.py", line 470, in config
    if config_args else dict(bot.config))
  File "hangupsbot/config.py", line 283, in get_by_path
    (self.logger.name, keys_list))

command run 140376637981416: low level error

https://sentry.das7pad.de/sentry/hangoutsbot/issues/79/

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.