Giter VIP home page Giter VIP logo

sftmumblebot's Introduction

Description

This bot provides a text bridge between an IRC channel and a Mumble server.

How to install/configure/run

You can directly run sftbot by typing ./run or python2 -m sftbot. To permanently install sftbot, type sudo ./setup.py install. Then, you can run it by typing sftbot.

You need to provide a config file that (among others) contains user credentials for the bot. An example conf file can be found in sftbot.conf.example.

You can either specify a conf file path as a command line argument (sftbot myconffile.conf), or place it at ./sftbot.conf or /etc/sftbot.conf.

Behaviour

By default, the bot

  • Relays messages from a mumble channel to an IRC channel
  • Leaves the channel when somebody types 'gtfo'
  • Tries to reconnect on connection failures

However, this behaviour can be altered easily by editing sftbot/__main__.py, which contains several fairly self-explainatory callback functions that will be automatically invoked at the appropriate times. For example, certain IRC messages may be ignored by adding a line if message.contains('bannedtext'): return to the top of ircTextMessageCallback. More complex, 'botty' behaviour may be implemented the same way; note that you can call irc.sendTextMessage() and mumble.sendTextMessage() from everywhere within the callback functions.

Dependencies

  • python2
  • protobuf-python (Debian/Ubuntu package: python-protobuf, Arch package: python2-protobuf)

TODOs

Nice-to-have features (which we don't plan to implement right now, but feel free to do it yourself):

  • SSL certificate validation support
  • SSL client certificate support
  • More chat protocols (e.g. XMPP multi-user chat)
  • Init scripts for <your distribution here>

Misc

Mumble uses Google Protobuf for most of its communications; this means that one code file needs to be auto-generated (that's what the Makefile is there for). Unfortunately, protoc does not officially support python3, so we're forced to deal with python2 and all its string buffer ugliness.

Contact

You can find us at irc.freenode.net/#sfttech. If you found a bug, feel free to join and randomly insult channel OPs until someone fixes it (or bans you). Alternatively, fix it yourself and send a pull request.

Contributors/Copyright

See COPYING. The license is GPLv3 or higher.

sftmumblebot's People

Contributors

dopeghoti avatar mic-e avatar promi avatar thejj avatar thvortex avatar tslocum avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sftmumblebot's Issues

Running in as systemd daemon causes high CPU usage

I run sftmumblebot inside a docker container. And it themes like detaching the container from stdin causes high CPU load.

As it started flooding the IRC and the mumble channel instantly it joined I "fixed" it by using the following patch: https://github.com/SISheogorath/docker-sftmumblebot/blob/b05ec9280fe62c799595d762d57f694e864b04a9/console-fix.patch

But I reconized that didn't lower the CPU usage. So here is my new patch: SISheogorath/sftmumblebot-docker@60199b6

This solves the CPU problem but its a bad solution. May fix it in general?

opus support not supported

although we're doing nothing with speech yet, the bot reports version 1.2.3, which leads the server to use celt instead of opus.

sftmumblebot can insult himself

As we can see here

<grindhold> !insult sftbot
<sftbot> I think sftbot is full of shit.
<grindhold> bwahahaha

sftmumblebot can insult himself when told to do so. as sftmumblebutt is a highly aware artificial intelligence i think, this is a bug and should immediately be fixed.

Bot will attempt to relay before connection is established

(3) mumble: unknown text message sender id: 0
(2) mumble: text message received, sender: unknown
mumble: unknown: <strong>WARNING:</strong> Your client doesn't support the Opus
codec the server is switching to, you won't be able to talk or hear anyone. Plea
se upgrade to a client with Opus support.
(1) irc: could not send text message: <type 'exceptions.Exception'>
(2) irc: Traceback (most recent call last):
(2) irc:   File "C:\Users\SwedFTP\Desktop\BTCBot\AbstractConnection.py", line 21
9, in sendTextMessage
(2) irc:     raise Exception("connection not established")
(2) irc: Exception: connection not established
(2) irc:

SSL handshake error when connecting to Murmur 1.2.4

The bot throws http://pastebin.com/NX23ATff , while murmur throws
'Connection closed: Error during SSL handshake: error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number [13]'

when attempting to connect.

I fixed the error and allowed the relay bot to connect by editing line 75 of MumbleConnection.py

I changed it from

        self._socket = ssl.wrap_socket(s)

to

        self._socket = ssl.wrap_socket(s, ssl_version = ssl.PROTOCOL_TLSv1)

I would be surprised if this was the correct fix, however it was the most simple hack I could do with absolutely no python knowledge.

When a user is kicked bot disconnects

Line 179 in MumbleConnection.py(testing branch)

        elif messagetype == Mumble_pb2.UserRemove:
            self._log("Got UserRemove Message", 2)
            if self._users[pbMess.session] in self._userIds.keys():
                del self._userIds[self._users[pbMess.session]]
            if pbMess.session in self._users.keys():
                del self._users[pbMess.session]

This causes the following output

(2) mumble: Got UserRemove Message
(2) mumble: Got UserRemove Message
(0) mumble: connection terminated with an error:
(0) mumble: <type 'exceptions.KeyError'>
(1) mumble: Traceback (most recent call last):
(1) mumble:   File "C:\Users\SwedFTP\Desktop\sftmumblebot-master\AbstractConnect
ion.py", line 166, in run
(1) mumble:     if not self._listen():
(1) mumble:   File "C:\Users\SwedFTP\Desktop\sftmumblebot-master\MumbleConnectio
n.py", line 179, in _listen
(1) mumble:     if self._users[pbMess.session] in self._userIds.keys():
(1) mumble: KeyError: 80L
(1) mumble:
(2) mumble: socket successfully closed
connection to mumble lost. reconnect in 5 seconds.
(1) irc: could not send text message: <type 'exceptions.Exception'>
(2) irc: Traceback (most recent call last):
(2) irc:   File "C:\Users\SwedFTP\Desktop\sftmumblebot-master\AbstractConnection
.py", line 219, in sendTextMessage
(2) irc:     raise Exception("connection not established")
(2) irc: Exception: connection not established

Bot sends messages globally if a user disconnects & reconnects.

When the user disconnects the bot throws

(2) mumble: unhandeled package received: UserRemove, 2 bytes

when I reconnect the bot throws

(2) mumble: user SwedFTP has id 55
(2) mumble: I was dragged into another channel. Channle id:2
(2) mumble: unhandeled package received: CryptSetup, 0 bytes

after this point any message received from IRC is relayed to the whole Mumble server.

IRC connection lost after receiving too large of a buffer.

After running the bot for a couple of hours it dies with

(0) irc: connection terminated with an error:
(0) irc: <class 'socket.error'>
(1) irc: Traceback (most recent call last):
(1) irc:   File "C:\Users\SwedFTP\Desktop\BTCBot\AbstractConnection.py", line 16
6, in run
(1) irc:     if not self._listen():
(1) irc:   File "C:\Users\SwedFTP\Desktop\BTCBot\IRCConnection.py", line 64, in
_listen
(1) irc:     self._readBuffer += self._socket.recv(1024)
(1) irc: error: [Errno 10053] An established connection was aborted by the softw
are in your host machine
(1) irc:
(2) irc: socket successfully closed
connection to irc lost. reconnect in 15 seconds.

I'm assuming it's because it's receiving larger than 1 kB of data, however I'm not sure of that, and I'm not quite sure how to reproduce this.

mac install errors

Hi there,

I followed the instructions in the readme. Installed python through brew (v 2.7.5) and ran ./setup.py install

$ sudo ./setup.py install                                                                                                                                                                                                                                                                                                                              
running install
running build
running build_py
running build_scripts
running install_lib
copying build/lib/sftbot/__init__.py -> /usr/local/lib/python2.7/site-packages/sftbot
copying build/lib/sftbot/__main__.py -> /usr/local/lib/python2.7/site-packages/sftbot
copying build/lib/sftbot/AbstractConnection.py -> /usr/local/lib/python2.7/site-packages/sftbot
copying build/lib/sftbot/ConsoleConnection.py -> /usr/local/lib/python2.7/site-packages/sftbot
copying build/lib/sftbot/IRCConnection.py -> /usr/local/lib/python2.7/site-packages/sftbot
copying build/lib/sftbot/MumbleConnection.py -> /usr/local/lib/python2.7/site-packages/sftbot
copying build/lib/sftbot/protobuf/__init__.py -> /usr/local/lib/python2.7/site-packages/sftbot/protobuf
copying build/lib/sftbot/protobuf/Mumble_pb2.py -> /usr/local/lib/python2.7/site-packages/sftbot/protobuf
copying build/lib/sftbot/util.py -> /usr/local/lib/python2.7/site-packages/sftbot
byte-compiling /usr/local/lib/python2.7/site-packages/sftbot/__init__.py to __init__.pyc
byte-compiling /usr/local/lib/python2.7/site-packages/sftbot/__main__.py to __main__.pyc
byte-compiling /usr/local/lib/python2.7/site-packages/sftbot/AbstractConnection.py to AbstractConnection.pyc
byte-compiling /usr/local/lib/python2.7/site-packages/sftbot/ConsoleConnection.py to ConsoleConnection.pyc
byte-compiling /usr/local/lib/python2.7/site-packages/sftbot/IRCConnection.py to IRCConnection.pyc
byte-compiling /usr/local/lib/python2.7/site-packages/sftbot/MumbleConnection.py to MumbleConnection.pyc
byte-compiling /usr/local/lib/python2.7/site-packages/sftbot/protobuf/__init__.py to __init__.pyc
byte-compiling /usr/local/lib/python2.7/site-packages/sftbot/protobuf/Mumble_pb2.py to Mumble_pb2.pyc
byte-compiling /usr/local/lib/python2.7/site-packages/sftbot/util.py to util.pyc
running install_scripts
copying build/scripts-2.7/sftbot -> /usr/local/bin
changing mode of /usr/local/bin/sftbot to 755
running install_egg_info
Removing /usr/local/lib/python2.7/site-packages/sftmumblebot-0.0-py2.7.egg-info
Writing /usr/local/lib/python2.7/site-packages/sftmumblebot-0.0-py2.7.egg-info

Created /etc/sftbot.conf

When I run sftbot I receive the following:

$ sftbot                                                                                                                                                                                                                                                                                                                                               ✹⚡(master*) ‹system›
Traceback (most recent call last):
  File "/usr/local/Cellar/python/2.7.7_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/local/Cellar/python/2.7.7_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/Users/sirkitree/repos/sftmumblebot/sftbot/__main__.py", line 3, in <module>
    import MumbleConnection
  File "sftbot/MumbleConnection.py", line 10, in <module>
    import sftbot.protobuf.Mumble_pb2 as pb2
  File "sftbot/protobuf/Mumble_pb2.py", line 4, in <module>
    from google.protobuf import descriptor as _descriptor
ImportError: No module named google.protobuf

Anyone have suggestions?

Support mumble client certificate

please add the feature for mumble client certificates so that the bot can be registered on server side.

On our server it is not allowed, for spam protection reasons, to send text messages if the user is not registered so that bot is not really useful.

Thanks in advance

Doesn't work, Error with sendTextMessage

With a friend, we're trying to set-up the bot but it just can't join a channel on IRC and sending message to him makes some errors.

When starting with ./run, I'm getting those lines first: (redacted username and server)

sft mumble bot 0.0
loading conf file sftbot.conf
(2) console:   connection successfully opened
(2) console:   initial packages successfully sent
(3) mumble:    trying python default ssl socket
(2) mumble:    connection successfully opened
(2) mumble:    initial packages successfully sent
(2) mumble:    unhandeled package received: Version, 71 bytes
(2) irc:       connection successfully opened
(3) irc:       tx: NICK <botUsername>
(3) irc:       tx: USER <botUsername> <ircServer> bla :<botUsername>
(3) irc:       tx: JOIN #<ircChannel>
(2) irc:       initial packages successfully sent
(3) irc:       rx: :c<ircServer> NOTICE Auth :*** Looking up your hostname...
(2) mumble:    unhandeled package received: CryptSetup, 54 bytes
(3) mumble:    unknown text message sender id: 0
(2) mumble:    text message received, sender: unknown
mumble: unknown: <strong>WARNING:</strong> Your client doesn't support the Opus codec the server is using, you won't be able to talk or hear anyone. Please upgrade to a client with Opus support.
(1) irc:       could not send text message: <type 'exceptions.Exception'>
(2) irc:       Traceback (most recent call last):
(2) irc:         File "sftbot/AbstractConnection.py", line 286, in sendTextMessage
(2) irc:           raise Exception("connection not established")
(2) irc:       Exception: connection not established
(2) irc:

When sending a message from the console:

(1) irc:       could not send text message: <type 'exceptions.Exception'>
(2) irc:       Traceback (most recent call last):
(2) irc:         File "sftbot/AbstractConnection.py", line 286, in sendTextMessage
(2) irc:           raise Exception("connection not established")
(2) irc:       Exception: connection not established
(2) irc:
(1) mumble:    could not send text message: <type 'exceptions.Exception'>
(2) mumble:    Traceback (most recent call last):
(2) mumble:      File "sftbot/AbstractConnection.py", line 286, in sendTextMessage
(2) mumble:        raise Exception("connection not established")
(2) mumble:    Exception: connection not established
(2) mumble:

If I'm sending a message from Mumble, the error only shows about IRC, and the same for IRC to Mumble.

Tested on a Debian 7 server and on my Mac with OS X 10.10.

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.