Index: code/branches/console/src/core/CMakeLists.txt
===================================================================
--- code/branches/console/src/core/CMakeLists.txt	(revision 1269)
+++ code/branches/console/src/core/CMakeLists.txt	(revision 1276)
@@ -28,4 +28,5 @@
   TclBind.cc
   TclThreadManager.cc
+  IRC.cc
 )
 
Index: code/branches/console/src/core/CommandExecutor.cc
===================================================================
--- code/branches/console/src/core/CommandExecutor.cc	(revision 1269)
+++ code/branches/console/src/core/CommandExecutor.cc	(revision 1276)
@@ -100,7 +100,7 @@
     {
         if (newline)
-            std::cout << text << std::endl;
+            COUT(0) << text << std::endl;
         else
-            std::cout << text;
+            COUT(0) << text;
     }
 
@@ -412,10 +412,10 @@
         if (evaluation.bEvaluatedParams_ && evaluation.evaluatedExecutor_)
         {
-std::cout << "CE_execute (evaluation): " << evaluation.evaluatedExecutor_->getName() << " " << evaluation.param_[0] << " " << evaluation.param_[1] << " " << evaluation.param_[2] << " " << evaluation.param_[3] << " " << evaluation.param_[4] << std::endl;
+            COUT(4) << "CE_execute (evaluation): " << evaluation.evaluatedExecutor_->getName() << " " << evaluation.param_[0] << " " << evaluation.param_[1] << " " << evaluation.param_[2] << " " << evaluation.param_[3] << " " << evaluation.param_[4] << std::endl;
             (*evaluation.evaluatedExecutor_)(evaluation.param_[0], evaluation.param_[1], evaluation.param_[2], evaluation.param_[3], evaluation.param_[4]);
             return true;
         }
 
-std::cout << "CE_execute: " << evaluation.processedCommand_ << "\n";
+        COUT(4) << "CE_execute: " << evaluation.processedCommand_ << "\n";
         switch (evaluation.state_)
         {
Index: code/branches/console/src/core/CorePrereqs.h
===================================================================
--- code/branches/console/src/core/CorePrereqs.h	(revision 1269)
+++ code/branches/console/src/core/CorePrereqs.h	(revision 1276)
@@ -119,4 +119,5 @@
   class InputHandlerGUI;
   class InputManager;
+  class IRC;
   template <class T>
   class Iterator;
@@ -135,4 +136,5 @@
   class ObjectListElement;
   class OrxonoxClass;
+  class OutputBuffer;
   class OutputHandler;
   class Shell;
@@ -140,4 +142,5 @@
   class SubclassIdentifier;
   class TclBind;
+  struct TclInterpreterBundle;
   class Tickable;
   template <class T, class O>
Index: code/branches/console/src/core/IRC.cc
===================================================================
--- code/branches/console/src/core/IRC.cc	(revision 1276)
+++ code/branches/console/src/core/IRC.cc	(revision 1276)
@@ -0,0 +1,141 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include <boost/thread/thread.hpp>
+
+#include "IRC.h"
+#include "ConsoleCommand.h"
+#include "TclThreadManager.h"
+#include "CoreIncludes.h"
+#include "util/Convert.h"
+
+#define IRC_TCL_THREADID 1421421421
+
+namespace orxonox
+{
+    ConsoleCommand(IRC, say,  AccessLevel::User, true);
+    ConsoleCommand(IRC, msg,  AccessLevel::User, false);
+    ConsoleCommand(IRC, nick, AccessLevel::User, false);
+
+    IRC* instance_irc = &IRC::getInstance();
+
+    IRC::IRC()
+    {
+        RegisterRootObject(IRC);
+        this->bundle_ = 0;
+    }
+
+    void IRC::initialize()
+    {
+        unsigned int threadID = (unsigned int)IRC_TCL_THREADID;
+        TclThreadManager::createID(threadID);
+        this->bundle_ = TclThreadManager::getInstance().getInterpreterBundle(threadID);
+
+        try
+        {
+            this->bundle_->interpreter_->def("orxonox::irc::say", IRC::tcl_say, Tcl::variadic());
+            this->bundle_->interpreter_->def("orxonox::irc::privmsg", IRC::tcl_privmsg, Tcl::variadic());
+            this->bundle_->interpreter_->def("orxonox::irc::action", IRC::tcl_action, Tcl::variadic());
+            this->bundle_->interpreter_->def("orxonox::irc::info", IRC::tcl_info, Tcl::variadic());
+        }
+        catch (Tcl::tcl_error const &e)
+        {   COUT(1) << "Tcl (IRC) error: " << e.what();   }
+        catch (std::exception const &e)
+        {   COUT(1) << "Error while initializing Tcl (IRC): " << e.what();   }
+
+        this->nickname_ = "orx" + getConvertedValue<int, std::string>((unsigned int)rand());
+        TclThreadManager::execute(threadID, "set nickname " + this->nickname_);
+        TclThreadManager::execute(threadID, "source irc.tcl");
+    }
+
+    IRC& IRC::getInstance()
+    {
+        static IRC instance;
+        return instance;
+    }
+
+    bool IRC::eval(const std::string& command)
+    {
+        if (!IRC::getInstance().bundle_)
+        {
+            IRC::getInstance().initialize();
+            COUT(1) << "Error: IRC client wasn't yet initialized, please try again." << std::endl;
+            return false;
+        }
+
+        try
+        {
+            IRC::getInstance().bundle_->interpreter_->eval(command);
+            return true;
+        }
+        catch (Tcl::tcl_error const &e)
+        {   COUT(1) << "Tcl (IRC) error: " << e.what();   }
+        catch (std::exception const &e)
+        {   COUT(1) << "Error while executing Tcl (IRC): " << e.what();   }
+
+        return false;
+    }
+
+    void IRC::say(const std::string& message)
+    {
+        if (IRC::eval("irk::say $conn #orxonox {" + message + "}"))
+            IRC::tcl_say(Tcl::object(), Tcl::object(IRC::getInstance().nickname_), Tcl::object(message));
+    }
+
+    void IRC::msg(const std::string& channel, const std::string& message)
+    {
+        if (IRC::eval("irk::say $conn " + channel + " {" + message + "}"))
+            IRC::tcl_privmsg(Tcl::object(channel), Tcl::object(IRC::getInstance().nickname_), Tcl::object(message));
+    }
+
+    void IRC::nick(const std::string& nickname)
+    {
+        if (IRC::eval("irk::nick $conn " + nickname))
+            IRC::getInstance().nickname_ = nickname;
+    }
+
+    void IRC::tcl_say(Tcl::object const &channel, Tcl::object const &nick, Tcl::object const &args)
+    {
+        COUT(0) << "IRC> " << nick.get() << ": " << stripEnclosingBraces(args.get()) << std::endl;
+    }
+
+    void IRC::tcl_privmsg(Tcl::object const &query, Tcl::object const &nick, Tcl::object const &args)
+    {
+        COUT(0) << "IRC (" << query.get() << ")> " << nick.get() << ": " << stripEnclosingBraces(args.get()) << std::endl;
+    }
+
+    void IRC::tcl_action(Tcl::object const &channel, Tcl::object const &nick, Tcl::object const &args)
+    {
+        COUT(0) << "IRC> * " << nick.get() << " " << stripEnclosingBraces(args.get()) << std::endl;
+    }
+
+    void IRC::tcl_info(Tcl::object const &channel, Tcl::object const &args)
+    {
+        COUT(0) << "IRC> --> " << stripEnclosingBraces(args.get()) << std::endl;
+    }
+}
Index: code/branches/console/src/core/IRC.h
===================================================================
--- code/branches/console/src/core/IRC.h	(revision 1276)
+++ code/branches/console/src/core/IRC.h	(revision 1276)
@@ -0,0 +1,66 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _IRC_H__
+#define _IRC_H__
+
+#include "CorePrereqs.h"
+
+#include "OrxonoxClass.h"
+#include "cpptcl/CppTcl.h"
+
+namespace orxonox
+{
+    class _CoreExport IRC : public OrxonoxClass
+    {
+        public:
+            static IRC& getInstance();
+
+            static void say(const std::string& message);
+            static void msg(const std::string& channel, const std::string& message);
+            static void nick(const std::string& nickname);
+
+            static void tcl_say(Tcl::object const &channel, Tcl::object const &nick, Tcl::object const &args);
+            static void tcl_privmsg(Tcl::object const &query, Tcl::object const &nick, Tcl::object const &args);
+            static void tcl_action(Tcl::object const &channel, Tcl::object const &nick, Tcl::object const &args);
+            static void tcl_info(Tcl::object const &channel, Tcl::object const &args);
+
+        private:
+            static bool eval(const std::string& command);
+            void initialize();
+
+            IRC();
+            IRC(const IRC& other);
+            ~IRC() {}
+
+            TclInterpreterBundle* bundle_;
+            std::string nickname_;
+    };
+}
+
+#endif /* _IRC_H__ */
Index: code/branches/console/src/core/TclBind.cc
===================================================================
--- code/branches/console/src/core/TclBind.cc	(revision 1269)
+++ code/branches/console/src/core/TclBind.cc	(revision 1276)
@@ -35,4 +35,5 @@
 #include "TclThreadManager.h"
 #include "TclBind.h"
+#include "util/String.h"
 
 namespace orxonox
@@ -104,9 +105,7 @@
     std::string TclBind::tcl_query(Tcl::object const &args)
     {
-std::cout << "Tcl_query: args: " << args.get() << std::endl;
-        std::string command = args.get();
+        COUT(4) << "Tcl_query: " << args.get() << std::endl;
 
-        while (command.size() >= 2 && command[0] == '{' && command[command.size() - 1] == '}')
-            command = command.substr(1, command.size() - 2);
+        std::string command = stripEnclosingBraces(args.get());
 
         if (!CommandExecutor::execute(command, false))
@@ -121,9 +120,6 @@
     void TclBind::tcl_execute(Tcl::object const &args)
     {
-std::cout << "Tcl_execute: args: " << args.get() << std::endl;
-        std::string command = args.get();
-
-        while (command.size() >= 2 && command[0] == '{' && command[command.size() - 1] == '}')
-            command = command.substr(1, command.size() - 2);
+        COUT(4) << "Tcl_execute: " << args.get() << std::endl;
+        std::string command = stripEnclosingBraces(args.get());
 
         if (!CommandExecutor::execute(command, false))
@@ -150,8 +146,5 @@
     void TclBind::bgerror(std::string error)
     {
-        while (error.size() >= 2 && error[0] == '{' && error[error.size() - 1] == '}')
-            error = error.substr(1, error.size() - 2);
-
-        COUT(1) << "Tcl background error: " << error << std::endl;
+        COUT(1) << "Tcl background error: " << stripEnclosingBraces(error) << std::endl;
     }
 
Index: code/branches/console/src/core/TclThreadManager.cc
===================================================================
--- code/branches/console/src/core/TclThreadManager.cc	(revision 1269)
+++ code/branches/console/src/core/TclThreadManager.cc	(revision 1276)
@@ -58,5 +58,5 @@
     ConsoleCommand(TclThreadManager, flush,     AccessLevel::None, false);
 
-    TclThreadManager* instance = &TclThreadManager::getInstance();
+    TclThreadManager* instance_tclthreadmanager = &TclThreadManager::getInstance();
 
     TclThreadManager::TclThreadManager()
@@ -92,4 +92,13 @@
         COUT(0) << "Created new Tcl-interpreter with ID " << TclThreadManager::getInstance().threadCounter_ << std::endl;
         return TclThreadManager::getInstance().threadCounter_;
+    }
+
+    unsigned int TclThreadManager::createID(unsigned int threadID)
+    {
+        unsigned int temp = TclThreadManager::getInstance().threadCounter_;
+        TclThreadManager::getInstance().threadCounter_ = threadID - 1;
+        TclThreadManager::create();
+        TclThreadManager::getInstance().threadCounter_ = temp;
+        return threadID;
     }
 
@@ -136,8 +145,5 @@
     void TclThreadManager::execute(unsigned int threadID, const std::string& _command)
     {
-        std::string command = _command;
-        while (command.size() >= 2 && command[0] == '{' && command[command.size() - 1] == '}')
-            command = command.substr(1, command.size() - 2);
-
+        std::string command = stripEnclosingBraces(_command);
 
         if (threadID == 0)
@@ -237,27 +243,15 @@
     void TclThreadManager::tcl_execute(Tcl::object const &args)
     {
-        std::string command = args.get();
-        while (command.size() >= 2 && command[0] == '{' && command[command.size() - 1] == '}')
-            command = command.substr(1, command.size() - 2);
-
-        TclThreadManager::getInstance().pushCommandToQueue(command);
+        TclThreadManager::getInstance().pushCommandToQueue(stripEnclosingBraces(args.get()));
     }
 
     std::string TclThreadManager::tcl_query(int querierID, Tcl::object const &args)
     {
-        std::string command = args.get();
-        while (command.size() >= 2 && command[0] == '{' && command[command.size() - 1] == '}')
-            command = command.substr(1, command.size() - 2);
-
-        return TclThreadManager::getInstance().evalQuery((unsigned int)querierID, command);
+        return TclThreadManager::getInstance().evalQuery((unsigned int)querierID, stripEnclosingBraces(args.get()));
     }
 
     std::string TclThreadManager::tcl_crossquery(int querierID, int threadID, Tcl::object const &args)
     {
-        std::string command = args.get();
-        while (command.size() >= 2 && command[0] == '{' && command[command.size() - 1] == '}')
-            command = command.substr(1, command.size() - 2);
-
-        return TclThreadManager::getInstance().evalQuery((unsigned int)querierID, (unsigned int)threadID, command);
+        return TclThreadManager::getInstance().evalQuery((unsigned int)querierID, (unsigned int)threadID, stripEnclosingBraces(args.get()));
     }
 
@@ -349,4 +343,19 @@
 
         this->forceCommandToFrontOfQueue("error " + error);
+    }
+
+    void TclThreadManager::debug(const std::string& error)
+    {
+        if (boost::this_thread::get_id() != this->threadID_)
+        {
+            boost::mutex::scoped_lock queue_lock(this->orxonoxInterpreterBundle_.queueMutex_);
+            if (this->orxonoxInterpreterBundle_.queue_.size() >= TCLTHREADMANAGER_MAX_QUEUE_LENGTH)
+            {
+                boost::this_thread::yield();
+                return;
+            }
+        }
+
+        this->forceCommandToFrontOfQueue("debug " + error);
     }
 
@@ -506,4 +515,5 @@
                     if (successfullyLocked)
                     {
+                        this->debug("TclThread_query: " + command);
                         try
                         {   output = (std::string)target->interpreter_->eval(command);   }
@@ -566,5 +576,5 @@
     void tclThread(TclInterpreterBundle* interpreterBundle, std::string command)
     {
-std::cout << "tclthreadm executes " << command << std::endl;
+        TclThreadManager::getInstance().debug("TclThread_execute: " + command);
         boost::mutex::scoped_lock interpreter_lock(interpreterBundle->interpreterMutex_);
         try
Index: code/branches/console/src/core/TclThreadManager.h
===================================================================
--- code/branches/console/src/core/TclThreadManager.h	(revision 1269)
+++ code/branches/console/src/core/TclThreadManager.h	(revision 1276)
@@ -73,4 +73,5 @@
 
             static unsigned int create();
+            static unsigned int createID(unsigned int threadID);
             static void destroy(unsigned int threadID);
             static void execute(unsigned int threadID, const std::string& command);
@@ -89,4 +90,5 @@
             std::string dumpList(const std::list<unsigned int>& list);
             void error(const std::string& error);
+            void debug(const std::string& error);
 
             void pushCommandToQueue(const std::string& command);
