class SkypePlugin(BasePlugin): def __init__(self): print "Attempting to connect to Skype API. If Python crashes, this" print "could mean that Skype isn't running at the moment." print "" print "(There's no way around this at present -- Skype's Python" print "libraries suck. It also this seems to crash all the time" print "on OSX.)" # connect to skype self.skype = Skype() # skype4py is quite un-pythonic, with it's method names. self.skype.Attach() # by now skype4py would crash if skype isn't running. def configure(self, c): # read in phone numbers we need self.numbers = [ x.strip() for x in c.get('skypesms', 'to').lower().split(',') ] def execute(self, msg, unit, address, when, printer, print_copies): # lets just send the whole message verbatim. sms = self.skype.CreateSms(smsMessageTypeOutgoing, *self.numbers) sms.Body = "%s: %s - %s" % (when.ctime(), msg, unit) sms.Send()
def __init__(self): if platform.system() == 'Windows': skype = Skype() else: skype = Skype(Transport='x11') skype.Attach() self.chat = skype.Chat(SKYPE_CHAT)
def skype_notify(pull_request_url=None): client = Skype() client.Attach() msg = PULL_REQUEST_NOTIFICATION_MESSAGE % (pull_request_url or '') for receiver in PULL_REQUEST_NOTIFICATION_RECEIVERS: client.SendMessage(receiver, msg)
def send(self, queryset): try: queryset = queryset.order_by('user_id') except AttributeError: notification = queryset test_message = self.to_text(notification) test_user = slef.to_user(notification.user.skype) client = Skype(Transport='x11') client.Attach() client.SendMessage(test_user,test_message) return test_user
def validation(string): while (1): if not re.match("^[A-Z][a-z]{2,15} [A-Z][a-z]{2,25} \d{4}.\d{2}.\d{2}", string): print('is incorrect') else: client = Skype(Transport='x11') client.Attach() user = '******' massage = 'string - Davit Sakanyan' client.SendMessage(user, massage) print('is correct') time.sleep(600) return
def run(command_args): Thread(target=start_skype).start() print output_api.INFO + 'Please, wait 2 seconds... (Press Ctrl + C to exit)' sleep(2) client = Skype() client.Attach() while True: try: client.SendMessage(command_args[1], random_all(50, 50)) print output_api.YES + 'Flood Sent!' sleep(int(command_args[2])) except KeyboardInterrupt: break
from Skype4Py import Skype import rstr import time client = Skype(Transport='x11') client.Attach() user = '******' while (True): message = rstr.xeger('[A-Z][a-z]{3,8} [A-Z][a-z]{3,8}yan (19\d\d|20[0-1][0-7])\nHi Armenuhi you are reseve message from Smbat') client.SendMessage(user, message) print message time.sleep(600)
def skype_call(user_name, message_text): client = Skype() client.Attach() client.PlaceCall(user_name)
def skype_message(user_name, message_text): client = Skype() client.Attach() client.SendMessage(user_name, message_text)
class Handler(object): def __init__(self): self.contact = None self.skype = Skype() self.skype.OnMessageStatus = Handler.OnMessageStatus print('***************************************') print 'Connecting to Skype..' self.skype.Attach() self.contacts = dict( (user.FullName, user.Handle) \ for user in self.skype.Friends ) self.handles = set(self.contacts.values()) self.contact = None self.prev = None @staticmethod def OnMessageStatus(Message, Status): if Status == 'RECEIVED': print('\n %s >> Me : %s' % (Message.FromHandle, Message.Body)) gHandler.prev = Message.FromHandle if gHeader: print gHeader, if Status == 'READ': return print "READ" print(Message.FromDisplayName + ': ' + Message.Body) if Status == 'SENT': return def parse_cmd(self, cmd): if not cmd: return allowed = {'.contacts', '.chat', '.exit', '.help', '.r', '.reply'} if cmd.startswith('.'): args = cmd.split()[1:] cmd = cmd.split()[0] if cmd not in allowed: print('This command is not allowed!\n' 'Allowed commands: %s' % ','.join(allowed)) if cmd == '.contacts': for i in self.contacts.iteritems(): print('%s : %s' % i) if cmd == '.help': print 'allowed commands:' % ','.join(allowed) if cmd == '.chat': if not len(args): print 'you should provide one target!' return target = ' '.join(args) if target in self.contacts: self.contact = self.contacts[target] elif target in self.handles: self.contact = target else: print 'I do not have %s as a contact!' % target if cmd == '.r' or cmd == '.reply': if self.prev is None: print 'No-one to reply!' self.skype.SendMessage(self.prev, ' '.join(args)) else: self.skype.SendMessage(self.contact, cmd)
import platform from Skype4Py import Skype if platform.system() == 'Windows': skype = Skype() else: skype = Skype(Transport='x11') skype.Attach() for chat in skype.RecentChats: print '"%s" -> "%s"' % (chat.FriendlyName, chat.Name)
class SkypeBot(object): __metaclass__ = ABCMeta """ Abstract Base Class to define the interactions of a SkypeBot Args: name (string, optional): Name given to the SkypeBot """ def __init__(self, name="Skype Bot"): self.command_handler = CommandHandler() self.skype = Skype(Events=self) self.skype.FriendlyName = name def MessageStatus(self, msg, status): """ Event handler for sending messages Args: msg (Skype4Py.SmsMessage): Skype Message status (int): status code """ if status == cmsReceived: msg.MarkAsSeen() user = msg.FromHandle reply_with = self.command_handler.handle(msg, status, user) if reply_with: self.__reply(msg, reply_with) def __reply(self, msg_client, msg): """ [Internal] Send message to chat via Skype Msg Module Args: msg_client (Skype4Py.Chat): Skype Chat client instance msg (Skype4Py.SmsMessage): Skype Message """ msg_client.Chat.SendMessage(msg) def bootstrap(self): """ Bootstraps the Bot config to run and attach to the skype client """ self.register_command_delimiter() self.register_command_owner() self.register_commands() self.skype.Attach() @abstractmethod def run(self): """ Method which will facilitate running the Bot. """ pass @abstractmethod def register_command_delimiter(self): """ Register the delimiter in which signifies a command is being sent. """ pass @abstractmethod def register_command_owner(self): """ Register the current bot name which will respond to commands in skype. """ pass @abstractmethod def register_commands(self): """ Register the bot commands. """ pass