Skip to content
This repository was archived by the owner on Jun 5, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 40 additions & 16 deletions rhonrhon.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from twython import TwythonStreamer
from twython import TwythonError, TwythonRateLimitError, TwythonAuthError
from daemonize import Daemonize
import random

import rhonmod.coin

Expand Down Expand Up @@ -269,29 +270,34 @@ def on_pubmsg(self, serv, ev):
if 'nolog' in tags:
return

# handle yolo tag
if re.search('[\[#]\ *yolo\ *[#\]]', pl, re.I):
msg = '{0}: you got SWAG'
self.send_message(serv, channel, msg.format(nick))
if self.flip_coin():
return
pl = re.sub(r"[\[#]\ *yolo\ *[#\]]", "", pl);
tags.append('yolo')

urls = re.findall('(https?://[^\s]+)', pl)
urls_copy = list(urls)
for url in urls_copy:
(vieille, rep) = self.vieille(url, channel)
if vieille:
try:
msg = '{0}: VIEUX ! The URL [ {1} ] has been posted '
msg = '{0}: VIEUX ! The URL [ {1} ] has been posted '
msg = msg + 'by {2} the {3} at {4}.'

if len(msg) > 512:
msg = '{0}: VIEUX ! This URL has been posted '
msg = msg + 'by {2} the {3} at {4}.'

if len(msg) > 512:
msg = '{0}: VIEUX ! This URL has been posted '
msg = msg + 'by {2} the {3} at {4}.'

serv.privmsg('#{0}'.format(channel),
msg.format(nick,
url,
'you' if rep['_source']['nick'] == nick
else rep['_source']['nick'],
rep['_source']['date'],
rep['_source']['time']))
except Exception as e:
logger.warn(e)
pass
self.send_message(serv, channel,
msg.format(nick,
url,
'you' if rep['_source']['nick'] == nick
else rep['_source']['nick'],
rep['_source']['date'],
rep['_source']['time']))

urls.remove(url)

Expand Down Expand Up @@ -326,6 +332,20 @@ def on_pubmsg(self, serv, ev):
r = es.index(index=es_idx, doc_type=channel, body=json.dumps(data))
logger.debug(r)

def send_message(self, serv, channel, msg):
try:

if len(msg) > 512:
return

serv.privmsg('#{0}'.format(channel), msg)

except Exception as e:
logger.warn(e)
pass



def handle_noauth_privcmd(self, serv, ev, s):
if s[0] == 'rage':
self.showrage(serv, ev, 'priv')
Expand Down Expand Up @@ -482,6 +502,10 @@ def vieille(self, url, channel):
pass
return (False, [])

def flip_coin(self):
if random.random() > 0.5:
return True
return False


foreground = False
Expand Down
7 changes: 7 additions & 0 deletions www/static/gcu.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ body {
.line {
margin-left: 5px;
}
.yolo {
margin-left: 5px;
font-weight: bold;
color: red;
text-decoration: blink;
font-family: "Comic Sans MS", cursive, sans-serif;
}
.tags {
margin-left: 5px;
}
Expand Down
10 changes: 9 additions & 1 deletion www/templates/gerard.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,15 @@ var process_ircline = function(data, lastdate, cnt, pos) {
/* destination nicks */
{{ js.buttonlst('tonick', ircline_style) }}
/* real line */
ircline += '<span class="line">' + decoline(source) + '</span>';

var line_class = 'line';
if (source.tags && source.tags[0] && $.inArray('yolo', source.tags) !== false) {
ircline += '<span class="yolo"><marquee behavior="alternate">' + decoline(source) + '</marquee></span>';
}
else {
ircline += '<span class="line">' + decoline(source) + '</span>';
}

/* tags */
{{ js.buttonlst('tags', ircline_style, 'tag') }}

Expand Down