Blabb
This commit is contained in:
parent
fb4e7b2d5b
commit
e69307283d
@ -21,10 +21,10 @@ class Coins(Plugin):
|
||||
"""
|
||||
data = requests.get('https://www.bitstamp.net/api/ticker').json()
|
||||
values = {k: float(data[k]) for k in ['last', 'high', 'low', 'volume']}
|
||||
return '\x02[BitStamp]\x02 ' \
|
||||
return '\x02[Bitcoin]\x02 ' \
|
||||
'Current: \x02\x037${last:,.2f}\x0F - ' \
|
||||
'High: \x02\x033${high:,.2f}\x0F - ' \
|
||||
'Low: \x02\x035${low:,.2f}\x0F - ' \
|
||||
'Low: \x02\x034${low:,.2f}\x0F - ' \
|
||||
'Volume: \x02฿{volume:,.2f}\x02'.format(**values)
|
||||
|
||||
@command
|
||||
|
@ -14,24 +14,28 @@ class CTCP(Plugin):
|
||||
requires = ['irc3.plugins.async',
|
||||
'irc3.plugins.command']
|
||||
|
||||
TIMEOUT = 10
|
||||
|
||||
async def ctcp(self, ctcp: str, mask: IrcString, args: DocOptDict):
|
||||
nick = args.get('<nick>') or mask.nick
|
||||
name = ctcp.upper()
|
||||
ctcp = await self.bot.ctcp_async(nick, name, timeout=self.TIMEOUT)
|
||||
if not ctcp or ctcp['timeout']:
|
||||
reply = 'timeout'
|
||||
elif not ctcp['success']:
|
||||
reply = 'Error: {reply}'.format(reply=ctcp['reply'])
|
||||
else:
|
||||
reply = ctcp['reply']
|
||||
return '\x02[{ctcp}]\x0F {nick}: {reply}'.format(
|
||||
ctcp=name,
|
||||
@staticmethod
|
||||
def _ctcp(name: str, nick: str, reply: str):
|
||||
return '\x02[{name}]\x02 {nick}: {reply}'.format(
|
||||
name=name.upper(),
|
||||
nick=nick,
|
||||
reply=reply,
|
||||
)
|
||||
|
||||
async def ctcp(self, name: str, mask: IrcString, args: DocOptDict):
|
||||
nick = args.get('<nick>') or mask.nick
|
||||
name = name.upper()
|
||||
data = await self.bot.ctcp_async(nick, name)
|
||||
|
||||
if not data or data['timeout']:
|
||||
reply = 'timeout'
|
||||
elif not data['success']:
|
||||
reply = 'Error: {reply}'.format(reply=data['reply'])
|
||||
else:
|
||||
reply = data['reply']
|
||||
|
||||
return self._ctcp(name, nick, reply)
|
||||
|
||||
@command
|
||||
async def ping(self, mask: IrcString, channel: IrcString,
|
||||
args: DocOptDict):
|
||||
@ -40,21 +44,22 @@ class CTCP(Plugin):
|
||||
%%ping [<nick>]
|
||||
"""
|
||||
nick = args.get('<nick>') or mask.nick
|
||||
ctcp = await self.bot.ctcp_async(nick, 'PING {0}'.format(time.time()),
|
||||
timeout=self.TIMEOUT)
|
||||
if not ctcp or ctcp['timeout']:
|
||||
data = await self.bot.ctcp_async(nick, 'PING {0}'.format(time.time()))
|
||||
|
||||
if not data or data['timeout']:
|
||||
reply = 'timeout'
|
||||
elif not ctcp['success']:
|
||||
reply = 'Error: {reply}'.format(reply=ctcp['reply'])
|
||||
elif not data['success']:
|
||||
reply = 'Error: {reply}'.format(reply=data['reply'])
|
||||
else:
|
||||
delta = time.time() - float(ctcp['reply'])
|
||||
delta = time.time() - float(data['reply'])
|
||||
if delta < 1.0:
|
||||
delta *= 1000
|
||||
unit = 'ms'
|
||||
else:
|
||||
unit = 's'
|
||||
reply = '{delta:.3f} {unit}'.format(unit=unit, delta=delta)
|
||||
return '\x02[PING]\x0F {nick}: {text}'.format(nick=nick, text=reply)
|
||||
|
||||
return self._ctcp('PING', nick, reply)
|
||||
|
||||
@command
|
||||
async def finger(self, mask: IrcString, channel: IrcString,
|
||||
|
@ -21,6 +21,11 @@ GNU_LINUX = """I'd Just Like To Interject For A Moment. What you're referring
|
||||
class Linux(Plugin):
|
||||
KERNEL_FEED = 'https://www.kernel.org/feeds/kdist.xml'
|
||||
|
||||
@irc3.event(r'(?i)^:\S+ PRIVMSG (?P<channel>\S+) :.*(debian|apt|dpkg).*')
|
||||
def debillian(self, channel: str):
|
||||
if random.randint(0, 3) is 0:
|
||||
self.bot.privmsg(channel, 'REEEEEEEEEEEEEEEEEEEEEEEEEEEEE')
|
||||
|
||||
@irc3.event(r'(?i)^:\S+ PRIVMSG (?P<channel>\S+) :'
|
||||
r'.*(?<!gnu[/+])linux(?! kernel).*')
|
||||
def linux(self, channel: str):
|
||||
@ -38,8 +43,8 @@ class Linux(Plugin):
|
||||
for e in feed['entries']:
|
||||
version, branch = e['title'].split(': ')
|
||||
if '(EOL)' in e['description']:
|
||||
branch = '{branch}, \x1DEOL\x0F'.format(branch=branch)
|
||||
releases.append('\x02{version}\x0F ({branch})'.format(
|
||||
branch = '{branch}, \x1DEOL\x1D'.format(branch=branch)
|
||||
releases.append('\x02{version}\x02 ({branch})'.format(
|
||||
version=version,
|
||||
branch=branch,
|
||||
))
|
||||
|
@ -27,7 +27,7 @@ class Rape(DatabasePlugin):
|
||||
owes = self.cur.fetchone()
|
||||
|
||||
if owes:
|
||||
total = '5${total}'.format(total=owes['amount'])
|
||||
total = '4${total}'.format(total=owes['amount'])
|
||||
else:
|
||||
total = '3$0'
|
||||
|
||||
|
@ -10,6 +10,7 @@ from irc3.utils import IrcString
|
||||
from . import DatabasePlugin
|
||||
|
||||
|
||||
@irc3.plugin
|
||||
class Seen(DatabasePlugin):
|
||||
requires = ['irc3.plugins.command',
|
||||
'nxy.plugins.database']
|
||||
|
@ -1,7 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import irc3
|
||||
import os
|
||||
import re
|
||||
import requests
|
||||
|
||||
from docopt import Dict as DocOptDict
|
||||
@ -9,7 +7,6 @@ from irc3.plugins.command import command
|
||||
from irc3.utils import IrcString
|
||||
|
||||
from . import Plugin
|
||||
from ..utils import date_from_iso
|
||||
|
||||
|
||||
@irc3.plugin
|
||||
@ -20,30 +17,27 @@ class Urban(Plugin):
|
||||
|
||||
@command
|
||||
def ud(self, mask: IrcString, channel: IrcString, args: DocOptDict):
|
||||
"""Searches for query on YouTube and returns first result.
|
||||
"""Searches for a term on YouTube and returns first result.
|
||||
|
||||
%%ud <query>...
|
||||
%%ud <term>...
|
||||
"""
|
||||
query = ' '.join(args.get('<query>')).lower().strip().split()
|
||||
term = ' '.join(args.get('<term>')).lower().strip().split()
|
||||
|
||||
if query[-1].isdigit():
|
||||
idx = int(query[-1]) - 1
|
||||
query = ' '.join(query[:-1])
|
||||
if term[-1].isdigit():
|
||||
idx = int(term[-1]) - 1
|
||||
term = ' '.join(term[:-1])
|
||||
else:
|
||||
idx = 0
|
||||
|
||||
data = requests.get(self.URL, params=dict(term=query)).json()
|
||||
|
||||
data = requests.get(self.URL, params=dict(term=term)).json()
|
||||
if data['result_type'] == 'no_results':
|
||||
return '[UrbanDictionary] Query not found'
|
||||
res = data['list'][idx]
|
||||
return 'Term not found'
|
||||
|
||||
try:
|
||||
return '[{idx}/{len}] \x02{word}\x02: {definition} - {example}' \
|
||||
.format(idx=idx + 1,
|
||||
len=len(data['list']),
|
||||
word=res['word'],
|
||||
definition=res['definition'].replace('\r\n', ' '),
|
||||
example=res['example'].replace('\r\n', ' '))
|
||||
except IndexError:
|
||||
return '[UrbanDictionary] Error getting result'
|
||||
res = data['list'][idx]
|
||||
return '[{idx}/{len}] \x02{word}\x02: {definition} - {example}'.format(
|
||||
idx=idx + 1,
|
||||
len=len(data['list']),
|
||||
word=res['word'],
|
||||
definition=res['definition'].replace('\r\n', ' '),
|
||||
example=res['example'].replace('\r\n', ' '),
|
||||
)
|
||||
|
@ -64,9 +64,9 @@ class Useless(Plugin):
|
||||
%%jn <question>
|
||||
%%jn
|
||||
"""
|
||||
choice = random.choice(['3Ja', '5Nein'])
|
||||
return '{nick}: \x02\x03{choice}'.format(nick=mask.nick,
|
||||
choice=choice)
|
||||
choice = random.choice(['3Ja', '4Nein'])
|
||||
return '{nick}: \x02\x03{choice}\x0F'.format(nick=mask.nick,
|
||||
choice=choice)
|
||||
|
||||
@command
|
||||
def kiss(self, mask: IrcString, channel: IrcString, args: DocOptDict):
|
||||
@ -74,7 +74,7 @@ class Useless(Plugin):
|
||||
|
||||
%%kiss <nick>
|
||||
"""
|
||||
return '(づ。◕‿‿◕。)\x033。。・゜゜・。。・゜❤\x0F {nick} \x033❤'.format(
|
||||
return '(づ。◕‿‿◕。)\x034。。・゜゜・。。・゜❤\x0F {nick} \x034❤'.format(
|
||||
nick=args['<nick>'])
|
||||
|
||||
@command
|
||||
@ -83,25 +83,25 @@ class Useless(Plugin):
|
||||
|
||||
%%hug <nick>
|
||||
"""
|
||||
return '\x033♥♡❤♡♥\x0F {nick} \x033♥♡❤♡♥'.format(nick=args['<nick>'])
|
||||
return '\x034♥♡❤♡♥\x03 {nick} \x034♥♡❤♡♥'.format(nick=args['<nick>'])
|
||||
|
||||
@command
|
||||
def bier(self, mask: IrcString, channel: IrcString, args: DocOptDict):
|
||||
"""Gives nick a beer.
|
||||
|
||||
%%bier <nick>
|
||||
%%bier [<nick>]
|
||||
"""
|
||||
return '\x01ACTION schenkt ein kühles blondes an {nick} aus.\x01' \
|
||||
.format(nick=args['<nick>'])
|
||||
self.bot.action(channel, 'schenkt ein kühles blondes an {nick} aus.'
|
||||
.format(nick=args.get('<nick>') or mask.nick))
|
||||
|
||||
@command
|
||||
def fucken(self, mask: IrcString, channel: IrcString, args: DocOptDict):
|
||||
"""Kills and fucks a nick.
|
||||
|
||||
%%fucken <nick>
|
||||
%%fucken [<nick>]
|
||||
"""
|
||||
return '\x01ACTION fuckt {nick} und tötet {nick} anschließend.\x01' \
|
||||
.format(nick=args['<nick>'])
|
||||
self.bot.action(channel, 'fuckt {nick} und tötet {nick} anschließend.'
|
||||
.format(nick=args.get('<nick>') or mask.nick))
|
||||
|
||||
@command
|
||||
def anhero(self, mask: IrcString, channel: IrcString, args: DocOptDict):
|
||||
|
@ -41,9 +41,9 @@ class YouTube(Plugin):
|
||||
except ZeroDivisionError:
|
||||
score = 0
|
||||
|
||||
return '{title} - length {length} -\x033 {likes:,}\x0F /\x035 ' \
|
||||
'{dislikes:,}\x0F ({score:,.1f}%) - {views:,} views - ' \
|
||||
'{channel} on {date}' \
|
||||
return '{title} - length {length} -\x033 {likes:,}\x03 /' \
|
||||
'\x034 {dislikes:,}\x03 ({score:,.1f}%) - {views:,} ' \
|
||||
'views - {channel} on {date}' \
|
||||
.format(title=item['snippet']['title'],
|
||||
channel=item['snippet']['channelTitle'],
|
||||
length=' '.join([l.lower() for l in length]),
|
||||
|
Loading…
Reference in New Issue
Block a user