<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Mice on Natenoms Blog</title><link>https://natenom.de/tags/mice/</link><description>Recent content in Mice on Natenoms Blog</description><generator>Hugo -- gohugo.io</generator><language>de</language><copyright/><lastBuildDate>Fri, 25 Nov 2016 18:40:35 +0000</lastBuildDate><atom:link href="https://natenom.de/tags/mice/index.xml" rel="self" type="application/rss+xml"/><item><title>Edit your Mumble Servers welcome message with mice and a channel as the editor</title><link>https://natenom.de/2016/11/edit-your-mumble-servers-welcome-message-with-mice-and-a-channel-as-the-editor/</link><pubDate>Fri, 25 Nov 2016 18:40:35 +0000</pubDate><guid>https://natenom.de/2016/11/edit-your-mumble-servers-welcome-message-with-mice-and-a-channel-as-the-editor/</guid><description><![CDATA[<p>In <a  href="/2016/02/an-introduction-on-how-to-manage-your-mumble-server-murmur-through-ice-with-mice/">this article</a> I already described how to use Mice to manage your Mumble-Server.</p>
<p>Thats what I use instead of an admin interface.</p>
<p>But this is very unhandy if you want to change the welcome message (internally called welcometext) of your server because pasting much HTML code into an interactive Python shell does not work well.</p>]]></description><content:encoded><![CDATA[<p>In <a  href="/2016/02/an-introduction-on-how-to-manage-your-mumble-server-murmur-through-ice-with-mice/">this article</a> I already described how to use Mice to manage your Mumble-Server.</p>
<p>Thats what I use instead of an admin interface.</p>
<p>But this is very unhandy if you want to change the welcome message (internally called welcometext) of your server because pasting much HTML code into an interactive Python shell does not work well.</p>
<p>But one can use a trick: Load the current welcometext into a channel description, edit it with the channel editor and write it back.</p>
<p>In order to do that create a new channel, temporary or permanent. Then edit it and note the channel id you can see behind the channel name which is <strong>4268</strong> in this case:</p>
<p><a  href="/wp-content/uploads/2016/11/mumble_channel_editor.png"><img loading="lazy" class="alignnone size-large wp-image-37490" src="/wp-content/uploads/2016/11/mumble_channel_editor-600x395.png" alt="mumble_channel_editor" srcset="/wp-content/uploads/2016/11/mumble_channel_editor-600x395.png 600w, /wp-content/uploads/2016/11/mumble_channel_editor-150x99.png 150w, /wp-content/uploads/2016/11/mumble_channel_editor-300x198.png 300w, /wp-content/uploads/2016/11/mumble_channel_editor.png 715w" sizes="(max-width: 474px) 100vw, 474px" /></a></p>
<p>Close the editor. Don’t leave the channel if it is a temporary one.</p>
<p>Start mice as described <a  href="/2016/02/an-introduction-on-how-to-manage-your-mumble-server-murmur-through-ice-with-mice/">here</a> and get your server as an object, the first created server has the ID 1:</p>
<blockquote>
<pre>s1=mice.m.getServer(1)</pre>
</blockquote>
<p>Now set the current welcometext as the channel description of your new channel:</p>
<blockquote>
<pre>channel=s1.getChannelState(4268)
</blockquote>
<p>channel.description=s1.getConf(&ldquo;welcometext&rdquo;)
s1.setChannelState(channel)</pre></p>
<p>Open the channel editor again to be able to change the channel description:</p>
<p><a  href="/wp-content/uploads/2016/11/mumble_channel_editor_with_welcometext-1.png"><img loading="lazy" class="alignnone size-large wp-image-37493" src="/wp-content/uploads/2016/11/mumble_channel_editor_with_welcometext-1-600x416.png" alt="mumble_channel_editor_with_welcometext" srcset="/wp-content/uploads/2016/11/mumble_channel_editor_with_welcometext-1-600x416.png 600w, /wp-content/uploads/2016/11/mumble_channel_editor_with_welcometext-1-150x104.png 150w, /wp-content/uploads/2016/11/mumble_channel_editor_with_welcometext-1-300x208.png 300w, /wp-content/uploads/2016/11/mumble_channel_editor_with_welcometext-1-768x533.png 768w, /wp-content/uploads/2016/11/mumble_channel_editor_with_welcometext-1.png 862w" sizes="(max-width: 474px) 100vw, 474px" /></a></p>
<p>When editing is done close the editor with „OK“ and then write back the welcometext (note that the following code is one line only):</p>
<blockquote>
<pre>s1.setConf("welcometext", s1.getChannelState(4268).description)</pre>
</blockquote>
<p>The server sends the new welcome message instantly to all clients.</p>
<p>The drawback of this method is that some styles are filtered out when pressing OK which would work editing the welcometext directly. For example I cannot align paragraphs to the center in my case.</p>
<p>Another method editing the welcometext is with the help of a text file which I will describe later :)</p>]]></content:encoded></item><item><title>An introduction on how to manage your Mumble server (Murmur) through Ice with mice</title><link>https://natenom.de/2016/02/an-introduction-on-how-to-manage-your-mumble-server-murmur-through-ice-with-mice/</link><pubDate>Tue, 16 Feb 2016 18:03:34 +0000</pubDate><guid>https://natenom.de/2016/02/an-introduction-on-how-to-manage-your-mumble-server-murmur-through-ice-with-mice/</guid><description><![CDATA[<p>In the last years I have been using <a  class='urlextern'  href="https://bitbucket.org/Svedrin/mumble-django/wiki/Home">Mumble-Django</a> (MD) to configure my Mumble servers and in my opinion it is one of the best admin interfaces available.</p>
<p>But on a box with very little RAM I wanted something very simple so I started using „mice“ on <a  href="/2016/02/migration-of-my-mumble-server-hosteurope-to-digitalocean-ipv6-support/">my new server</a>.</p>]]></description><content:encoded><![CDATA[<p>In the last years I have been using <a  class='urlextern'  href="https://bitbucket.org/Svedrin/mumble-django/wiki/Home">Mumble-Django</a> (MD) to configure my Mumble servers and in my opinion it is one of the best admin interfaces available.</p>
<p>But on a box with very little RAM I wanted something very simple so I started using „mice“ on <a  href="/2016/02/migration-of-my-mumble-server-hosteurope-to-digitalocean-ipv6-support/">my new server</a>.</p>
<p><a  class='urlextern'  href="https://github.com/mumble-voip/mumble-scripts/blob/master/Helpers/mice.py">Mice</a> is a wrapper for the Ice connection to your Mumble server (also known as Murmur). Documentation about <a  class='urlextern'  href="https://wiki.mumble.info/wiki/Ice">Ice and Mumble</a> can be found here.</p>
<p>I use mice with <a  class='urlextern'  href="http://ipython.org/">ipython</a> which gives you for example the ability for tab completion.</p>
<p>BTW: I am a noob when it comes to Python so please leave a comment if the code I used in this blog post can be simplified :)</p>

<h2 id="what-you-need-to-know-when-using-mice-and-ice-in-general" data-numberify>What you need to know when using mice (and Ice in general)<a class="anchor ms-1" href="#what-you-need-to-know-when-using-mice-and-ice-in-general"></a></h2>

<h3 id="read-the-documentation-" data-numberify>Read the documentation :)<a class="anchor ms-1" href="#read-the-documentation-"></a></h3>
<p>You can either use the tab completion of ipython to get a list of methods (see below) or read the documentation from Murmur, see <a  class='urlextern'  href="https://github.com/mumble-voip/mumble/blob/master/src/murmur/Murmur.ice">Murmur.ice</a> itself or <a  class='urlextern'  href="http://mumble.sourceforge.net/slice/">its generated documentation</a>.</p>

<h3 id="instant-changes" data-numberify>Instant changes<a class="anchor ms-1" href="#instant-changes"></a></h3>
<p>It is very nice that all you change through Ice is instantly applied to your server. There is no need for a restart unlike editing the .ini file of your server (mostly murmur.ini or mumble-server.ini).</p>

<h3 id="8222global-settings8220-vs-8222local-settings8220" data-numberify>&#8222;Global settings&#8220; vs &#8222;local settings&#8220;<a class="anchor ms-1" href="#8222global-settings8220-vs-8222local-settings8220"></a></h3>
<p>But you can only change so called „local settings“, not „global settings“. The latter can be changed only in the .ini file and you need to reboot your server. Keep that in mind when you work with mice.</p>
<p>A (German) list of global and local settings can be found <a  href="https://wikiarchiv.natenom.de/mumble/benutzerhandbuch/murmur/servereinstellungen#a_globalevariablen">here (global)</a> and <a  href="https://wikiarchiv.natenom.de/mumble/benutzerhandbuch/murmur/servereinstellungen#a_lokalevariablen">here (local)</a>.</p>
<p>The list of all variables in the official Mumble wiki does not yet distinguish between local and global variables, <a  class='urlextern'  href="http://wiki.mumble.info/index.php?title=Murmur.ini">see here</a>.</p>
<p>A global setting is for example which backend for SQL Murmur should use, you can choose between MySQL and Sqlite (default).</p>
<p>A local setting is for example the name of your Mumble server (it is called „registername“).</p>

<h3 id="always-lowercase" data-numberify>Always lowercase<a class="anchor ms-1" href="#always-lowercase"></a></h3>
<p>If you change settings via „setConf“ you must always use the lowercase name of what you change.</p>
<p>For example use</p>
<pre>setConf("registername", "Name of your Mumble-Server")</pre>
<p>instead of</p>
<pre><del>setConf("registerName", "Name of your Mumble-Server")</del></pre>
<p>Murmur won’t recognize mixed case written settings set through Ice.</p>
<p>Note: The case isn’t important in your murmur.ini file.</p>

<h3 id="always-use-strings-for-setconf" data-numberify>Always use strings for setConf<a class="anchor ms-1" href="#always-use-strings-for-setconf"></a></h3>
<p>The method setConf requires alway strings as values, <a  class='urlextern'  href="http://mumble.sourceforge.net/slice/1.3.0/Murmur/Server.html#setConf">see here</a>.</p>
<p>For example the next will not work:</p>
<pre><del>s1.setConf("users", 127)</del></pre>
<p>But this works:</p>
<pre>s1.setConf("users", "127")</pre>

<h2 id="before-you-start" data-numberify>Before you start<a class="anchor ms-1" href="#before-you-start"></a></h2>
<p>Download <a  class='urlextern'  href="https://github.com/mumble-voip/mumble-scripts/blob/master/Helpers/mice.py">mice.py</a> onto your server and edit it.</p>
<p>Change the default settings like host, port and most important the „secret“ which is the equivalent of „icesecret“ or „icesecretwrite“ in your „murmur.ini“ or „mumble-server.ini“.</p>

<h2 id="encoding-version" data-numberify>Encoding version<a class="anchor ms-1" href="#encoding-version"></a></h2>
<p>If you get an error like</p>
<pre>UnknownLocalException: exception ::Ice::UnknownLocalException
{
unknown = ../../include/Ice/BasicStream.h:175: Ice::UnsupportedEncodingException:
protocol error: unsupported encoding version: 1.1
(can only support encodings compatible with version 1.1)</pre>
<p>change the prxstr value in line 52 from</p>
<pre>prxstr = "Meta:tcp -h %s -p %d -t 1000" % (host, port)</pre>
<p>to</p>
<pre>prxstr = "Meta -e 1.0:tcp -h %s -p %d -t 1000" % (host, port)</pre>
<p>in order to force protocol encoding in version 1.0.</p>

<h2 id="lets-start-with-mice" data-numberify>Lets start with mice<a class="anchor ms-1" href="#lets-start-with-mice"></a></h2>
<p>Change into the directory where your mice.py script is located. Then start ipython:</p>
<pre>mymumbleserver # ls .</pre>
<pre>mice.py</pre>
<pre>mymumbleserver # ipython</pre>
<pre>Python 2.7.9 (default, Mar 1 2015, 18:22:53)
Type "copyright", "credits" or "license" for more information.

IPython 2.3.0 -- An enhanced Interactive Python.
? -&gt; Introduction and overview of IPython's features.
%quickref -&gt; Quick reference.
help -&gt; Python's own help system.
object? -&gt; Details about 'object', use 'object??' for extra details.

In [1]:</pre>
<p>Import mice:</p>
<pre>import mice</pre>
<pre>Using default settings.
Import ice... Done
Trying to retrieve slice dynamically from server... Success
Import dynamically compiled murmur class... Done
Establish ice connection... [protected]... Done
Murmur object accessible via 'mice.murmur' or 'mice.m'
3 booted servers in 'mice.sl', 'mice.s' contains 's/1 -t -e 1.0:tcp -h 127.0.0.1 -p 6502'
--- Reached interactive mode ---</pre>
<p>Now you are ready to start…</p>

<h2 id="some-examples-for-working-with-mice" data-numberify>Some examples for working with mice<a class="anchor ms-1" href="#some-examples-for-working-with-mice"></a></h2>

<h3 id="get-list-of-all-servers" data-numberify>Get list of all servers<a class="anchor ms-1" href="#get-list-of-all-servers"></a></h3>
<p>There are three Mumble servers available, lets get a list of them:</p>
<pre>mice.m.getAllServers()</pre>
<pre>[s/1 -t -e 1.0:tcp -h 127.0.0.1 -p 6502,
s/3 -t -e 1.0:tcp -h 127.0.0.1 -p 6502,
s/5 -t -e 1.0:tcp -h 127.0.0.1 -p 6502]</pre>

<h3 id="create-an-object-for-the-server-you-want-to-work-with" data-numberify>Create an object for the server you want to work with<a class="anchor ms-1" href="#create-an-object-for-the-server-you-want-to-work-with"></a></h3>
<p>I want to work with the first one, so I get it into a new object:</p>
<pre>s1 = mice.m.getServer(1)</pre>

<h3 id="list-all-methods-for-your-server" data-numberify>List all methods for your server<a class="anchor ms-1" href="#list-all-methods-for-your-server"></a></h3>
<pre>s1.&lt;PRESS TAB&gt;</pre>
<pre>s1.
Display all 215 possibilities? (y or n)
s1.addCallback                   s1.end_getChannelState           s1.ice_datagram
s1.addChannel                    s1.end_getChannels               s1.ice_encodingVersion
s1.addContextCallback            s1.end_getConf                   s1.ice_endpointSelection
s1.addUserToGroup                s1.end_getLog                    s1.ice_endpoints
s1.begin_addCallback             s1.end_getLogLen                 s1.ice_facet
s1.begin_addChannel              s1.end_getRegisteredUsers        s1.ice_flushBatchRequests
[..]</pre>
<p>The most interesting methods start with „get“ and „set“.</p>

<h3 id="check-whether-the-server-is-running" data-numberify>Check whether the server is running<a class="anchor ms-1" href="#check-whether-the-server-is-running"></a></h3>
<pre>s1.isRunning()</pre>
<pre>Out[6]: True</pre>

<h3 id="print-the-complete-configuration" data-numberify>Print the complete configuration<a class="anchor ms-1" href="#print-the-complete-configuration"></a></h3>
<pre>s1.getAllConf()</pre>
<pre>Out[7]:
{'': '',
'allowhtml': 'true',
'allowping': 'true',
'autobanattempts': '10',
'bandwidth': '128000',
'bonjour': 'false',
'boot': 'true',
[...]</pre>

<h3 id="print-only-a-specific-setting" data-numberify>Print only a specific setting<a class="anchor ms-1" href="#print-only-a-specific-setting"></a></h3>
<pre>s1.getConf("registername")</pre>
<pre>Out[8]: 'Natemologie-Zentrum (Opus)'</pre>

<h3 id="change-settings" data-numberify>Change settings<a class="anchor ms-1" href="#change-settings"></a></h3>
<pre>s1.setConf("users", "150")</pre>

<h3 id="restart-the-server" data-numberify>Restart the server<a class="anchor ms-1" href="#restart-the-server"></a></h3>
<pre>s1.stop()
s1.start()</pre>

<h3 id="change-the-welcome-message" data-numberify>Change the welcome message<a class="anchor ms-1" href="#change-the-welcome-message"></a></h3>
<pre>s1.setConf("welcometext", "Welcome to my server")</pre>

<h3 id="lets-send-a-message-to-a-specific-channel-on-your-server" data-numberify>Lets send a message to a specific channel on your server<a class="anchor ms-1" href="#lets-send-a-message-to-a-specific-channel-on-your-server"></a></h3>
<p>In the Ice documentation we can read that the sendMessageChannel needs the following arguments:</p>
<pre>s1.sendMessageChannel(int channelid, bool tree, string text)</pre>
<p>If the „tree“ parameter is True the message is sent to all subchannels of the channel you send a message to.</p>
<p>So we can use for example:</p>
<pre>s1.sendMessageChannel(123, False, "Test message to channel with id 123")</pre>
<p>On the Mumble server we get:</p>
<pre>[07:02:47] (Channel) Server: Test message to channel with id 530</pre>

<h3 id="now-a-so-called-tree-message-to-all-channels-on-the-server" data-numberify>Now a so called tree message to all channels on the server<a class="anchor ms-1" href="#now-a-so-called-tree-message-to-all-channels-on-the-server"></a></h3>
<p>Now we write a so called tree message (see above):</p>
<pre>s1.sendMessageChannel(0, True, "This is a test message to all channels on your server")</pre>
<p>0 is the id of the root channel of a server.</p>
<p>Every user on your server gets:</p>
<pre>[07:04:04] (Tree) Server: This is a test message to all channels on your server</pre>
<p>You can also use HTML and CSS to style your message:</p>
<pre>s1.sendMessageChannel(0, True, "&lt;span style='color:red;font-size:12px;'&gt;This is a test message to all channels o
n your server&lt;/span&gt;")</pre>

<h3 id="get-the-server-uptime-in-seconds" data-numberify>Get the server uptime in seconds<a class="anchor ms-1" href="#get-the-server-uptime-in-seconds"></a></h3>
<pre>s1.getUptime()</pre>
<pre>Out[71]: 104157L</pre>

<h3 id="get-a-list-of-current-online-users" data-numberify>Get a list of current online users<a class="anchor ms-1" href="#get-a-list-of-current-online-users"></a></h3>
<pre>for k,v in s1.getUsers().iteritems():
    print(k, v.name)</pre>
<pre>(194L, 'Natenom')
(197L, 'Music-Bot 2')
(198L, 'Music-Bot 5')
(199L, 'Music-Bot 3')
(200L, 'Music-Bot 1')
(201L, 'Music-Bot 4')
(19L, 'MetalRubyOceanBot')
(126L, 'someone')</pre>
<p>The first number is the current session ID of a user.</p>
<p>But there is more information about a user; when you write the code above press <TAB> after v. …</p>
<p>For example:</p>
<pre>for k,v in s1.getUsers().iteritems():
    print(k, v.name, v.os, v.osversion, v.release, v.selfMute, v.idlesecs)</pre>
<pre>(194L, 'Natenom', 'X11', 'Arch Linux', '1.3.0', False, 1L)
(197L, 'Music-Bot 2', 'Linux x86_64', '#1 SMP Wed Feb 10 09:52:06 CET 2016', 'mumble-ruby 1.1.2', False, 3360L)
[...]</pre>

<h3 id="kick-a-user" data-numberify>Kick a user<a class="anchor ms-1" href="#kick-a-user"></a></h3>
<p>Lets kick Natenom, referenced by his current session id (194):</p>
<pre>s1.kickUser(194, "Just a test :P")</pre>
<pre>[07:28:23] You were kicked from the server by the server: Just a test :P.</pre>
<p>Note that the session id is limited to the current session; it changes when Natenom reconnects.</p>

<h3 id="playing-with-a-specific-user" data-numberify>Playing with a specific user<a class="anchor ms-1" href="#playing-with-a-specific-user"></a></h3>
<p>Create an object with a specific user, lets say Natenom:</p>
<pre>for k,v in s1.getUsers().iteritems():
    print(k, v.name, v.os, v.osversion, v.release, v.selfMute, v.idlesecs)</pre>
<pre>(1L, 'Natenom', 'X11', 'Arch Linux', '1.3.0', False, 12L)</pre>
<pre>Natenom = s1.getUsers()[1] #1 is the session id from above</pre>
<p>Now type Natenom. and press <TAB>.</p>
<pre>Natenom.&lt;press TAB&gt;</pre>
<pre>Natenom.address          Natenom.idlesecs
[...]</pre>
<p>The object „Natenom“ can also be used to change his current state with the help of setState().</p>
<p>First modify the object:</p>
<pre>Natenom.name = "Ice is cool :P"</pre>
<p>Nothing happened yet on the server; now:</p>
<pre>s1.setState(Natenom)</pre>
<p>Now Natenom was renamed on the server :)</p>
<p><em>BTW: When using Ice to rename users you are not limited to characters allowed by „username“ setting. The same applies for channel names.</em></p>
<p>Lets deaf Natenom server side:</p>
<pre>Natenom.deaf = True
s1.setState(Natenom)</pre>
<p>Done.</p>
<p><a href="/wp-content/uploads/2016/02/ice_is_cool.png" rel="attachment wp-att-34322"><img loading="lazy" class="alignnone size-full wp-image-34322" src="/wp-content/uploads/2016/02/ice_is_cool.png" alt="ice_is_cool" srcset="/wp-content/uploads/2016/02/ice_is_cool.png 371w, /wp-content/uploads/2016/02/ice_is_cool-150x38.png 150w, /wp-content/uploads/2016/02/ice_is_cool-300x75.png 300w" sizes="(max-width: 371px) 100vw, 371px" /></a></p>

<h3 id="work-with-channels" data-numberify>Work with channels<a class="anchor ms-1" href="#work-with-channels"></a></h3>
<p>In order to create a new channel you need to know the ID of the parent channel; 0 in this case is the root channel so the next command will create a main channel.</p>
<pre>s1.addChannel("Name your channel", 0)</pre>
<pre>Out[13]: 3696L</pre>
<p>The output gives you the ID of the new channel, 3696. You need it to reference this channel in other commands.</p>
<pre>s1.getChannelState(3696)</pre>
<pre>{
id = 3696
name = name of new channel
parent = 0
links =
{
}
description =
temporary = False
position = 0
}</pre>
<pre>mychannel = s1.getChannelState(3696)
mychannel.description = "You can use HTML and CSS in channel descriptions if allowhtml is set to true on your se
rver&lt;br /&gt;&lt;br /&gt;&lt;a href='https://natenom.de'&gt;Link to my blog&lt;/a&gt;" 
s1.setChannelState(mychannel)</pre>
<p><a href="/wp-content/uploads/2016/02/working_with_ice.png" rel="attachment wp-att-34339"><img loading="lazy" class="alignnone size-full wp-image-34339" src="/wp-content/uploads/2016/02/working_with_ice.png" alt="working_with_ice" srcset="/wp-content/uploads/2016/02/working_with_ice.png 488w, /wp-content/uploads/2016/02/working_with_ice-150x51.png 150w, /wp-content/uploads/2016/02/working_with_ice-300x102.png 300w" sizes="(max-width: 488px) 100vw, 488px" /></a></p>

<h2 id="done8230" data-numberify>Done&#8230;<a class="anchor ms-1" href="#done8230"></a></h2>
<p>Have fun with experimenting what else you can do with Mice :)</p>
<p>It is very powerful.</p>]]></content:encoded></item></channel></rss>