Eggdrop script to list mumble users

Ice/DBus, Web-Interfaces, Management tools

Eggdrop script to list mumble users

Postby purch » Fri Nov 12, 2010 7:41 pm

A little eggdrop script to list mumble users to an irc channel. You may modify and use these scripts in any way you like.

Please post or PM me of possible modifications to the scripts.

Special thanks to Svedrin (Author of Mumble-django) for python/ice help.

irc channel output (only server:channel combinations with users on separate rows ):
Code: Select all
<@purch> !m
<@botti> nahka.CoD MW2: purch, jukkis, seppo
<@botti> nolla.Strikeforce: aman


Requirements are eggdrop, python, murmur with ICE.

TCL script just splits and putchan the return of the python script:

mumble.tcl
Code: Select all
#mumble.tcl version 0.3 by Arto Puranen

# Reply to triggers on these channels
set mumble(channellist) {#channel1 #channel2}

# Binds
bind pub - !m mumble

# python executable
set mumble(cmdpython) "/usr/bin/python"

# python script
set mumble(info) "/home/puke/eggdrop/scripts/python/mumble.py"

# If mumble(channellist) is empty, all channels apply
if {$mumble(channellist) == ""} {
   set mumble(channellist) [channels]
}

##***********##
## The Stuff ##
##***********##

proc mumble {nick uhost hand chan arg} {
    global mumble

    if {[lsearch [string toupper $mumble(channellist)] [string toupper $chan]] == -1} {
        return 0
    }
   
    set html [exec $mumble(cmdpython) $mumble(info) 2> /dev/null]
   
    #putchan $chan "$html"
   
    set y [llength $html]
    #putchan $chan "$y"
    for {set x 0} {$x<$y} {incr x} {
        set line [lindex $html $x]
        putchan $chan "$line"
    }
}


set mumble(versio) "0.3"
putlog "mumble.tcl v$mumble(versio) by Arto Puranen"


Python script finds users from servers and creates proper output for tcl script. This script works from shell too (~ $ python mumble.py)
- Added mumble 1.2.3 support

mumble.py
Code: Select all
# Author Arto Puranen
# Thanks to svedrin (author of mumble-django)

__version__ = 'Mumble.py ver 1.2'

###
### configs
###

# The first is Ice connection string to a server.
# The second is server name to be printed to the irc channel.
servConn = [['Meta:tcp -h 127.0.0.1 -p 6502', 'nahka'],
            ['Meta:tcp -h xx.yy.zzz.yx -p 6502', 'nolla']]

# No users on the mumble servers then print this
emptyOutput = 'None'

# Exclude servers by server registername
exServ = ['kalju']

# Exclude channels by channel name
exChan = ['']

# No response from a server message
noRespMess = 'ei vastaa'

# Murmur.ice from mumble ver >= 1.2.3 (1 = true; 0 = false)
iceVer = 0

# Murmur.ice path
icePath = '/usr/share/slice'

###
### config end
###

import sys
import traceback
import Ice
import os


class ice():

    def __init__(self, iceconn, iceVer, icePath):
        self.output = {}
        try:
            slicefile = 'Murmur.ice'
            slicepath = icePath
            # load murmur module
            """ Load the slice file with the correct include dir set, if possible. """
            if hasattr(Ice, "getSliceDir"):
                icepath = Ice.getSliceDir()
            else:
                icepath = None

            if iceVer == 0:
                # use this if mumble ver (Murmur.ice) < 1.2.3
                Ice.loadSlice(os.path.join(slicepath,slicefile))
            else:
                # use this if mumble ver (Murmur.ice) >= 1.2.3
                Ice.loadSlice(os.path.join(slicepath,slicefile), ['-I' + icepath, slicefile])

            import Murmur
           
            self.idd = Ice.InitializationData()
            self.ice = Ice.initialize(self.idd)
            self.prx = self.ice.stringToProxy(iceconn)
            try:
                self.prx.ice_ping()
            except Ice.Exception:
                raise EnvironmentError( "Murmur does not appear to be listening on this address (Ice ping failed)." )
            self.meta = Murmur.MetaPrx.checkedCast(self.prx)
            self.servers = self.meta.getBootedServers()
            self.default = self.meta.getDefaultConf()
        except:
            status = 1
           

    def getPlayers(self):
        for sid in self.servers:
            if sid.getAllConf()['registername'] in self.exServ:
                continue
            channels = sid.getChannels()
            userList = sid.getUsers()
            for uid in userList:
                uidChannelId = sid.getState(uid).channel
                uidChannelName = sid.getChannelState(uidChannelId).name
                if uidChannelName in self.exChan:
                    continue
                uidUserName = sid.getState(uid).name
                if not self.output[self.serverName].has_key(uidChannelName):
                    self.output[self.serverName][uidChannelName] = []
                self.output[self.serverName][uidChannelName].append(uidUserName)
               
               
    def returnOutput(self):
        fulllist = ''
        start = r'{'
        end = r'}'
        bold = '\002'
        for s in self.output:
            if self.output[s].keys():
                channelList = self.output[s].keys()
                channelList.sort()
                for c in channelList:
                    list = '%s%s%s.%s:%s ' % (start, bold, s, c, bold)
                    userList = self.output[s][c]
                    userList.sort()
                    for u in userList:
                        list += '%s, ' % (u)
                    list = list[:-2] + '%s ' % (end)
                    fulllist += list
        return fulllist


    def close(self):
        try:
            self.ice.destroy()
            status = 0
        except:
            traceback.print_exc()
            status = 1


def main(servconn, emptyOutput, exServ, exChan, noRespMess):
    outputlist = ''
    start = r'{'
    end = r'}'
    bold = '\002'
    for s in servconn:
        try:
            serv = ice(s[0])
            serv.exServ = exServ
            serv.exChan = exChan
            serv.serverName = s[1]
            serv.output = {serv.serverName : {}}
            serv.getPlayers()
            outputlist += serv.returnOutput()
            serv.close()
        except:
            serv.close()
            outputlist += '%s%s %s%s' % (start, s[1], noRespMess, end)

    if outputlist:
        print outputlist
    else:
        outputlist = '%s%s%s%s%s' % (start, bold, emptyOutput, bold, end)
        print outputlist


main(servConn, emptyOutput, exServ, exChan, noRespMess)
purch
 
Posts: 2
Joined: Fri Nov 12, 2010 6:59 pm

Re: Eggdrop script to list mumble users

Postby purch » Tue Nov 16, 2010 5:48 pm

Mumble 1.2.3 support added
purch
 
Posts: 2
Joined: Fri Nov 12, 2010 6:59 pm


Return to Scripting

Who is online

Users browsing this forum: No registered users and 1 guest

cron