Compare commits

...

3 Commits

3 changed files with 18 additions and 9 deletions

View File

@ -11,11 +11,11 @@ from . import Plugin
from .utils import re_generator
GNU_LINUX = """I'd Just Like To Interject For A Moment. What you're referring
to as Linux, is in fact, GNU/Linux, or as I've recently taken to calling it,
GNU plus Linux. Linux is not an operating system unto itself, but rather
another free component of a fully functioning GNU system made useful by the
GNU corelibs, shell utilities and vital system components comprising a full
OS as defined by POSIX."""
to as Linux, is in fact, GNU/Linux, or as I've recently taken to calling it,
GNU plus Linux. Linux is not an operating system unto itself, but rather
another free component of a fully functioning GNU system made useful by the
GNU corelibs, shell utilities and vital system components comprising a full
OS as defined by POSIX."""
class Linux(Plugin):

View File

@ -49,8 +49,8 @@ class McManiac(DatabasePlugin):
if result:
return '[{rank}/{total}] {item}'.format(**result)
@irc3.event(r'^:(?P<mask>\S+) PRIVMSG \S+ :.*?\b(?P<item>Mc\S+iaC)\b.*')
def save(self, mask: str, item: str):
@irc3.event(r'^:(?P<mask>\S+) PRIVMSG (?P<channel>#\S+) :.*?\b(?P<item>Mc\S+iaC)\b.*')
def save(self, mask: str, channel: str, item: str):
if IrcString(mask).nick != self.bot.nick:
with self.con.cursor() as cur:
cur.execute('''
@ -59,5 +59,11 @@ class McManiac(DatabasePlugin):
VALUES
(%s)
ON CONFLICT DO NOTHING
RETURNING
(SELECT (count(*) + 1) AS total FROM mcmaniacs)
''', [item])
self.con.commit()
self.con.commit()
result = cur.fetchone()
if result is None:
return
self.bot.privmsg(channel, f"{result['total']}. mcmanic added: {item}")

View File

@ -16,6 +16,7 @@ class YouTube(Plugin):
URL = 'https://www.googleapis.com/youtube/v3'
API = '{}/videos?part=snippet,statistics,contentDetails'.format(URL)
SEARCH = '{}/search?part=id'.format(URL)
RETURN_YOUTUBE_DISLIKE_API = 'https://returnyoutubedislikeapi.com/votes'
def get_video_data(self, video_id: str):
"""Requests the infos for a video id and formats them."""
@ -24,13 +25,15 @@ class YouTube(Plugin):
if not data.get('items'):
return
return_youtube_dislike_response = requests.get(self.RETURN_YOUTUBE_DISLIKE_API, params={'videoId': video_id}).json()
item = data['items'][0]
date = date_from_iso(item['snippet']['publishedAt'])
length = re.findall('(\d+[DHMS])', item['contentDetails']['duration'])
views = int(item['statistics'].get('viewCount', 0))
likes = int(item['statistics'].get('likeCount', 0))
dislikes = int(item['statistics'].get('dislikeCount', 0))
dislikes = int(return_youtube_dislike_response.get('dislikes', 0))
try:
score = 100 * float(likes) / (likes + dislikes)