Getting LYNC or OFFICE COMMUNICATOR chat to work on linux (using weechat irc client)
We are going to setup an IRC client (a trivial one, meaning you can do it with anyone but im using weechat) to talk with bitlbee. Bitlbee is an irc gateway that allows you to talk via IRC to MSN chat, or GOOGLE chat, or SKYPE, but specifically for this example your WORK NETWORK that utilizes MICROSOFT EXCHANGE and specifically Lync.
Good links that I quote in here:
SIPE and OCS are the protocols used for the chat. SIPE is actually just the library that allows it to happen for linux.
NOTE ABOUT COMMANDS:
# are commands in bash/your shell
 are commands in weechat or your favorite IRC client
The # and  are just my representation of the prompt, everyone will have a different prompt, so thats just a generic representation.
INITIAL SETUP AND INSTALLATION
I hear rumors on certain debian versions (like 6.0) the wrong version of bitlbee installs (like version 1 something) and you wont be able to do any of this (Without some big hassles). In this case I have the following system.
# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 7.0 (wheezy)"
# uname -a
Linux ram 2.6.32-042stab078.27 #1 SMP Mon Jul 1 20:48:07 MSK 2013 x86_64 GNU/Linux
HOW TO INSTALL:
# apt-get install bitlbee-libpurple
# apt-get install pidgin-sipe
It should install bitlbee-common with it
# dpkg -l | egrep "bitlbee|sipe"
ii bitlbee-common 3.0.5-1.2 all An IRC to other chat networks gateway (common files/docs)
ii bitlbee-libpurple 3.0.5-1.2 amd64 An IRC to other chat networks gateway (using libpurple)
ii pidgin-sipe 1.13.1-2 amd64 Pidgin protocol plugin to connect to MS Office Communicator
Note there is the opportunity to install just "bitlbee" without the -libpurple extension, dont install that or you might not get sipe. (to think of it maybe you are okay, with bitlbee-libpurple i cant get gtalk to work but I can get OCS/SIPE to work, but maybe with regular bitlbee and pidgin-sipe I can get gtalk and sipe/OCS to work)
If you just install bitlbee then you will have problems because the "bitlbee" executable is ran from the "bitlbee-libpurple" package instead of the "bitlbee" package.
HERE IS PROOF THAT BITLBEE IS RUNNING OFF "bitlbee-libpurple" (THAT FOR PEOPLE THAT HAVING IT RUN OFF JUST "bitlbee"):
# which bitlbee
# dpkg -S /usr/sbin/bitlbee
MAKE SURE BITLBEE IS RUNNING AND LISTENING ON PORT 6667:
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp6 0 0 :::6667 :::* LISTEN 2505/bitlbee
You should see bitlbee on port 6667
# apt-get install weechat
MY VERSION OF WEECHAT:
# dpkg -l | egrep weechat
ii weechat 0.3.8-1+deb7u1 all Fast, light and extensible chat client
ii weechat-core 0.3.8-1+deb7u1 amd64 Fast, light and extensible chat client - core files
ii weechat-curses 0.3.8-1+deb7u1 amd64 Fast, light and extensible chat client - console client
ii weechat-plugins 0.3.8-1+deb7u1 amd64 Fast, light and extensible chat client - plugins
Start weechat (not weechat but its weechat-ncurses)
Once in weechat you will be automatically in window 1 (There will be more windows as you connect to other servers and talk to people, and do oauth authentication - in weechat however a window is called a buffer)
 /connect localhost 6667
Then that should connect you to bitlbee and you should see bitlbees hello messages. You should now have 2 buffers (windows). To switch between buffers
 /buffer 1
 /buffer 2
At buffer 2 you should have bitlbee. Also CONTROL-N and CONTROL-P to cycle through them, and numerically ALT+[0+9]
Make sure your on your bitlbee buffer (which you can cycle to with above keys or use /buffer 2 - most likely its buffer 2 for you)
Let give your bitlbee account a password (no need for username)
 register YOUR_PASSWORD
Just put in anything for YOUR_PASSWORD, you can leave it as YOUR_PASSWORD if you want just remember it. Either way later we will setup autoconnect so you dont need to remember it that much (i would still save the YOUR_PASSWORD in your favorite password manager)
SETTING UP ACCOUNT:
From here on out we can setup FACEBOOK CHAT, GOOGLE TALK, OCS. Lets do OCS (Office communicator, exchange, whatever)
 account add sipe emailaddress,DOMAIN\\username PASSWORD
 account on
Example (imagine a john doe that works at yahoo and maybe yahoo uses exchange who knows so they have LYNC communicator, now adays every big company has the full MICROSOFT EXCHANGE package):
 account add sipe firstname.lastname@example.org,YAHOO\\jdoe Somepassword!!!
 account one
Side note: notice how we have to escape the \ with another \ for a total of \\, also notice how the password doesnt need "" or '' around it. Maybe because I didnt use special characters. If you get auth fail messages then try to escape the funny characters. I know for a fact that ! dont need escaping
The "account on" will enable the account. If the certificate provided by your domain is untrusted then it will ask to type "yes" or "no" to accept it. Obviously just type "yes" without the quotes and hit ENTER.
 /server add im localhost/6667 -autoconnect
 /set irc.server.im.command "/msg &bitlbee identify YOUR_PASS"
This will ensure you can get into the same account after without typing in your password and having to do all of the account enteries again manually.
To test it exit it and get back into weechat:
It should log you right back into bitlbee with your OCS account.
IF YOU GET SOME READ ERROR:
First make sure you do the SAVE COMMANDS then
Exit out of weechat
Run this command on your shell and then restart bitlbee:
# export NSS_SSL_CBC_RANDOM_IV=0
Then can permenantly set it up by putting it in one of the boot up scripts (like /etc/rc.local)
HOW CAN YOU TELL SUCCESS:
You will see all of your Lync/OCS friends populating in the nicklist (which is on the right hand side by default)
To setup facebook:
 account add jabber email@example.com
 acc fb set oauth on
 acc fb on
 acc fb set nick_source full_name
Side note: Where "fb" is the account tag. You can put the accounts number in there instead. To get account numbers "account list"
You should see a new buffer window which will contain a URL (Switch to new buffer to see the URL. Switch with above keys, CONTROL-N or CONTROL-P, or buffer commands /buffer #). This URL is used to setup OAuth authentication (You might need to copy the URL to notepad and rearrange it so it looks like a URL). Load up the URL in a browser and follow the instructions for allowing bitlbee access. You will receive a code which you then need to send to the buffer which gave you the URL (Just copy the code and literally paste and hit enter into weechat). Once that is done you should now be connected to the facebook chat service. You will see the names populating in your nicklist.
To setup gtalk:
 account add jabber firstname.lastname@example.org
 acc jabber set oauth on
 acc jabber on
Side note: Where "jabber" is the account tag. You can put the accounts number in there instead. To get account numbers "account list"
Same steps as facebooks step2
To get information on your accounts:
 account list
Notice accounts have a #, you can use that number to see all the options to that account, to set different options in that account. Also accounts get a tag. Like above the gmail account got the jabber tag and the facebook got the fb tag. Instead of "fb" and "jabber" you can use those accounts numbers like this, pretend the account number of something is 2 (meaning you have 3 accounts, account numbers start at 0)
To see all options:
 account 2 set
To set oauth on:
 account 2 set oauth on
General syntax for option setting:
 account 2 set <option> <value>
To DELETE an account:
 account 2 del
IF it complains that the account is still on (still connected), then turn it off (disconnect)
 account 2 off
To turn on all account (meaning connect to all accounts):
 account on
To turn off all account (meaning disconnect from all account):
 account off
ONE OF THE COOLEST OPTIONS:
 account n set
Other notes - nicklist shows numbers with facebook:
Back in the older versions facebook used to not be able to pull all of the information about users, and so it would give their user ID instead, which was annoying. You can still find out the users real username with
"info USERID" like this "info u123456789"
but anyhow the fix is implemented with some plugin script (that you run in bash shell and not in weechat and not thru bitlbee server). But even newer versions like this bitlbee implement "acc fb set nick_source full_name" which fixes everything.
Other notes - auth fail:
If using OCS and SIPE you keep getting auth fail, maybe your putting in your information wrong in the EMAIL
 account add sipe emailaddress,DOMAIN\\username PASSWORD
You can double check with credential manager on a computer you have Lync setup.
(Look at weechat user guide)
Nice long read - user guide for weechat: