Skip to content

Commit

Permalink
Merge pull request #226 from DeForce/LC-222
Browse files Browse the repository at this point in the history
LC-222 Cleanup for Release v0.3.5
  • Loading branch information
DeForce authored Jan 15, 2017
2 parents b1e9400 + 4461d41 commit a56cad0
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 23 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ levels.db*
*.log
govno_rutony.py
/node_modules/
/http
13 changes: 8 additions & 5 deletions gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,9 @@ def clear_changes():
main_tuple = []
for item, i_value in self.main_class.loaded_modules[split_keys[0]]['config'][split_keys[1]].iteritems():
if i_value:
main_tuple.append((item, i_value))
main_tuple.append((item.decode('utf-8'), i_value.decode('utf-8')))
else:
main_tuple.append((item,))
main_tuple.append((item.decode('utf-8'),))

if compare_2d_lists(value, main_tuple):
clear_changes()
Expand Down Expand Up @@ -821,7 +821,7 @@ def set_viewers(self, module, viewers):
if isinstance(viewers, int):
viewers = str(viewers)
if len(viewers) >= 5:
viewers = '{0}k'.format(viewers[:2])
viewers = '{0}k'.format(viewers[:-3])
self.chats[module]['label'].SetLabel(str(viewers))
self.Layout()

Expand Down Expand Up @@ -859,14 +859,17 @@ def __init__(self, parent, title, url, **kwargs):
vbox.Add(self.status_frame, 0, wx.EXPAND)
if self.gui_settings['show_browser']:
vbox.Add(chromectrl.ChromeCtrl(self, useTimer=False, url=str(url), hasNavBar=False), 1, wx.EXPAND)
else:
self.Fit()

# Set events
self.Bind(wx.EVT_CLOSE, self.on_close)

# Show window after creation
self.SetSizer(vbox)

if not self.gui_settings['show_browser']:
self.Layout()
self.Fit()

self.Show(True)

# Show update dialog if new version found
Expand Down
8 changes: 6 additions & 2 deletions modules/chat/goodgame.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import logging
from collections import OrderedDict
from modules.helper.parser import load_from_config_file
from modules.helper.system import system_message, translate_key, remove_message_by_id, EMOTE_FORMAT
from modules.helper.system import system_message, translate_key, remove_message_by_id, EMOTE_FORMAT, NA_MESSAGE
from modules.helper.module import ChatModule
from ws4py.client.threadedclient import WebSocketClient
from gui import MODULE_KEY
Expand Down Expand Up @@ -347,7 +347,11 @@ def get_viewers(self):
try:
request = requests.get(streams_url)
if request.status_code == 200:
return request.json().get('player_viewers')
json_data = request.json()
if json_data['status'] == 'Live':
return request.json().get('player_viewers')
else:
return NA_MESSAGE
else:
raise Exception("Not successful status code: {0}".format(request.status_code))
except Exception as exc:
Expand Down
31 changes: 22 additions & 9 deletions modules/chat/sc2tv.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,25 @@ def load_module(self, *args, **kwargs):
self.fs_thread = fs
fs.start()

@staticmethod
def get_viewers(ws):
request = [
'/chat/channel/list',
{
'channel': 'stream/{0}'.format(str(ws.channel_id))
}
]
ws.fs_send(request)
def get_viewers(self, ws):
user_data = {'name': ws.channel_name}
status_data = {'slug': ws.channel_name}
request = ['/chat/channel/list', {'channel': 'stream/{0}'.format(str(ws.channel_id))}]

try:
user_request = requests.post('http://funstream.tv/api/user', timeout=5, data=user_data)
if user_request.status_code == 200:
status_data['slug'] = user_request.json()['slug']
except requests.ConnectionError:
log.error("Unable to get smiles")

try:
status_request = requests.post('http://funstream.tv/api/stream', timeout=5, data=status_data)
if status_request.status_code == 200:
if status_request.json()['online']:
ws.fs_send(request)
else:
self.set_viewers('N/A')

except requests.ConnectionError:
log.error("Unable to get smiles")
7 changes: 5 additions & 2 deletions modules/chat/twitch.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import time
from modules.helper.parser import load_from_config_file
from modules.helper.module import ChatModule
from modules.helper.system import system_message, translate_key, remove_message_by_user, EMOTE_FORMAT
from modules.helper.system import system_message, translate_key, remove_message_by_user, EMOTE_FORMAT, NA_MESSAGE
from gui import MODULE_KEY

logging.getLogger('irc').setLevel(logging.ERROR)
Expand Down Expand Up @@ -452,7 +452,10 @@ def get_viewers(self):
try:
request = requests.get(streams_url, headers=headers)
if request.status_code == 200:
return request.json()['stream'].get('viewers')
json_data = request.json()
if json_data['stream']:
return request.json()['stream'].get('viewers', NA_MESSAGE)
return NA_MESSAGE
else:
raise Exception("Not successful status code: {0}".format(request.status_code))
except Exception as exc:
Expand Down
2 changes: 2 additions & 0 deletions modules/helper/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
SOURCE_USER = 'System'
SOURCE_ICON = '/img/sources/lalka_cup.png'

NA_MESSAGE = 'N/A'

IGNORED_TYPES = ['command', 'system_message']
TRANSLATIONS = {}
SPLIT_TRANSLATION = '='
Expand Down
3 changes: 2 additions & 1 deletion modules/messaging/c2b.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ def process_message(self, message, queue, **kwargs):
return message

for item, replace in self._conf_params['config']['config'].iteritems():
item = item.decode('utf-8')
if item in message['text']:
replace_word = random.choice(replace.split('/'))
replace_word = random.choice(replace.split('/')).decode('utf-8')
if message['source'] == 'tw':
message['emotes'] = twitch_replace_indexes(item, message['text'],
len(item), len(replace_word),
Expand Down
4 changes: 2 additions & 2 deletions modules/messaging/webchat.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from gui import MODULE_KEY
from main import PYTHON_FOLDER, CONF_FOLDER

DEFAULT_STYLE = 'default'
DEFAULT_PRIORITY = 9001
HISTORY_SIZE = 20
HISTORY_TYPES = ['system_message', 'message']
Expand Down Expand Up @@ -388,12 +389,11 @@ def start_webserver(self):

@staticmethod
def get_style_path(style):
fallback_style = 'czt'
path = os.path.abspath(os.path.join(HTTP_FOLDER, style))
if os.path.exists(path):
style_location = path
else:
style_location = os.path.join(HTTP_FOLDER, fallback_style)
style_location = os.path.join(HTTP_FOLDER, DEFAULT_STYLE)
return style_location

def reload_chat(self):
Expand Down
3 changes: 3 additions & 0 deletions translations/en/main.key
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ menu.reload = Reload WebChat
*.list_remove = Remove
*.descr_explain = Click on an item to view description of the item
*.description = No description
*.show_pm = Mark messages for channel

settings = Settings
settings.main = Main Settings
Expand All @@ -17,6 +18,8 @@ main = Main
main.gui = GUI Settings
main.gui.show_hidden = Show hidden items
main.gui.gui = Is GUI enabled
main.gui.show_browser = Show browser window
main.gui.show_counters = Show channel view counters
main.gui.on_top = Show window on top
main.gui.very_big_parameter_with_really_big_name_and_a_lot_of_not_needed_stuff = Just a big parameter for test
main.gui.reload = Reload WebChat
Expand Down
9 changes: 8 additions & 1 deletion translations/en/webchat.key
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,11 @@ webchat.server.port = Port
webchat.style = Available styles
webchat.style.list_box =
webchat.style_settings = Style Settings
webchat.style_settings.font_size = Font Size (pt)
webchat.style_settings.font_size = Font Size (pt)
webchat.style_settings.show_system_msg = Show system messages
webchat.style_settings.remove_message = Replace deleted Messages
webchat.style_settings.remove_text = Replaced Message text
webchat.style_settings.timer = Message clear timer
webchat.style_settings.message_opacity = Background opacity
webchat.style_settings.smile_size = Smile Size (px)
webchat.style_settings.badge_size = Badge Size (px)
3 changes: 3 additions & 0 deletions translations/ru/main.key
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ menu.reload = Перезагрузить Чат
*.list_remove = Удалить
*.descr_explain = Выберите вещь, описание которой вы хотите прочитать.
*.description = Описание не предоставлено
*.show_pm = Выделять личные сообщения

settings = Настройки
settings.main = Главные Настройки
Expand All @@ -17,6 +18,8 @@ main = Главные Настройки
main.gui = Настройки Интерфейса
main.gui.show_hidden = Показвать скрытые вещи
main.gui.gui = Интерфейс Включен
main.gui.show_browser = Показывать окно браузера
main.gui.show_counters = Показывать счетчики зрителей
main.gui.on_top = Окно поверх всех
main.gui.very_big_parameter_with_really_big_name_and_a_lot_of_not_needed_stuff = Тестовый Параметр
main.gui.reload = Перезагрузить ВебЧат
Expand Down
8 changes: 7 additions & 1 deletion translations/ru/webchat.key
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,10 @@ webchat.style = Доступные Стили
webchat.style.list_box =
webchat.style_settings = Настройки Стиля
webchat.style_settings.font_size = Размер шрифта

webchat.style_settings.show_system_msg = Показывать системные сообщения
webchat.style_settings.remove_message = Заменять удалённые сообщения
webchat.style_settings.remove_text = Текст замещенного сообщения
webchat.style_settings.timer = Срок жизни сообщения
webchat.style_settings.message_opacity = Прозрачность фона
webchat.style_settings.smile_size = Размер смайлов (px)
webchat.style_settings.badge_size = Размер бейджей (px)

0 comments on commit a56cad0

Please sign in to comment.