Change API example usernames to use example.com domain.

(imported from commit 41b7be58735df0ea3d3a3daf23bc0f78606abc0d)
This commit is contained in:
Tim Abbott 2015-09-19 18:12:02 -07:00
parent 7272ed89fb
commit c20623b841
7 changed files with 16 additions and 14 deletions

View file

@ -12,9 +12,11 @@ from irc.client import ip_numstr_to_quad, ip_quad_to_numstr
import zulip import zulip
import optparse import optparse
IRC_DOMAIN = "irc.example.com"
def zulip_sender(sender_string): def zulip_sender(sender_string):
nick = sender_string.split("!")[0] nick = sender_string.split("!")[0]
return nick + "@irc.zulip.com" return nick + "@" + IRC_DOMAIN
class IRCBot(irc.bot.SingleServerIRCBot): class IRCBot(irc.bot.SingleServerIRCBot):
def __init__(self, channel, nickname, server, port=6667): def __init__(self, channel, nickname, server, port=6667):
@ -47,14 +49,14 @@ class IRCBot(irc.bot.SingleServerIRCBot):
def on_privmsg(self, c, e): def on_privmsg(self, c, e):
content = e.arguments[0] content = e.arguments[0]
sender = zulip_sender(e.source) sender = zulip_sender(e.source)
if sender.endswith("_zulip@irc.zulip.com"): if sender.endswith("_zulip@" + IRC_DOMAIN):
return return
# Forward the PM to Zulip # Forward the PM to Zulip
print zulip_client.send_message({ print zulip_client.send_message({
"sender": sender, "sender": sender,
"type": "private", "type": "private",
"to": "tabbott@zulip.com", "to": "username@example.com",
"content": content, "content": content,
}) })
@ -62,7 +64,7 @@ class IRCBot(irc.bot.SingleServerIRCBot):
content = e.arguments[0] content = e.arguments[0]
stream = e.target stream = e.target
sender = zulip_sender(e.source) sender = zulip_sender(e.source)
if sender.endswith("_zulip@irc.zulip.com"): if sender.endswith("_zulip@" + IRC_DOMAIN):
return return
# Forward the stream message to Zulip # Forward the stream message to Zulip
@ -94,8 +96,8 @@ usage = """python irc-mirror.py --server=IRC_SERVER --channel=<CHANNEL> --nick-p
Example: Example:
python irc-mirror.py --irc-server=127.0.0.1 --channel='#test' --nick-prefix=tabbott python irc-mirror.py --irc-server=127.0.0.1 --channel='#test' --nick-prefix=username
--site=https://staging.zulip.com --user=irc-bot@zulip.com --site=https://zulip.example.com --user=irc-bot@example.com
--api-key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx --api-key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Note that "_zulip" will be automatically appended to the IRC nick provided Note that "_zulip" will be automatically appended to the IRC nick provided

View file

@ -29,7 +29,7 @@ usage = """list-subscriptions --user=<bot's email address> --api-key=<bot's api
Prints out a list of the user's subscriptions. Prints out a list of the user's subscriptions.
Example: list-subscriptions --user=tabbott@zulip.com --api-key=a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 Example: list-subscriptions --user=username@example.com --api-key=a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5
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
""" """

View file

@ -29,7 +29,7 @@ usage = """print-events --user=<bot's email address> --api-key=<bot's api key> [
Prints out certain events received by the indicated bot or user matching the filter below. Prints out certain events received by the indicated bot or user matching the filter below.
Example: print-events --user=tabbott@zulip.com --api-key=a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 Example: print-events --user=username@example.com --api-key=a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5
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
""" """

View file

@ -29,7 +29,7 @@ usage = """print-messages --user=<bot's email address> --api-key=<bot's api key>
Prints out each message received by the indicated bot or user. Prints out each message received by the indicated bot or user.
Example: print-messages --user=tabbott@zulip.com --api-key=a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 Example: print-messages --user=username@example.com --api-key=a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5
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
""" """

View file

@ -29,7 +29,7 @@ usage = """print-next-message --user=<bot's email address> --api-key=<bot's api
Prints out the next message received by the user. Prints out the next message received by the user.
Example: print-next-messages --user=tabbott@zulip.com --api-key=a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 Example: print-next-messages --user=username@example.com --api-key=a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5
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
""" """

View file

@ -29,8 +29,8 @@ usage = """subscribe --user=<bot's email address> --api-key=<bot's api key> [opt
Ensures the user is subscribed to the listed streams. Ensures the user is subscribed to the listed streams.
Examples: subscribe --user=tabbott@zulip.com --api-key=a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 --streams=foo Examples: subscribe --user=username@example.com --api-key=a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 --streams=foo
subscribe --user=tabbott@zulip.com --api-key=a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 --streams='foo bar' subscribe --user=username@example.com --api-key=a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 --streams='foo bar'
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
""" """

View file

@ -29,8 +29,8 @@ usage = """unsubscribe --user=<bot's email address> --api-key=<bot's api key> [
Ensures the user is not subscribed to the listed streams. Ensures the user is not subscribed to the listed streams.
Examples: unsubscribe --user=tabbott@zulip.com --api-key=a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 --streams=foo Examples: unsubscribe --user=username@example.com --api-key=a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 --streams=foo
unsubscribe --user=tabbott@zulip.com --api-key=a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 --streams='foo bar' unsubscribe --user=username@example.com --api-key=a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 --streams='foo bar'
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
""" """