Пример #1
0
    def __init__(self):
        self.xmpp_username = env("CXG_XMPP_USERNAME")
        self.xmpp_password = env("CXG_XMPP_PASSWORD")
        self.xmpp_recipient = env("CXG_XMPP_RECIPIENT")

        self.cf_subdomain = env("CXG_CAMPFIRE_SUBDOMAIN")
        self.cf_room_name = env("CXG_CAMPFIRE_ROOM")
        self.cf_real_name = env("CXG_CAMPFIRE_REAL_NAME")
        self.cf_username = env("CXG_CAMPFIRE_USERNAME")
        self.cf_password = env("CXG_CAMPFIRE_PASSWORD")

        self.cf = pyfire.Campfire(self.cf_subdomain,
                                  self.cf_username,
                                  self.cf_password,
                                  ssl=True)

        self.cf_room = None
        self.cf_stream = None

        self.xmpp_username = self.xmpp_username + "/Campfire"
        sleekxmpp.ClientXMPP.__init__(self, self.xmpp_username,
                                      self.xmpp_password)

        self.add_event_handler("session_start", self.xmpp_session_start)
        self.add_event_handler("session_end", self.xmpp_session_end)
        self.add_event_handler("message", self.xmpp_incoming_message)
Пример #2
0
def get_campfire_room():
    subdomain = os.environ.get("HUBOT_CAMPFIRE_SUBDOMAIN", None)
    username = os.environ.get("HUBOT_CAMPFIRE_USERNAME", None)
    password = os.environ.get("HUBOT_CAMPFIRE_PASSWORD", None)
    room_name = os.environ.get("HUBOT_CAMPFIRE_ROOM", None)

    if not all([subdomain, username, password, room_name]):
        sys.stderr.write("You must set HUBOT_CAMPFIRE_SUBDOMAIN "
                         "HUBOT_CAMPFIRE_USERNAME, HUBOT_CAMPFIRE_PASSWORD "
                         "and HUBOT_CAMPFIRE_ROOM\n")
        sys.exit(1)

    campfire = pyfire.Campfire(subdomain, username, password, ssl=True)
    room = campfire.get_room_by_name(room_name)
    room.join()
    return room
Пример #3
0
    def run(self):
        if self._action and hasattr(self, self._action):
            if not self._campfire:
                try:
                    self._campfire = pyfire.Campfire(self._subdomain,
                                                     self._user,
                                                     self._password,
                                                     ssl=self._ssl)
                except Exception as e:
                    self.emit(QtCore.SIGNAL("connectError(PyQt_PyObject)"), e)

            try:
                getattr(self, self._action)(*self._actionArgs)
            except Exception as e:
                self.emit(QtCore.SIGNAL("error(PyQt_PyObject)"), e)
            finally:
                self._action = None
                self._actionArgs = []
Пример #4
0
        elif message.is_topic_change():
            msg_func(irc_channel, "-- " + header_prefix + \
            " -- [%s] changed topic to '%s'" % (user, msg_body))


def error(e):
    print("Stream STOPPED due to ERROR: %s" % e)
    print("Press ENTER to continue")


if __name__ == '__main__':
    # initialize logging
    log.startLogging(sys.stdout)

    campfire = pyfire.Campfire(CAMPFIRE_SUBDOMAIN,
                               CAMPFIRE_EMAIL,
                               CAMPFIRE_PASSWORD,
                               ssl=True)
    global room
    room = campfire.get_room_by_name("CHATROOM")
    room.join()
    stream = room.get_stream(error_callback=error)
    stream.attach(incoming).start()
    # create factory protocol and application
    f = LogBotFactory('triggerchannel', 'messageschannel')

    # connect factory to this host and port
    reactor.connectTCP("127.0.0.1", 6667, f)

    reactor.run()
Пример #5
0
    elif message.is_leaving():
        print "<-- %s LEFT THE ROOM" % user
    elif message.is_tweet():
        print "[%s] %s TWEETED '%s' - %s" % (user, message.tweet["user"], 
            message.tweet["tweet"], message.tweet["url"])
    elif message.is_text():
        print "[%s] %s" % (user, message.body)
    elif message.is_upload():
        print "-- %s UPLOADED FILE %s: %s" % (user, message.upload["name"],
            message.upload["url"])
    elif message.is_topic_change():
        print "-- %s CHANGED TOPIC TO '%s'" % (user, message.body)

def error(e):
    print("Stream STOPPED due to ERROR: %s" % e)
    print("Press ENTER to continue")

campfire = pyfire.Campfire("skysourcer", "*****@*****.**", "abcd1234!", ssl=True)
#room = campfire.get_room_by_name("Test for skypefire")
stream = campfire.get_room_by_name("Test for skypefire").get_stream(live=False,use_process=False)
stream = room.get_stream(live=False,use_process=False,error_callback=error)

#live=True cannot work unfortuately...(which mean live streaming does not work well)
#use_process cannot work also...(which mean multiprocess does not work well)

#stream = room.get_stream(error_callback=error)
stream.attach(incoming).start()
raw_input("Waiting for messages (Press ENTER to finish)\n")
stream.stop().join()
#room.leave()
Пример #6
0
  sys.stdout = logger.Logger(sys.stdout, args.logfile)
  sys.stderr = logger.Logger(sys.stderr, args.logfile, startStamp=False)
  # data structure to store users' info who are using this integration service
  # ['skypename'] : Skyfire object, which contains token, campfire object, campfire userId
  skyfirers = {}
  rooms = {}
  print 'Reading config file......'
  config = ConfigParser.ConfigParser()
  config.optionxform = str
  config.read(args.config)
  osPlatform = platform.system()
  Skype4PyInterface = config.get('Skype4Py','interface')
  domain = config.get('campfire','domain')
  username = config.get('campfire','username')
  password = config.get('campfire','password')
  campfire = pyfire.Campfire(domain, username, password, ssl=True)
  for item in config.items('mapping'):
    print 'Get mapping [%s] -> [%s]' % (item[0], item[1])
    skyfirers[item[0]] = Skyfire()
    skyfirers[item[0]].token = item[1]

  # Initialize Input device to simulate typing in order to show typing indicator to remote client
  if osPlatform=="Windows":
    import win32com.client as comclt
    from win32gui import GetWindowText, GetForegroundWindow
    wsh = comclt.Dispatch("WScript.Shell")
  elif osPlatform=="Linux":
    import subprocess
  else:
    pass
  skype = Skype4Py.Skype(Transport=Skype4PyInterface) if osPlatform=="Linux" else Skype4Py.Skype()
Пример #7
0
                        help='config file. Use [example.cfg] by default')
    parser.add_argument('-v',
                        '--version',
                        action='version',
                        version='dumpfire 0.1')
    args = parser.parse_args()

    rooms = {}
    config = ConfigParser.ConfigParser()
    config.optionxform = str
    config.read(args.config)
    domain = config.get('campfire', 'domain')
    username = config.get('campfire', 'username')
    password = config.get('campfire', 'password')
    skypename = config.get('campfire', 'skypename')
    campfire = pyfire.Campfire(domain, username, password, ssl=True)
    """ multi-room version """
    for item in config.items('transcript'):
        roomName = item[0]
        try:
            time = datetime.datetime.strptime(item[1], '%Y-%m-%d')
        except ValueError:
            time = datetime.date.today()
        print '===== Getting transcript from room [', roomName, '] from ', time, ' ====='
        rooms[roomName] = campfire.get_room_by_name(roomName)
        messages = rooms[roomName].transcript(time)
        for message in messages:
            if message.user:
                user = message.user.name
            if message.is_text():
                print "[%s] [%s] %s" % (message.get_data()['created_at'], user,