source: utils/centericq2bitlbee.sh @ 0fbd3a6d

Last change on this file since 0fbd3a6d was b7d3cc34, checked in by Wilmer van der Gaast <wilmer@…>, at 2005-11-06T18:23:18Z

Initial repository (0.99 release tree)

  • Property mode set to 100755
File size: 3.0 KB
RevLine 
[b7d3cc34]1#!/bin/bash
2#
3#  Author       geno, <geno@xenyon.com>
4#  Date         2004-04-24
5#  Version      0.1c
6#
7
8show_help()
9{
10cat << _EOF_
11
12This script converts your CenterICQ contacts (AIM/ICQ) to BitlBee's contacts.
13The use of this script is on you own risk. You agree by using this script. :-)
14
15SYNTAX: `basename $0` <protoname> [<add_proto_tag>]
16
17        protoname     - Choose the protocol you want to get your contacts from
18                        by using "aim" or "icq" here.
19
20        add_proto_tag - This is optional and adds a suffix to each nickname.
21                        For an AIM contact it will look like this: geno|aim
22                        For an ICQ contact it will be |icq , WOW! :-D
23                        To enable this option use "on".
24
25NOTE:
26        After the conversion of one protocol is done you will find a file
27        called bitlbee_[protoname] in ~/.centericq . Append the content of
28        this file to /var/lib/bitlbee/[username].nicks .
29
30        [username] is your username you use to talk to the BitlBee Server.
31        You will have to be root to edit this file!
32
33CREDITS:
34        This script was written by geno (geno@xenyon.com).
35        I hope it will help you to make the switch to BitlBee a bit easier. :-)
36
37_EOF_
38exit 0
39}
40
41case $1 in
42        "") show_help ;;
43        "icq")
44                nick_protocol="[1-9]*/"
45                protocol_const="3"
46        ;;
47       
48        "aim")
49                nick_protocol="a*/"
50                protocol_const="1"
51        ;;
52       
53        *) show_help ;;
54esac
55
56# can we see CenterICQ's directory ?
57if [ ! -d ~/.centericq ]; then
58        echo "The directory of CenterICQ (~/.centericq) was not found!"
59        echo "Maybe you are logged in with the wrong username."
60        exit 1
61fi
62
63# change to the center of all evil ;)
64cd ~/.centericq
65
66# get the listing of all nicks
67nick_listing=`ls -d $nick_protocol | sed 's/\ /_DuMmY_/g' | sed 's/\/_DuMmY_/\/ /g'`
68
69echo -e "\nConverting ...\n"
70
71# remove old conversion
72rm -f ~/.centericq/bitlbee_$1
73
74for nick_accountname in $nick_listing; do
75        # get rid of the slash and replace _DuMmY_ with space
76        nick_accountname=`echo "$nick_accountname" | sed 's/\/$//' | sed 's/_DuMmY_/\ /g'`
77       
78        # find centericq alias
79        nick_cicq_alias=`cat "$nick_accountname/info" | sed '46!d'`
80       
81        # if the centericq alias is the same as the account's name then
82        # it's not a real alias; search for account nickname
83        if [ "$nick_accountname" == "$nick_cicq_alias" ]; then
84                nick_accountalias=`cat "$nick_accountname/info" | sed '1!d'`
85        fi
86
87        # save the best nickname for conversion
88        if [ "x$nick_accountalias" == "x" ]; then
89                nick="$nick_cicq_alias"
90        else
91                nick="$nick_accountalias"
92        fi
93
94        # cut off the prefix 'a' of the accountname
95        if [ "$1" == "aim" ]; then
96                nick_accountname=`echo "$nick_accountname" | sed 's/^a//'`
97        fi
98
99        # replace each space with an underscore (spaces are not allowed in irc nicknames)
100        nick=`echo "$nick" | sed 's/\ /_/g'`
101
102        # if tags are wanted we will add them here
103        if [ "$2" == "on" ]; then
104                nick=`echo "$nick"\|$1`
105        fi
106
107        # print output to std
108        echo "Found '$nick_accountname' with alias '$nick'"
109        # save output to file
110        echo "$nick_accountname" $protocol_const "$nick" >> ~/.centericq/bitlbee_$1
111done
112
113echo -e "\nYou can find this list as a file in ~/.centericq/bitlbee_$1."
114echo -e "See help if you don't know what you have to do next.\n"
115
Note: See TracBrowser for help on using the repository browser.