Skip to content

Commit d3cbd7b

Browse files
committed
Optimize !social command
1 parent 9f011fb commit d3cbd7b

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

models.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
from datetime import datetime
77
from re import sub, findall
88
from random import randrange
9-
from json import loads
10-
from requests import get
119

1210
from user import User
1311

@@ -171,14 +169,12 @@ class SocialCommand(Command):
171169
user = User()
172170

173171
def __call__(self, args, data=None):
174-
try:
175-
user_data = self.user.request("GET", "/channels/{channel}".format(channel=data['channel']), fields='user')['user']
176-
except Exception:
177-
raise Exception("Bad things went boom! (Invalid channel: {chan})".format(chan=data['channel']))
178-
return "Things when boom! Invalid channel {chan}".format(chan=data['channel'])
179-
print(user_data)
172+
social = self.user.request("GET", "/channels/{id}".format(
173+
id=data['channel']), fields='user')["user"]["social"]
174+
if social:
175+
return ', '.join(': '.join((k.title(), social[k])) for k in social)
176+
return "No social services were found on the streamer's profile."
180177

181-
return ' '.join(user_data['social'].values())
182178

183179
# #### TO BE REDONE IN USERS MODEL #### #
184180

user.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
class User:
99
path = "https://beam.pro/api/v1"
10-
channel = ""
1110

1211
def __init__(self, debug="WARNING", **kwargs):
1312
self._init_logger(debug)

0 commit comments

Comments
 (0)