Created
June 20, 2013 10:26
-
-
Save gislifreyr/5821721 to your computer and use it in GitHub Desktop.
Takes a text-file as an input and pumps all the email-addresses into Pidgin. If being used with sipe then the account must be in the form of [email protected],DOMAIN\user (case-sensitive).
If you wanna use it with other protocols just change the protocol according to what you're using.
Usage: ./buddyadd <account> <group> <file>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
#TODO: Add the capability of only adding contacts that aren't in the group already. | |
import dbus | |
import sys | |
if len(sys.argv) < 4: | |
print("usage: ./buddyadd <account> <group> <file>") | |
exit() | |
account = sys.argv[1] | |
group = sys.argv[2] | |
users = sys.argv[3] | |
protocol = 'prpl-sipe' | |
bus = dbus.SessionBus() | |
pidgin_object = bus.get_object('im.pidgin.purple.PurpleService','/im/pidgin/purple/PurpleObject') | |
purple = dbus.Interface(pidgin_object, 'im.pidgin.purple.PurpleInterface') | |
targetAccount = purple.PurpleAccountsFind(account, protocol) | |
if targetAccount == 0: | |
print("I say! You must be having a senior moment.") | |
exit() | |
targetGroup = purple.PurpleFindGroup(group) | |
if targetGroup == 0: | |
print("Oi! Breed with your own group.") | |
exit() | |
try: | |
with open(users, 'r') as user_list: | |
for email in iter(user_list): | |
email = email.strip("\n") | |
newBuddy = purple.PurpleBuddyNew(targetAccount, email, '') | |
purple.PurpleBlistAddBuddy(newBuddy, 0, targetGroup, 0) | |
purple.PurpleAccountAddBuddy(targetAccount, newBuddy) | |
except IOError: | |
print("Toodle-pip!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment