Rename the 'humbug' API module to 'zulip'.
(imported from commit b3a3d7c05459cbb0110cd0fbe2197d779f3a6264)
This commit is contained in:
parent
9aaefde9b2
commit
084847b0d7
|
@ -42,8 +42,8 @@ A typical simple bot sending API messages will look as follows:
|
||||||
At the top of the file:
|
At the top of the file:
|
||||||
|
|
||||||
# Make sure the Zulip API distribution's root directory is in sys.path, then:
|
# Make sure the Zulip API distribution's root directory is in sys.path, then:
|
||||||
import humbug
|
import zulip
|
||||||
humbug_client = humbug.Client(email="your-bot@example.com")
|
zulip_client = zulip.Client(email="your-bot@example.com")
|
||||||
|
|
||||||
When you want to send a message:
|
When you want to send a message:
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ When you want to send a message:
|
||||||
"subject": "your subject",
|
"subject": "your subject",
|
||||||
"content": "your content",
|
"content": "your content",
|
||||||
}
|
}
|
||||||
humbug_client.send_message(message)
|
zulip_client.send_message(message)
|
||||||
|
|
||||||
Additional examples:
|
Additional examples:
|
||||||
|
|
||||||
|
|
|
@ -65,12 +65,12 @@ def main(argv=None):
|
||||||
|
|
||||||
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
|
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
|
||||||
|
|
||||||
import humbug
|
import zulip
|
||||||
|
|
||||||
parser = optparse.OptionParser(usage=usage)
|
parser = optparse.OptionParser(usage=usage)
|
||||||
|
|
||||||
# Grab parser options from the API common set
|
# Grab parser options from the API common set
|
||||||
parser.add_option_group(humbug.generate_option_group(parser))
|
parser.add_option_group(zulip.generate_option_group(parser))
|
||||||
|
|
||||||
parser.add_option('-m', '--message',
|
parser.add_option('-m', '--message',
|
||||||
help='Specifies the message to send, prevents interactive prompting.')
|
help='Specifies the message to send, prevents interactive prompting.')
|
||||||
|
@ -99,7 +99,7 @@ def main(argv=None):
|
||||||
if len(recipients) == 0 and not (options.stream and options.subject):
|
if len(recipients) == 0 and not (options.stream and options.subject):
|
||||||
parser.error('You must specify a stream/subject or at least one recipient.')
|
parser.error('You must specify a stream/subject or at least one recipient.')
|
||||||
|
|
||||||
client = humbug.init_from_options(options)
|
client = zulip.init_from_options(options)
|
||||||
|
|
||||||
if not options.message:
|
if not options.message:
|
||||||
options.message = sys.stdin.read()
|
options.message = sys.stdin.read()
|
||||||
|
|
|
@ -26,7 +26,7 @@ parser.add_option('--root-path',
|
||||||
action='store')
|
action='store')
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
# The 'api' directory needs to go first, so that 'import humbug' won't pick up
|
# The 'api' directory needs to go first, so that 'import zulip' won't pick up
|
||||||
# some other directory named 'humbug'.
|
# some other directory named 'humbug'.
|
||||||
sys.path[:0] = [os.path.join(options.root_path, "api/"),
|
sys.path[:0] = [os.path.join(options.root_path, "api/"),
|
||||||
os.path.join(options.root_path, "python-zephyr"),
|
os.path.join(options.root_path, "python-zephyr"),
|
||||||
|
@ -37,8 +37,8 @@ mit_user = 'tabbott/extra@ATHENA.MIT.EDU'
|
||||||
humbug_user = 'tabbott/extra@mit.edu'
|
humbug_user = 'tabbott/extra@mit.edu'
|
||||||
|
|
||||||
sys.path.append(".")
|
sys.path.append(".")
|
||||||
import humbug
|
import zulip
|
||||||
humbug_client = humbug.Client(
|
zulip_client = zulip.Client(
|
||||||
email=humbug_user,
|
email=humbug_user,
|
||||||
api_key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
api_key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||||
verbose=True,
|
verbose=True,
|
||||||
|
@ -103,7 +103,7 @@ def print_status_and_exit(status):
|
||||||
sys.exit(status)
|
sys.exit(status)
|
||||||
|
|
||||||
def send_humbug(message):
|
def send_humbug(message):
|
||||||
result = humbug_client.send_message(message)
|
result = zulip_client.send_message(message)
|
||||||
if result["result"] != "success":
|
if result["result"] != "success":
|
||||||
logger.error("Error sending zulip, args were:")
|
logger.error("Error sending zulip, args were:")
|
||||||
logger.error(message)
|
logger.error(message)
|
||||||
|
@ -128,7 +128,7 @@ def send_zephyr(zwrite_args, content):
|
||||||
|
|
||||||
# Subscribe to Zulip
|
# Subscribe to Zulip
|
||||||
try:
|
try:
|
||||||
res = humbug_client.get_profile()
|
res = zulip_client.get_profile()
|
||||||
max_message_id = res.get('max_message_id')
|
max_message_id = res.get('max_message_id')
|
||||||
if max_message_id is None:
|
if max_message_id is None:
|
||||||
logging.error("Error subscribing to Zulips!")
|
logging.error("Error subscribing to Zulips!")
|
||||||
|
@ -264,7 +264,7 @@ receive_zephyrs()
|
||||||
logger.info("Starting receiving messages!")
|
logger.info("Starting receiving messages!")
|
||||||
|
|
||||||
# receive zulips
|
# receive zulips
|
||||||
messages = humbug_client.get_messages({'last': str(max_message_id)})['messages']
|
messages = zulip_client.get_messages({'last': str(max_message_id)})['messages']
|
||||||
logger.info("Finished receiving Zulip messages!")
|
logger.info("Finished receiving Zulip messages!")
|
||||||
|
|
||||||
receive_zephyrs()
|
receive_zephyrs()
|
||||||
|
|
|
@ -4,7 +4,7 @@ from os import path
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
sys.path.append(path.join(path.dirname(__file__), '../api'))
|
sys.path.append(path.join(path.dirname(__file__), '../api'))
|
||||||
import humbug
|
import zulip
|
||||||
|
|
||||||
class StreamLogger(object):
|
class StreamLogger(object):
|
||||||
"""
|
"""
|
||||||
|
@ -32,12 +32,12 @@ sys.stdout = stdout_logger
|
||||||
stderr_logger = StreamLogger(logging.getLogger("stderr"), logging.ERROR)
|
stderr_logger = StreamLogger(logging.getLogger("stderr"), logging.ERROR)
|
||||||
sys.stderr = stderr_logger
|
sys.stderr = stderr_logger
|
||||||
|
|
||||||
prod_client = humbug.Client(
|
prod_client = zulip.Client(
|
||||||
email="feedback@zulip.com",
|
email="feedback@zulip.com",
|
||||||
api_key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
api_key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||||
verbose=True,
|
verbose=True,
|
||||||
site="https://api.zulip.com")
|
site="https://api.zulip.com")
|
||||||
staging_client = humbug.Client(
|
staging_client = zulip.Client(
|
||||||
email="feedback@zulip.com",
|
email="feedback@zulip.com",
|
||||||
api_key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
api_key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||||
verbose=True,
|
verbose=True,
|
||||||
|
|
|
@ -9,7 +9,7 @@ import traceback
|
||||||
from os import path
|
from os import path
|
||||||
|
|
||||||
sys.path.append(path.join(path.dirname(__file__), '../api'))
|
sys.path.append(path.join(path.dirname(__file__), '../api'))
|
||||||
import humbug
|
import zulip
|
||||||
|
|
||||||
parser = optparse.OptionParser(r"""
|
parser = optparse.OptionParser(r"""
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ parser.add_option('--interval',
|
||||||
action='store',
|
action='store',
|
||||||
help='Minutes before event for reminder [default: 10]',
|
help='Minutes before event for reminder [default: 10]',
|
||||||
metavar='MINUTES')
|
metavar='MINUTES')
|
||||||
parser.add_option_group(humbug.generate_option_group(parser))
|
parser.add_option_group(zulip.generate_option_group(parser))
|
||||||
|
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ def get_calendar_url():
|
||||||
|
|
||||||
calendar_url = get_calendar_url()
|
calendar_url = get_calendar_url()
|
||||||
|
|
||||||
client = humbug.init_from_options(options)
|
client = zulip.init_from_options(options)
|
||||||
|
|
||||||
def get_events():
|
def get_events():
|
||||||
feed = CalendarClient().GetCalendarEventFeed(uri=calendar_url)
|
feed = CalendarClient().GetCalendarEventFeed(uri=calendar_url)
|
||||||
|
|
|
@ -8,15 +8,15 @@ import subprocess
|
||||||
import unicodedata
|
import unicodedata
|
||||||
|
|
||||||
sys.path.append(path.join(path.dirname(__file__), '..', 'api'))
|
sys.path.append(path.join(path.dirname(__file__), '..', 'api'))
|
||||||
import humbug
|
import zulip
|
||||||
|
|
||||||
humbug_client = humbug.Client()
|
zulip_client = zulip.Client()
|
||||||
|
|
||||||
def fetch_public_streams():
|
def fetch_public_streams():
|
||||||
public_streams = set()
|
public_streams = set()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
res = humbug_client.get_public_streams()
|
res = zulip_client.get_public_streams()
|
||||||
if res.get("result") == "success":
|
if res.get("result") == "success":
|
||||||
streams = res["streams"]
|
streams = res["streams"]
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -46,9 +46,9 @@ humbug_directory = path.join(path.dirname(__file__), '../api')
|
||||||
|
|
||||||
|
|
||||||
sys.path.append(humbug_directory)
|
sys.path.append(humbug_directory)
|
||||||
import humbug
|
import zulip
|
||||||
|
|
||||||
client = humbug.Client(
|
client = zulip.Client(
|
||||||
email = environ['HUMBUG_USER'],
|
email = environ['HUMBUG_USER'],
|
||||||
api_key = environ.get('HUMBUG_API_KEY'))
|
api_key = environ.get('HUMBUG_API_KEY'))
|
||||||
|
|
||||||
|
|
|
@ -165,7 +165,7 @@ def send_zulip(zeph):
|
||||||
logger.debug("Message is: %s" % (str(message),))
|
logger.debug("Message is: %s" % (str(message),))
|
||||||
return {'result': "success"}
|
return {'result': "success"}
|
||||||
|
|
||||||
return humbug_client.send_message(message)
|
return zulip_client.send_message(message)
|
||||||
|
|
||||||
def send_error_zulip(error_msg):
|
def send_error_zulip(error_msg):
|
||||||
message = {"type": "private",
|
message = {"type": "private",
|
||||||
|
@ -173,7 +173,7 @@ def send_error_zulip(error_msg):
|
||||||
"to": zulip_account_email,
|
"to": zulip_account_email,
|
||||||
"content": error_msg,
|
"content": error_msg,
|
||||||
}
|
}
|
||||||
humbug_client.send_message(message)
|
zulip_client.send_message(message)
|
||||||
|
|
||||||
current_zephyr_subs = set()
|
current_zephyr_subs = set()
|
||||||
def zephyr_bulk_subscribe(subs):
|
def zephyr_bulk_subscribe(subs):
|
||||||
|
@ -623,7 +623,7 @@ def zulip_to_zephyr(options):
|
||||||
logger.info("Starting syncing messages.")
|
logger.info("Starting syncing messages.")
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
humbug_client.call_on_each_message(maybe_forward_to_zephyr)
|
zulip_client.call_on_each_message(maybe_forward_to_zephyr)
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.exception("Error syncing messages:")
|
logger.exception("Error syncing messages:")
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
@ -675,7 +675,7 @@ def add_zulip_subscriptions(verbose):
|
||||||
zephyr_subscriptions.add(cls)
|
zephyr_subscriptions.add(cls)
|
||||||
|
|
||||||
if len(zephyr_subscriptions) != 0:
|
if len(zephyr_subscriptions) != 0:
|
||||||
res = humbug_client.add_subscriptions(list({"name": stream} for stream in zephyr_subscriptions))
|
res = zulip_client.add_subscriptions(list({"name": stream} for stream in zephyr_subscriptions))
|
||||||
if res.get("result") != "success":
|
if res.get("result") != "success":
|
||||||
logger.error("Error subscribing to streams:\n%s" % (res["msg"],))
|
logger.error("Error subscribing to streams:\n%s" % (res["msg"],))
|
||||||
return
|
return
|
||||||
|
@ -866,7 +866,7 @@ if __name__ == "__main__":
|
||||||
logger = open_logger()
|
logger = open_logger()
|
||||||
configure_logger(logger, "parent")
|
configure_logger(logger, "parent")
|
||||||
|
|
||||||
# The 'api' directory needs to go first, so that 'import humbug' won't pick
|
# The 'api' directory needs to go first, so that 'import zulip' won't pick
|
||||||
# up some other directory named 'humbug'.
|
# up some other directory named 'humbug'.
|
||||||
pyzephyr_lib_path = "python-zephyr/build/lib.linux-" + os.uname()[4] + "-2.6/"
|
pyzephyr_lib_path = "python-zephyr/build/lib.linux-" + os.uname()[4] + "-2.6/"
|
||||||
sys.path[:0] = [os.path.join(options.root_path, 'api'),
|
sys.path[:0] = [os.path.join(options.root_path, 'api'),
|
||||||
|
@ -892,8 +892,8 @@ or specify the --api-key-file option.""" % (options.api_key_file,))))
|
||||||
os.environ["HUMBUG_API_KEY"] = api_key
|
os.environ["HUMBUG_API_KEY"] = api_key
|
||||||
|
|
||||||
zulip_account_email = options.user + "@mit.edu"
|
zulip_account_email = options.user + "@mit.edu"
|
||||||
import humbug
|
import zulip
|
||||||
humbug_client = humbug.Client(
|
zulip_client = zulip.Client(
|
||||||
email=zulip_account_email,
|
email=zulip_account_email,
|
||||||
api_key=api_key,
|
api_key=api_key,
|
||||||
verbose=True,
|
verbose=True,
|
||||||
|
|
|
@ -11,7 +11,7 @@ import time
|
||||||
import urlparse
|
import urlparse
|
||||||
|
|
||||||
import feedparser
|
import feedparser
|
||||||
import humbug
|
import zulip
|
||||||
|
|
||||||
RSS_DATA_DIR = os.path.expanduser(os.path.join('~', '.cache', 'humbug-rss'))
|
RSS_DATA_DIR = os.path.expanduser(os.path.join('~', '.cache', 'humbug-rss'))
|
||||||
OLDNESS_THRESHOLD = 30 # days
|
OLDNESS_THRESHOLD = 30 # days
|
||||||
|
@ -56,7 +56,7 @@ parser.add_option('--feed-file',
|
||||||
help='The file containing a list of RSS feed URLs to follow, one URL per line',
|
help='The file containing a list of RSS feed URLs to follow, one URL per line',
|
||||||
default=os.path.join(RSS_DATA_DIR, "rss-feeds"),
|
default=os.path.join(RSS_DATA_DIR, "rss-feeds"),
|
||||||
action='store')
|
action='store')
|
||||||
parser.add_option_group(humbug.generate_option_group(parser))
|
parser.add_option_group(zulip.generate_option_group(parser))
|
||||||
(opts, args) = parser.parse_args()
|
(opts, args) = parser.parse_args()
|
||||||
|
|
||||||
def mkdir_p(path):
|
def mkdir_p(path):
|
||||||
|
@ -131,7 +131,7 @@ try:
|
||||||
except IOError:
|
except IOError:
|
||||||
log_error_and_exit("Unable to read feed file at %s." % (opts.feed_file,))
|
log_error_and_exit("Unable to read feed file at %s." % (opts.feed_file,))
|
||||||
|
|
||||||
client = humbug.Client(email=opts.email, api_key=opts.api_key,
|
client = zulip.Client(email=opts.email, api_key=opts.api_key,
|
||||||
site=opts.site)
|
site=opts.site)
|
||||||
|
|
||||||
first_message = True
|
first_message = True
|
||||||
|
|
|
@ -4,7 +4,7 @@ import sys
|
||||||
import optparse
|
import optparse
|
||||||
import ConfigParser
|
import ConfigParser
|
||||||
|
|
||||||
import humbug
|
import zulip
|
||||||
|
|
||||||
CONFIGFILE = os.path.expanduser("~/.humbug_twitterrc")
|
CONFIGFILE = os.path.expanduser("~/.humbug_twitterrc")
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ parser.add_option('--limit-tweets',
|
||||||
type='int',
|
type='int',
|
||||||
help='Maximum number of tweets to push at once')
|
help='Maximum number of tweets to push at once')
|
||||||
|
|
||||||
parser.add_option_group(humbug.generate_option_group(parser))
|
parser.add_option_group(zulip.generate_option_group(parser))
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
if not options.twitter_id:
|
if not options.twitter_id:
|
||||||
|
@ -101,7 +101,7 @@ try:
|
||||||
except ConfigParser.NoOptionError:
|
except ConfigParser.NoOptionError:
|
||||||
user_id = options.twitter_id
|
user_id = options.twitter_id
|
||||||
|
|
||||||
client = humbug.Client(
|
client = zulip.Client(
|
||||||
email=options.user,
|
email=options.user,
|
||||||
api_key=options.api_key,
|
api_key=options.api_key,
|
||||||
site=options.site,
|
site=options.site,
|
||||||
|
|
|
@ -4,7 +4,7 @@ import sys
|
||||||
import optparse
|
import optparse
|
||||||
import ConfigParser
|
import ConfigParser
|
||||||
|
|
||||||
import humbug
|
import zulip
|
||||||
|
|
||||||
CONFIGFILE = os.path.expanduser("~/.humbug_twitterrc")
|
CONFIGFILE = os.path.expanduser("~/.humbug_twitterrc")
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ parser.add_option('--limit-tweets',
|
||||||
type='int',
|
type='int',
|
||||||
help='Maximum number of tweets to send at once')
|
help='Maximum number of tweets to send at once')
|
||||||
|
|
||||||
parser.add_option_group(humbug.generate_option_group(parser))
|
parser.add_option_group(zulip.generate_option_group(parser))
|
||||||
(opts, args) = parser.parse_args()
|
(opts, args) = parser.parse_args()
|
||||||
|
|
||||||
if not opts.search_terms:
|
if not opts.search_terms:
|
||||||
|
@ -118,7 +118,7 @@ if not user.GetId():
|
||||||
Please double-check and try again."
|
Please double-check and try again."
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
client = humbug.Client(
|
client = zulip.Client(
|
||||||
email=opts.user,
|
email=opts.user,
|
||||||
api_key=opts.api_key,
|
api_key=opts.api_key,
|
||||||
site=opts.site,
|
site=opts.site,
|
||||||
|
|
|
@ -35,16 +35,16 @@ You can omit --user and --api-key arguments if you have a properly set up ~/.zul
|
||||||
"""
|
"""
|
||||||
|
|
||||||
sys.path.insert(0, path.join(path.dirname(__file__), '..'))
|
sys.path.insert(0, path.join(path.dirname(__file__), '..'))
|
||||||
import humbug
|
import zulip
|
||||||
|
|
||||||
parser = optparse.OptionParser(usage=usage)
|
parser = optparse.OptionParser(usage=usage)
|
||||||
parser.add_option('--message-id', default="")
|
parser.add_option('--message-id', default="")
|
||||||
parser.add_option('--subject', default="")
|
parser.add_option('--subject', default="")
|
||||||
parser.add_option('--content', default="")
|
parser.add_option('--content', default="")
|
||||||
parser.add_option_group(humbug.generate_option_group(parser))
|
parser.add_option_group(zulip.generate_option_group(parser))
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
client = humbug.init_from_options(options)
|
client = zulip.init_from_options(options)
|
||||||
|
|
||||||
message_data = {
|
message_data = {
|
||||||
"message_id": options.message_id,
|
"message_id": options.message_id,
|
||||||
|
|
|
@ -35,12 +35,12 @@ You can omit --user and --api-key arguments if you have a properly set up ~/.zul
|
||||||
"""
|
"""
|
||||||
|
|
||||||
sys.path.append(path.join(path.dirname(__file__), '..'))
|
sys.path.append(path.join(path.dirname(__file__), '..'))
|
||||||
import humbug
|
import zulip
|
||||||
|
|
||||||
parser = optparse.OptionParser(usage=usage)
|
parser = optparse.OptionParser(usage=usage)
|
||||||
parser.add_option_group(humbug.generate_option_group(parser))
|
parser.add_option_group(zulip.generate_option_group(parser))
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
client = humbug.init_from_options(options)
|
client = zulip.init_from_options(options)
|
||||||
|
|
||||||
print client.get_public_streams()
|
print client.get_public_streams()
|
||||||
|
|
|
@ -33,13 +33,13 @@ You can omit --user and --api-key arguments if you have a properly set up ~/.zul
|
||||||
"""
|
"""
|
||||||
|
|
||||||
sys.path.append(path.join(path.dirname(__file__), '..'))
|
sys.path.append(path.join(path.dirname(__file__), '..'))
|
||||||
import humbug
|
import zulip
|
||||||
|
|
||||||
parser = optparse.OptionParser(usage=usage)
|
parser = optparse.OptionParser(usage=usage)
|
||||||
parser.add_option_group(humbug.generate_option_group(parser))
|
parser.add_option_group(zulip.generate_option_group(parser))
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
client = humbug.init_from_options(options)
|
client = zulip.init_from_options(options)
|
||||||
|
|
||||||
for user in client.get_members()["members"]:
|
for user in client.get_members()["members"]:
|
||||||
print user["full_name"], user["email"]
|
print user["full_name"], user["email"]
|
||||||
|
|
|
@ -34,12 +34,12 @@ Example: list-subscriptions --user=tabbott@zulip.com --api-key=a0b1c2d3e4f5a6b7c
|
||||||
You can omit --user and --api-key arguments if you have a properly set up ~/.zuliprc
|
You can omit --user and --api-key arguments if you have a properly set up ~/.zuliprc
|
||||||
"""
|
"""
|
||||||
sys.path.append(path.join(path.dirname(__file__), '..'))
|
sys.path.append(path.join(path.dirname(__file__), '..'))
|
||||||
import humbug
|
import zulip
|
||||||
|
|
||||||
parser = optparse.OptionParser(usage=usage)
|
parser = optparse.OptionParser(usage=usage)
|
||||||
parser.add_option_group(humbug.generate_option_group(parser))
|
parser.add_option_group(zulip.generate_option_group(parser))
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
client = humbug.init_from_options(options)
|
client = zulip.init_from_options(options)
|
||||||
|
|
||||||
print client.list_subscriptions()
|
print client.list_subscriptions()
|
||||||
|
|
|
@ -34,13 +34,13 @@ Example: print-messages --user=tabbott@zulip.com --api-key=a0b1c2d3e4f5a6b7c8d9e
|
||||||
You can omit --user and --api-key arguments if you have a properly set up ~/.zuliprc
|
You can omit --user and --api-key arguments if you have a properly set up ~/.zuliprc
|
||||||
"""
|
"""
|
||||||
sys.path.append(path.join(path.dirname(__file__), '..'))
|
sys.path.append(path.join(path.dirname(__file__), '..'))
|
||||||
import humbug
|
import zulip
|
||||||
|
|
||||||
parser = optparse.OptionParser(usage=usage)
|
parser = optparse.OptionParser(usage=usage)
|
||||||
parser.add_option_group(humbug.generate_option_group(parser))
|
parser.add_option_group(zulip.generate_option_group(parser))
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
client = humbug.init_from_options(options)
|
client = zulip.init_from_options(options)
|
||||||
|
|
||||||
def print_message(message):
|
def print_message(message):
|
||||||
print message
|
print message
|
||||||
|
|
|
@ -34,12 +34,12 @@ Example: print-next-messages --user=tabbott@zulip.com --api-key=a0b1c2d3e4f5a6b7
|
||||||
You can omit --user and --api-key arguments if you have a properly set up ~/.zuliprc
|
You can omit --user and --api-key arguments if you have a properly set up ~/.zuliprc
|
||||||
"""
|
"""
|
||||||
sys.path.append(path.join(path.dirname(__file__), '..'))
|
sys.path.append(path.join(path.dirname(__file__), '..'))
|
||||||
import humbug
|
import zulip
|
||||||
|
|
||||||
parser = optparse.OptionParser(usage=usage)
|
parser = optparse.OptionParser(usage=usage)
|
||||||
parser.add_option_group(humbug.generate_option_group(parser))
|
parser.add_option_group(zulip.generate_option_group(parser))
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
client = humbug.init_from_options(options)
|
client = zulip.init_from_options(options)
|
||||||
|
|
||||||
print client.get_messages({})
|
print client.get_messages({})
|
||||||
|
|
|
@ -25,7 +25,7 @@ import sys
|
||||||
from os import path
|
from os import path
|
||||||
import optparse
|
import optparse
|
||||||
sys.path.append(path.join(path.dirname(__file__), '..'))
|
sys.path.append(path.join(path.dirname(__file__), '..'))
|
||||||
import humbug
|
import zulip
|
||||||
|
|
||||||
usage = """send-message --user=<bot's email address> --api-key=<bot's api key> [options] <recipients>
|
usage = """send-message --user=<bot's email address> --api-key=<bot's api key> [options] <recipients>
|
||||||
|
|
||||||
|
@ -40,13 +40,13 @@ parser = optparse.OptionParser(usage=usage)
|
||||||
parser.add_option('--subject', default="test")
|
parser.add_option('--subject', default="test")
|
||||||
parser.add_option('--message', default="test message")
|
parser.add_option('--message', default="test message")
|
||||||
parser.add_option('--type', default='private')
|
parser.add_option('--type', default='private')
|
||||||
parser.add_option_group(humbug.generate_option_group(parser))
|
parser.add_option_group(zulip.generate_option_group(parser))
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
if len(args) == 0:
|
if len(args) == 0:
|
||||||
parser.error("You must specify recipients")
|
parser.error("You must specify recipients")
|
||||||
|
|
||||||
client = humbug.init_from_options(options)
|
client = zulip.init_from_options(options)
|
||||||
|
|
||||||
message_data = {
|
message_data = {
|
||||||
"type": options.type,
|
"type": options.type,
|
||||||
|
|
|
@ -35,14 +35,14 @@ Examples: subscribe --user=tabbott@zulip.com --api-key=a0b1c2d3e4f5a6b7c8d9e0f1a
|
||||||
You can omit --user and --api-key arguments if you have a properly set up ~/.zuliprc
|
You can omit --user and --api-key arguments if you have a properly set up ~/.zuliprc
|
||||||
"""
|
"""
|
||||||
sys.path.append(path.join(path.dirname(__file__), '..'))
|
sys.path.append(path.join(path.dirname(__file__), '..'))
|
||||||
import humbug
|
import zulip
|
||||||
|
|
||||||
parser = optparse.OptionParser(usage=usage)
|
parser = optparse.OptionParser(usage=usage)
|
||||||
parser.add_option_group(humbug.generate_option_group(parser))
|
parser.add_option_group(zulip.generate_option_group(parser))
|
||||||
parser.add_option('--streams', default='')
|
parser.add_option('--streams', default='')
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
client = humbug.init_from_options(options)
|
client = zulip.init_from_options(options)
|
||||||
|
|
||||||
if options.streams == "":
|
if options.streams == "":
|
||||||
print >>sys.stderr, "Usage:", parser.usage
|
print >>sys.stderr, "Usage:", parser.usage
|
||||||
|
|
|
@ -35,14 +35,14 @@ Examples: unsubscribe --user=tabbott@zulip.com --api-key=a0b1c2d3e4f5a6b7c8d9e0f
|
||||||
You can omit --user and --api-key arguments if you have a properly set up ~/.zuliprc
|
You can omit --user and --api-key arguments if you have a properly set up ~/.zuliprc
|
||||||
"""
|
"""
|
||||||
sys.path.append(path.join(path.dirname(__file__), '..'))
|
sys.path.append(path.join(path.dirname(__file__), '..'))
|
||||||
import humbug
|
import zulip
|
||||||
|
|
||||||
parser = optparse.OptionParser(usage=usage)
|
parser = optparse.OptionParser(usage=usage)
|
||||||
parser.add_option_group(humbug.generate_option_group(parser))
|
parser.add_option_group(zulip.generate_option_group(parser))
|
||||||
parser.add_option('--streams', default='')
|
parser.add_option('--streams', default='')
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
client = humbug.init_from_options(options)
|
client = zulip.init_from_options(options)
|
||||||
|
|
||||||
if options.streams == "":
|
if options.streams == "":
|
||||||
print >>sys.stderr, "Usage:", parser.usage
|
print >>sys.stderr, "Usage:", parser.usage
|
||||||
|
|
|
@ -40,8 +40,8 @@ import humbug_git_config as config
|
||||||
if config.HUMBUG_API_PATH is not None:
|
if config.HUMBUG_API_PATH is not None:
|
||||||
sys.path.append(config.HUMBUG_API_PATH)
|
sys.path.append(config.HUMBUG_API_PATH)
|
||||||
|
|
||||||
import humbug
|
import zulip
|
||||||
client = humbug.Client(
|
client = zulip.Client(
|
||||||
email=config.HUMBUG_USER,
|
email=config.HUMBUG_USER,
|
||||||
site=config.HUMBUG_SITE,
|
site=config.HUMBUG_SITE,
|
||||||
api_key=config.HUMBUG_API_KEY)
|
api_key=config.HUMBUG_API_KEY)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
import optparse
|
import optparse
|
||||||
import humbug
|
import zulip
|
||||||
|
|
||||||
# Nagios passes the notification details as command line options.
|
# Nagios passes the notification details as command line options.
|
||||||
# In Nagios, "output" means "first line of output", and "long
|
# In Nagios, "output" means "first line of output", and "long
|
||||||
|
@ -14,7 +14,7 @@ for opt in ('type', 'host', 'service', 'state'):
|
||||||
parser.add_option('--' + opt)
|
parser.add_option('--' + opt)
|
||||||
(opts, args) = parser.parse_args()
|
(opts, args) = parser.parse_args()
|
||||||
|
|
||||||
client = humbug.Client(config_file=opts.config)
|
client = zulip.Client(config_file=opts.config)
|
||||||
|
|
||||||
msg = dict(type='stream', to=opts.stream)
|
msg = dict(type='stream', to=opts.stream)
|
||||||
|
|
||||||
|
|
|
@ -40,8 +40,8 @@ import humbug_svn_config as config
|
||||||
if config.HUMBUG_API_PATH is not None:
|
if config.HUMBUG_API_PATH is not None:
|
||||||
sys.path.append(config.HUMBUG_API_PATH)
|
sys.path.append(config.HUMBUG_API_PATH)
|
||||||
|
|
||||||
import humbug
|
import zulip
|
||||||
client = humbug.Client(
|
client = zulip.Client(
|
||||||
email=config.HUMBUG_USER,
|
email=config.HUMBUG_USER,
|
||||||
site=config.HUMBUG_SITE,
|
site=config.HUMBUG_SITE,
|
||||||
api_key=config.HUMBUG_API_KEY)
|
api_key=config.HUMBUG_API_KEY)
|
||||||
|
|
|
@ -44,8 +44,8 @@ import humbug_trac_config as config
|
||||||
if config.HUMBUG_API_PATH is not None:
|
if config.HUMBUG_API_PATH is not None:
|
||||||
sys.path.append(config.HUMBUG_API_PATH)
|
sys.path.append(config.HUMBUG_API_PATH)
|
||||||
|
|
||||||
import humbug
|
import zulip
|
||||||
client = humbug.Client(
|
client = zulip.Client(
|
||||||
email=config.HUMBUG_USER,
|
email=config.HUMBUG_USER,
|
||||||
site=config.HUMBUG_SITE,
|
site=config.HUMBUG_SITE,
|
||||||
api_key=config.HUMBUG_API_KEY)
|
api_key=config.HUMBUG_API_KEY)
|
||||||
|
|
8
setup.py
8
setup.py
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import humbug
|
import zulip
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from distutils.core import setup
|
from distutils.core import setup
|
||||||
|
@ -12,8 +12,8 @@ def recur_expand(target_root, dir):
|
||||||
if len(paths):
|
if len(paths):
|
||||||
yield os.path.join(target_root, root), paths
|
yield os.path.join(target_root, root), paths
|
||||||
|
|
||||||
setup(name='humbug',
|
setup(name='zulip',
|
||||||
version=humbug.__version__,
|
version=zulip.__version__,
|
||||||
description='Bindings for the Zulip message API',
|
description='Bindings for the Zulip message API',
|
||||||
author='Zulip, Inc.',
|
author='Zulip, Inc.',
|
||||||
author_email='humbug@humbughq.com',
|
author_email='humbug@humbughq.com',
|
||||||
|
@ -25,7 +25,7 @@ setup(name='humbug',
|
||||||
'Topic :: Communications :: Chat',
|
'Topic :: Communications :: Chat',
|
||||||
],
|
],
|
||||||
url='https://www.zulip.com/dist/api/',
|
url='https://www.zulip.com/dist/api/',
|
||||||
packages=['humbug'],
|
packages=['zulip'],
|
||||||
data_files=[('share/humbug/examples', ["examples/zuliprc", "examples/send-message", "examples/subscribe",
|
data_files=[('share/humbug/examples', ["examples/zuliprc", "examples/send-message", "examples/subscribe",
|
||||||
"examples/get-public-streams", "examples/unsubscribe",
|
"examples/get-public-streams", "examples/unsubscribe",
|
||||||
"examples/list-members", "examples/list-subscriptions",
|
"examples/list-members", "examples/list-subscriptions",
|
||||||
|
|
Loading…
Reference in a new issue