Commit 3e2f62f7 authored by Romain Bignon's avatar Romain Bignon

the facebook_rename script is now usable with bitlbee too (thanks to varogami)

parent d2aa8a95
# This script renames your Facebook buddies to a readable format when
# using Facebook's XMPP gateway with Minbif.
# using Facebook's XMPP gateway with Minbif or Bitlbee.
# Based on the Irssi script at http://browsingtheinternet.com/temp/bitlbee_rename.txt
# Ported for Weechat 0.3.0 or later by Jaakko Lintula (crwl@iki.fi)
# Modified for Minbif by 'varogami' <varogami@gmail.com>
# Testing contrib 'bizio' <maestrozappa@gmail.com>
#
# This program can be distributed under the terms of the GNU GPL3.
# Testing contrib 'bizio' maestrozappa@gmail.com
#Edit this variables with your own minbif configuration settings
mode = "minbif" #set 'minbif' or 'bitlbee' for select gateway type
minbifChannel = "&minbif"
minbifServer = "minbif"
bitlbeeChannel = "&bitlbee"
bitlbeeServer = "bitlbee"
facebookhostname = "chat.facebook.com"
minbifBuffer = "%s.%s" % (minbifServer, minbifChannel)
bitlbeeBuffer = "%s.%s" % (bitlbeeServer, bitlbeeChannel)
nicksToRename = set()
import weechat
import re
weechat.register("facebook_rename_minbif", "varogami", "0.0.2", "GPL", "Renames Facebook usernames when using minbif", "", "")
weechat.register("facebook_rename", "varogami", "0.0.3", "GPL", "Renames Facebook usernames when using minbif or bitlbee", "", "")
def message_join(data, signal, signal_data):
def message_join_minbif(data, signal, signal_data):
signal_data = signal_data.split()
channel = signal_data[2]
hostmask = signal_data[0]
......@@ -36,7 +41,7 @@ def message_join(data, signal, signal_data):
return weechat.WEECHAT_RC_OK
def whois_data(data, signal, signal_data):
def whois_data_minbif(data, signal, signal_data):
if "Full Name" in signal_data:
nick = signal_data.split("Full Name:")[0].strip()
nick = nick[1:nick.index(' :')]
......@@ -52,5 +57,37 @@ def whois_data(data, signal, signal_data):
return weechat.WEECHAT_RC_OK
weechat.hook_signal(minbifServer+",irc_in_join", "message_join", "")
weechat.hook_signal(minbifServer+",irc_in_320", "whois_data", "")
def message_join_bitlbee(data, signal, signal_data):
signal_data = signal_data.split()
channel = signal_data[2][1:]
hostmask = signal_data[0]
nick = hostmask[1:hostmask.index('!')]
username = hostmask[hostmask.index('!')+1:hostmask.index('@')]
server = hostmask[hostmask.index('@')+1:]
if channel == bitlbeeChannel and nick == username and nick[0] == '-' and server == facebookhostname:
nicksToRename.add(nick)
weechat.command(weechat.buffer_search("irc", bitlbeeBuffer), "/whois " + nick)
return weechat.WEECHAT_RC_OK
def whois_data_bitlbee(data, signal, signal_data):
nick = signal_data.split()[3]
realname = signal_data[signal_data.rindex(':')+1:]
if nick in nicksToRename:
nicksToRename.remove(nick)
ircname = re.sub("[^A-Za-z0-9]", "", realname)[:24]
if ircname != nick:
weechat.command(weechat.buffer_search("irc", bitlbeeBuffer), "/msg %s rename %s %s" % (bitlbeeChannel, nick, ircname))
weechat.command(weechat.buffer_search("irc", bitlbeeBuffer), "/msg %s save" % (bitlbeeChannel))
return weechat.WEECHAT_RC_OK
if mode == "minbif":
weechat.hook_signal(minbifServer+",irc_in_join", "message_join_minbif", "")
weechat.hook_signal(minbifServer+",irc_in_320", "whois_data_minbif", "")
if mode == "bitlbee":
weechat.hook_signal(bitlbeeServer+",irc_in_join", "message_join_bitlbee", "")
weechat.hook_signal(bitlbeeServer+",irc_in_311", "whois_data_bitlbee", "")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment