Esempio n. 1
0
 def getShare(self, user, channel, msg):
     share = Share.by_name(msg.lower())
     if share is not None:
         line = "%s: %s" % (share.name, share.private_key)
         if share.read_only:
             line += " (read only)"
         self.display(user, channel, line)
     else:
         self.display(user, channel, "Share not found with name '%s'" % msg.lower())
         searchResults = len(Share.by_search(msg.lower()))
         if 0 < searchResults <= 10:
             self.display(user, channel, "%d similar share(s) found via search" % searchResults)
Esempio n. 2
0
 def addShare(self, user, channel, msg):
     ''' Add a user's shared key to the database '''
     args = self.addShareParser.parse_args(msg.split())
     shareName = ' '.join(args.name).lower()
     shareKey = args.key.upper()
     if Share.by_name(shareName) is None and Share.by_private_key(shareKey) is None:
         share = Share(
             name=shareName,
             creator=user.lower(),
             private_key=shareKey, 
             description=' '.join(args.description)
         )
         dbsession.add(share)
         dbsession.flush()
         returnMessage = "Succesfully added new share '%s' to database" % share.name
     else:
         returnMessage = "Share already exists with that name or key"
     self.display(user, channel, returnMessage)