Bla, removed fmt() and bla bla
This commit is contained in:
		| @@ -7,7 +7,6 @@ from irc3.plugins.command import command | ||||
| from irc3.utils import IrcString | ||||
|  | ||||
| from . import Plugin | ||||
| from ..utils import fmt | ||||
|  | ||||
|  | ||||
| @irc3.plugin | ||||
| @@ -22,8 +21,8 @@ class Bitcoin(Plugin): | ||||
|         """ | ||||
|         data = requests.get('https://www.bitstamp.net/api/ticker').json() | ||||
|         values = {k: float(data[k]) for k in ['last', 'high', 'low', 'volume']} | ||||
|         return fmt('{bold}[BitStamp]{reset} ' | ||||
|                    'Current: {bold}{color}{orange}${last:,.2f}{reset} - ' | ||||
|                    'High: {bold}{color}{green}${high:,.2f}{reset} - ' | ||||
|                    'Low: {bold}{color}{maroon}${low:,.2f}{reset} - ' | ||||
|                    'Volume: {bold}฿{volume:,.2f}', **values) | ||||
|         return '\x02[BitStamp]\x0F ' \ | ||||
|                'Current: \x02\x037${last:,.2f}\x0F - ' \ | ||||
|                'High: \x02\x033${high:,.2f}\x0F - ' \ | ||||
|                'Low: \x02\x035${low:,.2f}\x0F - ' \ | ||||
|                'Volume: \x02฿{volume:,.2f}'.format(**values) | ||||
|   | ||||
| @@ -7,7 +7,6 @@ from irc3.plugins.command import command | ||||
| from irc3.utils import IrcString | ||||
|  | ||||
| from . import Plugin | ||||
| from ..utils import fmt | ||||
|  | ||||
|  | ||||
| @irc3.plugin | ||||
| @@ -27,10 +26,11 @@ class CTCP(Plugin): | ||||
|             reply = 'Error: {reply}'.format(reply=ctcp['reply']) | ||||
|         else: | ||||
|             reply = ctcp['reply'] | ||||
|         return fmt('{bold}[{ctcp}]{reset} {nick}: {reply}', | ||||
|                    ctcp=name, | ||||
|                    nick=nick, | ||||
|                    reply=reply) | ||||
|         return '\x02[{ctcp}]\x0F {nick}: {reply}'.format( | ||||
|             ctcp=name, | ||||
|             nick=nick, | ||||
|             reply=reply, | ||||
|         ) | ||||
|  | ||||
|     @command | ||||
|     async def ping(self, mask: IrcString, channel: IrcString, | ||||
| @@ -54,7 +54,7 @@ class CTCP(Plugin): | ||||
|             else: | ||||
|                 unit = 's' | ||||
|             reply = '{delta:.3f} {unit}'.format(unit=unit, delta=delta) | ||||
|         return fmt('{bold}[PING]{reset} {nick}: {text}', nick=nick, text=reply) | ||||
|         return '\x02[PING]\x0F {nick}: {text}'.format(nick=nick, text=reply) | ||||
|  | ||||
|     @command | ||||
|     async def finger(self, mask: IrcString, channel: IrcString, | ||||
|   | ||||
| @@ -5,7 +5,6 @@ from irc3.plugins.command import command | ||||
| from irc3.utils import IrcString | ||||
|  | ||||
| from . import Plugin | ||||
| from ..utils import fmt | ||||
|  | ||||
|  | ||||
| class Kernel(Plugin): | ||||
| @@ -22,6 +21,6 @@ class Kernel(Plugin): | ||||
|         for e in feed['entries']: | ||||
|             version, branch = e['title'].split(': ') | ||||
|             if '(EOL)' in e['description']: | ||||
|                 branch = '%s, {italic}EOL{reset}' % branch | ||||
|             releases.append('{bold}%s{reset} (%s)' % (version, branch)) | ||||
|         return fmt('[Kernel] {releases}'.format(releases=', '.join(releases))) | ||||
|                 branch = '%s, \x1DEOL\x0F' % branch | ||||
|             releases.append('\x02%s\x0F (%s)' % (version, branch)) | ||||
|         return '[Kernel] {releases}'.format(releases=', '.join(releases)) | ||||
|   | ||||
| @@ -31,7 +31,7 @@ class Seen(DatabasePlugin): | ||||
|             nick=seen['nick'], | ||||
|             # TODO: relate string delta | ||||
|             delta=datetime.now() - seen['last_seen'], | ||||
|             message=re.sub(r'\x01ACTION (.*)\x01', r'\1', seen['message']), | ||||
|             message=re.sub(r'\x01ACTION (.*)\x01', r'/me \1', seen['message']), | ||||
|         ) | ||||
|  | ||||
|     @irc3.event(r'(?i)^:(?P<mask>\S+) PRIVMSG (?P<channel>\S+) :(?P<msg>.*)') | ||||
|   | ||||
| @@ -8,7 +8,7 @@ from irc3.utils import IrcString | ||||
| import irc3 | ||||
|  | ||||
| from . import DatabasePlugin | ||||
| from ..utils import fmt, time_delta | ||||
| from ..utils import time_delta | ||||
|  | ||||
|  | ||||
| @irc3.plugin | ||||
| @@ -55,8 +55,11 @@ class Timer(DatabasePlugin): | ||||
|         seconds = delta.total_seconds() | ||||
|         if seconds > 0: | ||||
|             await asyncio.sleep(seconds) | ||||
|         text = fmt('{bold}[Timer]{reset} {nick}: {message} ({delay})', | ||||
|                    message=message, delay=delay, nick=mask.nick) | ||||
|         text = '\x02[Timer]\x0F {nick}: {message} ({delay})'.format( | ||||
|             message=message, | ||||
|             delay=delay, | ||||
|             nick=mask.nick, | ||||
|         ) | ||||
|         self.bot.privmsg(channel, text) | ||||
|         self.cur.execute('delete from timers where id = ?', [row_id]) | ||||
|         self.con.commit() | ||||
|   | ||||
| @@ -7,10 +7,8 @@ from irc3.plugins.command import command | ||||
| from irc3.utils import IrcString | ||||
|  | ||||
| from . import Plugin | ||||
| from ..utils import fmt | ||||
|  | ||||
| RAINBOW = ('maroon', 'red', 'orange', 'yellow', 'ltgreen', 'green', 'teal', | ||||
|            'ltblue', 'blue', 'purple', 'pink') | ||||
| RAINBOW = (5, 3, 7, 8, 9, 3, 10, 12, 2, 6, 13) | ||||
| RAINBOW_LEN = len(RAINBOW) | ||||
|  | ||||
| GNU_LINUX = """I'd Just Like To Interject For A Moment. What you're referring | ||||
| @@ -41,8 +39,8 @@ class Useless(Plugin): | ||||
|  | ||||
|     @irc3.event(r'(?i)^:\S+ PRIVMSG (?P<channel>\S+) :\[(?P<data>.*)\]$') | ||||
|     def intensifies(self, channel: str, data: str): | ||||
|         self.bot.privmsg(channel, fmt('{bold}[{data} INTENSIFIES]', | ||||
|                                       data=data.upper())) | ||||
|         self.bot.privmsg(channel, '\x02[{data} INTENSIFIES]'.format( | ||||
|             data=data.upper())) | ||||
|  | ||||
|     @command | ||||
|     def storyofpomfface(self, mask: IrcString, channel: IrcString, | ||||
| @@ -71,8 +69,9 @@ class Useless(Plugin): | ||||
|         %%jn <question> | ||||
|         %%jn | ||||
|         """ | ||||
|         choice = random.choice(['{green}Ja', '{maroon}Nein']) | ||||
|         return fmt('{nick}: {bold}{color}%s' % choice, nick=mask.nick) | ||||
|         choice = random.choice(['3Ja', '5Nein']) | ||||
|         return '{nick}: \x02\x03%s'.format(choice=choice, | ||||
|                                            nick=mask.nick) | ||||
|  | ||||
|     @command | ||||
|     def kiss(self, mask: IrcString, channel: IrcString, args: DocOptDict): | ||||
| @@ -80,8 +79,8 @@ class Useless(Plugin): | ||||
|  | ||||
|         %%kiss <nick> | ||||
|         """ | ||||
|         return fmt('(づ。◕‿‿◕。)づ{color}{red}。。・゜゜・。。・゜❤{reset} {nick} ' | ||||
|                    '{color}{red}❤', nick=args['<nick>']) | ||||
|         return '(づ。◕‿‿◕。)\x033。。・゜゜・。。・゜❤\x0F {nick} \x033❤'.format( | ||||
|             nick=args['<nick>']) | ||||
|  | ||||
|     @command | ||||
|     def hug(self, mask: IrcString, channel: IrcString, | ||||
| @@ -90,8 +89,7 @@ class Useless(Plugin): | ||||
|  | ||||
|         %%hug <nick> | ||||
|         """ | ||||
|         return fmt('{color}{red}♥♡❤♡♥{reset} {nick} {color}{red}♥♡❤♡♥', | ||||
|                    nick=args['<nick>']) | ||||
|         return '\x033♥♡❤♡♥\x0F {nick} \x033♥♡❤♡♥'.format(nick=args['<nick>']) | ||||
|  | ||||
|     @command | ||||
|     def hack(self, mask: IrcString, channel: IrcString, args: DocOptDict): | ||||
| @@ -100,7 +98,7 @@ class Useless(Plugin): | ||||
|         %%hack [<nick>] | ||||
|         """ | ||||
|         nick = args.get('<nick>') or '' | ||||
|         return 'hacking{}...'.format(' %s' % nick if nick else '') | ||||
|         return 'hacking{nick}...'.format(nick=' %s' % nick if nick else '') | ||||
|  | ||||
|     @command | ||||
|     def gay(self, mask: IrcString, channel: IrcString, args: DocOptDict): | ||||
| @@ -120,10 +118,10 @@ class Useless(Plugin): | ||||
|         word = [] | ||||
|         for i, char in enumerate(' '.join(args.get('<word>'))): | ||||
|             if char != ' ': | ||||
|                 char = '{color}{%s}%s' % (RAINBOW[last % RAINBOW_LEN], char) | ||||
|                 char = self._rainbow(last, char) | ||||
|                 last += 1 | ||||
|             word.append(char) | ||||
|         return fmt(''.join(word)) | ||||
|         return ''.join(word) | ||||
|  | ||||
|     @command | ||||
|     def wrainbow(self, mask: IrcString, channel: IrcString, args: DocOptDict): | ||||
| @@ -131,5 +129,10 @@ class Useless(Plugin): | ||||
|  | ||||
|         %%wrainbow <words>... | ||||
|         """ | ||||
|         return fmt(' '.join(['{color}{%s}%s' % (RAINBOW[i % RAINBOW_LEN], word) | ||||
|                              for i, word in enumerate(args['<words>'])])) | ||||
|         return ' '.join([self._rainbow(i, word) for i, word | ||||
|                          in enumerate(args['<words>'])]) | ||||
|  | ||||
|     @staticmethod | ||||
|     def _rainbow(i, char): | ||||
|         return '\x03{color}{char}'.format(color=RAINBOW[i % RAINBOW_LEN], | ||||
|                                           char=char) | ||||
|   | ||||
| @@ -10,7 +10,7 @@ from irc3.plugins.command import command | ||||
| from irc3.utils import IrcString | ||||
|  | ||||
| from . import Plugin | ||||
| from ..utils import fmt, date_from_iso | ||||
| from ..utils import date_from_iso | ||||
|  | ||||
|  | ||||
| # TODO: write better code lol | ||||
| @@ -46,22 +46,22 @@ class YouTube(Plugin): | ||||
|             except ZeroDivisionError: | ||||
|                 score = 0 | ||||
|  | ||||
|             stats = fmt(' -{color}{green} {likes:,}{reset} /{color}{maroon} ' | ||||
|                         '{dislikes:,}{reset} ({score:,.1f}%) ' | ||||
|                         '- {views:,} views', | ||||
|                         likes=likes, | ||||
|                         dislikes=dislikes, | ||||
|                         score=score, | ||||
|                         views=views) | ||||
|             stats = ' -\x033 {likes:,}\x0F /\x035 ' \ | ||||
|                     '{dislikes:,}\x0F ({score:,.1f}%) ' \ | ||||
|                     '- {views:,} views'.format(likes=likes, | ||||
|                                                dislikes=dislikes, | ||||
|                                                score=score, | ||||
|                                                views=views) | ||||
|         except KeyError: | ||||
|             stats = '' | ||||
|  | ||||
|         return fmt('{title}{length}{stats} - {channel} on {date}', | ||||
|                    title=item['snippet']['title'], | ||||
|                    channel=item['snippet']['channelTitle'], | ||||
|                    length=length, | ||||
|                    date=date.strftime('%Y.%m.%d'), | ||||
|                    stats=stats) | ||||
|         return '{title}{length}{stats} - {channel} on {date}'.format( | ||||
|             title=item['snippet']['title'], | ||||
|             channel=item['snippet']['channelTitle'], | ||||
|             length=length, | ||||
|             date=date.strftime('%Y.%m.%d'), | ||||
|             stats=stats, | ||||
|         ) | ||||
|  | ||||
|     @event(r'(?i)^:.* PRIVMSG (?P<target>.*) :.*(?:youtube.*?(?:v=|/v/)' | ||||
|            r'|youtu\.be/)(?P<video_id>[-_a-zA-Z0-9]+).*') | ||||
|   | ||||
| @@ -2,7 +2,6 @@ | ||||
| from pprint import pprint as pp | ||||
|  | ||||
| from .date import date_from_iso, time_delta, time_since | ||||
| from .formatting import fmt, FORMATTING | ||||
| from .misc import parse_int | ||||
|  | ||||
| __all__ = ( | ||||
| @@ -12,9 +11,6 @@ __all__ = ( | ||||
|     'date_from_iso', | ||||
|     'time_delta', | ||||
|     'time_since', | ||||
|     # formatting | ||||
|     'fmt', | ||||
|     'FORMATTING', | ||||
|     # misc | ||||
|     'parse_int' | ||||
| ) | ||||
|   | ||||
| @@ -28,11 +28,4 @@ FORMATTING = { | ||||
|     'swap': '\x16',       # swap bg and fg colors ("reverse video") | ||||
|     'reset': '\x0F',      # reset all formatting | ||||
| } | ||||
|  | ||||
| FORMATTING.update(COLORS) | ||||
| # @formatter:on | ||||
|  | ||||
|  | ||||
| def fmt(__text: str, **kwargs) -> str: | ||||
|     """Formats a str with `kwargs` and `FORMATTING`.""" | ||||
|     return __text.format(**kwargs, **FORMATTING) | ||||
|   | ||||
							
								
								
									
										17
									
								
								schema.sql
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								schema.sql
									
									
									
									
									
								
							| @@ -1,14 +1,14 @@ | ||||
| create table if not exists quotes ( | ||||
|     id integer primary key autoincrement, | ||||
|     nick text not null, | ||||
|     item text not null, | ||||
|     unique (nick, item collate nocase) | ||||
|     nick text not null collate nocase, | ||||
|     item text not null collate nocase, | ||||
|     unique (nick, item) | ||||
| ); | ||||
|  | ||||
| create table if not exists mcmaniacs ( | ||||
|     id integer primary key autoincrement, | ||||
|     item text not null, | ||||
|     unique (item collate nocase) on conflict replace | ||||
|     item text not null collate nocase, | ||||
|     unique (item) on conflict replace | ||||
| ); | ||||
|  | ||||
| create table if not exists timers ( | ||||
| @@ -30,12 +30,11 @@ create table if not exists tells ( | ||||
|     unique (to_user, message) | ||||
| ); | ||||
|  | ||||
|  | ||||
| create table if not exists seens ( | ||||
|     id integer primary key autoincrement, | ||||
|     nick text not null, | ||||
|     channel text not null, | ||||
|     nick text not null collate nocase, | ||||
|     channel text not null collate nocase, | ||||
|     message text not null, | ||||
|     last_seen timestamp not null, | ||||
|     unique (nick collate nocase) on conflict replace | ||||
|     unique (nick) on conflict replace | ||||
| ); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user