mirror of https://github.com/zulip/zulip.git
Delete deprecated iframe-bot.
This commit is contained in:
parent
1d414a432f
commit
0dc9ac7dac
|
@ -1,24 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
## For some reason, this doesn't work with a bot user.
|
||||
#BOT_EMAIL=bot1@customer3.invalid
|
||||
#API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
BOT_EMAIL=wdaher@gmail.com
|
||||
API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
STREAMS="event1 hongkong etc"
|
||||
COUNT=50
|
||||
|
||||
mkdir -p output
|
||||
while true; do
|
||||
|
||||
if ./show-last-messages --api-key="$API_KEY" --user="$BOT_EMAIL" --streams="$STREAMS" --count="$COUNT"; then
|
||||
echo "[`date`] Success";
|
||||
mv output-candidate.html output/zulip.html
|
||||
touch output/zulip.html
|
||||
else
|
||||
echo "[`date`] FAILURE";
|
||||
fi
|
||||
|
||||
sleep 30;
|
||||
|
||||
done
|
|
@ -1,180 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright © 2013 Zulip, Inc.
|
||||
|
||||
### NOTE: You must copy the emoji along with this script if you want
|
||||
### them to work properly
|
||||
### (to static/generated/emoji/images/)
|
||||
|
||||
|
||||
from __future__ import print_function
|
||||
import sys
|
||||
sys.path.append('zulip')
|
||||
import os
|
||||
import optparse
|
||||
import codecs
|
||||
|
||||
from typing import IO
|
||||
|
||||
usage = """show-last-messages --user=<bot's email address> --api-key=<bot's api key> --count=<count>
|
||||
|
||||
Shows the last <count> messages on all public streams.
|
||||
|
||||
Examples: subscribe --user=username@example.com --api-key=a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 --count=5 --streams=social
|
||||
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
|
||||
"""
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
|
||||
import zulip
|
||||
|
||||
parser = optparse.OptionParser(usage=usage)
|
||||
parser.add_option_group(zulip.generate_option_group(parser))
|
||||
parser.add_option('--streams', default='')
|
||||
parser.add_option('--count', default=5)
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
client = zulip.init_from_options(options)
|
||||
|
||||
if options.streams == "":
|
||||
print("Usage:", parser.usage, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
client.add_subscriptions([{"name": stream_name} for stream_name in
|
||||
options.streams.split()])
|
||||
queue = client.register(event_types=['message'])
|
||||
|
||||
|
||||
# TODO: The following code never works. We should probably remove
|
||||
# this deprecated script entirely, but if we need to resurrect it,
|
||||
# we need to fix the code below to work with the new API.
|
||||
client._register('get_old_messages', method='GET', url='messages')
|
||||
|
||||
result = client.get_old_messages({'anchor': queue['max_message_id'],
|
||||
'num_before': int(options.count),
|
||||
'num_after': 0,
|
||||
'apply_markdown': True})
|
||||
|
||||
if result['result'] != 'success':
|
||||
sys.exit(1)
|
||||
|
||||
f = codecs.open("output-candidate.html", encoding='utf-8', mode="wb")
|
||||
|
||||
def uniwrite(f, s):
|
||||
# type: (IO, str) -> None
|
||||
f.write(s)
|
||||
|
||||
uniwrite(f, """
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta http-equiv="refresh" content="120" />
|
||||
<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,700' rel='stylesheet' type='text/css'>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<script>
|
||||
var t=setTimeout(function(){ window.scrollTo(0,document.body.scrollHeight); },500)
|
||||
</script>
|
||||
|
||||
<style type="text/css">
|
||||
body {
|
||||
font-family: 'Source Sans Pro', 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
||||
font-size: 14px;
|
||||
background-color: #eee;
|
||||
}
|
||||
|
||||
p,ul,code,pre {
|
||||
margin-top: 3px;
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
|
||||
.message {
|
||||
background-color: white;
|
||||
border: 1px solid grey;
|
||||
border-radius: 0.25em;
|
||||
padding: 0.25em;
|
||||
padding-left: 0.5em;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
width: 25px;
|
||||
height: 25px;
|
||||
margin-right: 10px;
|
||||
border-radius: 25px;
|
||||
border: 1px solid #CCC;
|
||||
|
||||
float: right;
|
||||
}
|
||||
|
||||
.sender {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.recipient {
|
||||
margin-right: 0.5em;
|
||||
border-radius: 0.25em;
|
||||
padding: 2px;
|
||||
padding-left: 5px;
|
||||
padding-right: 5px;
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.twitter-tweet {
|
||||
border: 1px solid #ddd;
|
||||
padding: .5em .75em;
|
||||
margin-bottom: 0.25em;
|
||||
}
|
||||
|
||||
.twitter-avatar {
|
||||
float: left;
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
margin-right: .75em;
|
||||
}
|
||||
|
||||
.emoji {
|
||||
width: 1.4em;
|
||||
vertical-align: text-bottom;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div>
|
||||
<p>For more, join the conversation on <a href="https://zulip.com/register/customer3.invalid" target="_blank">Zulip</a>.
|
||||
</p>
|
||||
""")
|
||||
|
||||
color = {'event1': '#76ce90', 'hongkong': '#fae589', 'etc': '#a6c7e5'}
|
||||
|
||||
for msg in result['messages']:
|
||||
if msg['type'] != 'stream':
|
||||
# Don't show PMs the bot got
|
||||
continue
|
||||
if msg['sender_full_name'] == 'TwitterBot':
|
||||
# Don't put tweets in the iframe
|
||||
continue
|
||||
|
||||
uniwrite(f, '<div class="message">')
|
||||
|
||||
uniwrite(f, '<img class="avatar" src="%s" />' % msg['avatar_url'])
|
||||
|
||||
uniwrite(f, '<div class="sender-bar">')
|
||||
uniwrite(f, '<div class="recipient" style="background-color: %s;">%s > %s</div>' % (
|
||||
color[msg['display_recipient']], msg['display_recipient'], msg['subject']))
|
||||
uniwrite(f, '<span class="sender">%s</span>' % msg['sender_full_name'])
|
||||
uniwrite(f, '</div>')
|
||||
|
||||
uniwrite(f, '<div class="content">%s</div>' % msg['content'])
|
||||
uniwrite(f, "</div>")
|
||||
|
||||
uniwrite(f, """
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
""")
|
||||
|
||||
sys.exit(0)
|
|
@ -25,7 +25,6 @@ api/integrations/perforce/zulip_perforce_config.py
|
|||
api/integrations/svn/zulip_svn_config.py
|
||||
api/integrations/trac/zulip_trac_config.py
|
||||
api/integrations/git/post-receive
|
||||
tools/deprecated/iframe-bot/show-last-messages
|
||||
tools/deprecated/inject-messages/inject-messages
|
||||
zproject/settings.py
|
||||
zproject/test_settings.py
|
||||
|
|
Loading…
Reference in New Issue