mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			48 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			48 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
	
	
	
#!/usr/bin/python
 | 
						|
import sys
 | 
						|
import os
 | 
						|
import optparse
 | 
						|
 | 
						|
usage = """send-message [options] <recipient>
 | 
						|
 | 
						|
Sends a test message to the specified recipients.
 | 
						|
 | 
						|
Example: send-message --site=http://127.0.0.1:8000 iago@humbughq.com
 | 
						|
"""
 | 
						|
parser = optparse.OptionParser(usage=usage)
 | 
						|
parser.add_option('--site',
 | 
						|
                  dest='site',
 | 
						|
                  default="https://humbughq.com",
 | 
						|
                  action='store')
 | 
						|
parser.add_option('--api-key',
 | 
						|
                  dest='api_key',
 | 
						|
                  default=None,
 | 
						|
                  action='store')
 | 
						|
parser.add_option('--sender',
 | 
						|
                  dest='sender',
 | 
						|
                  default='othello@humbughq.com',
 | 
						|
                  action='store')
 | 
						|
parser.add_option('--type',
 | 
						|
                  dest='type',
 | 
						|
                  default='private',
 | 
						|
                  action='store')
 | 
						|
(options, args) = parser.parse_args()
 | 
						|
 | 
						|
if len(args) == 0:
 | 
						|
    parser.error("You must specify recipients")
 | 
						|
 | 
						|
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
 | 
						|
import api.common
 | 
						|
client = api.common.HumbugAPI(email=options.sender,
 | 
						|
                              api_key=options.api_key,
 | 
						|
                              verbose=True,
 | 
						|
                              site=options.site)
 | 
						|
 | 
						|
message_data = {
 | 
						|
    "type": options.type,
 | 
						|
    "content": "test",
 | 
						|
    "subject": "test",
 | 
						|
    "to": args,
 | 
						|
}
 | 
						|
print client.send_message(message_data)
 |