Beispiel #1
0
WORDLIST_URL = 'https://raw.githubusercontent.com/jesstess/Scrabble/5d4a1e69ad2267126fa8d82bbc34ca936d1f878a/scrabble/sowpods.txt'
WORDS = set()
GAME_MANAGER = None

HELP_STR = '''Play some countdown!
You will have a limited amount of time to create the longest word you can from 
the available letters. When the time is up, any players who made a word that is 
the longest will be crowned a winner.
If you try to submit a word that isn't in the dictionary, or that was already 
given by a different player, it won't count.
You can do '/countdown' to start a game with the default setup (5 consonants, 4 
vowels), or do '/countdown ccvvcv' to get a custom choice of letters (where 'c' 
is a consonant and 'v' is a vowel).'''

plugin = create_plugin(name='countdown', author='iandioch', help=HELP_STR)


class CountdownGame:
    def __init__(self, letters, word_checker):
        # `letters` must be a string of available letters.
        # `word_checker` must be a function which takes one string argument, and
        # returns True or False if it is a real word.
        self.letters = letters
        self.letter_counts = Counter(self.letters)
        # Maps author_id to their best word
        self.best_word = defaultdict(str)
        self.all_words = set()

        self.check_word = word_checker
Beispiel #2
0
import csv
import codecs

import requests

from plugin import create_plugin
from message import SteelyMessage

HELP_STR = """Get live Coronavirus numbers in various regions.
Run /corona to get some info.
"""

plugin = create_plugin(name='corona', author='iandioch', help=HELP_STR)


def get_canton_data(canton='ZH'):
    # This CSV is messy. There are very many missing fields, because each canton
    # reports different data, and each new row is populated in increments (eg.
    # they might know how many are in quarantine that day in the morning, but
    # might not take hospital counts until the evening, etc.).
    csv_url = f'https://github.com/openZH/covid_19/raw/master/fallzahlen_kanton_total_csv_v2/COVID19_Fallzahlen_Kanton_{canton}_total.csv'
    csv_lines = requests.get(csv_url).iter_lines()
    reader = csv.reader(codecs.iterdecode(csv_lines, 'utf-8'), delimiter=',')
    # Columns of CSV:
    # [0: date, 1: time, 2: abbreviation_canton_and_fl, 3: ncumul_tested,
    # 4: ncumul_conf, 5: new_hosp, 6: current_hosp, 7: current_icu,
    # 8: current_vent, 9: ncumul_released, 10: ncumul_deceased, 11: source,
    # 12: current_isolated, 13: current_quarantined,
    # 14: current_quarantined_riskareatravel, 15: current_quarantined_total]

    # Rows N-2, N-1
Beispiel #3
0
from plugin import create_plugin
from message import SteelyMessage

plugin = create_plugin(
    name='b',
    author='byxor',
    help=
    'will transform the previous message into something a bit more exciting.')

REPLACEABLE = 'PpBbGg'
REPLACEMENT = '🅱️'


def encode(string):
    for sequence in REPLACEABLE:
        string = string.replace(sequence, REPLACEMENT)
    return string


@plugin.listen(command='b')
def b_listener(bot, message: SteelyMessage, **kwargs):
    text = bot.fetchThreadMessages(thread_id=message.thread_id,
                                   limit=2)[1].text
    bot.sendMessage(encode(text),
                    thread_id=message.thread_id,
                    thread_type=message.thread_type)
Beispiel #4
0
import random

from plugin import create_plugin
from message import SteelyMessage

plugin = create_plugin(name='mock',
                       author='EdwardDowling',
                       help='mocks the previous command')


def mock(string):
    return ''.join(map(trans_char, string))


def trans_char(char):
    if char == "(":
        return ")"
    if char == ")":
        return "("
    return (char.upper(), char.lower())[random.randint(0, 1)]


@plugin.listen(command='mock')
def mock_listener(bot, trigger: SteelyMessage, **kwargs):
    message = bot.fetchThreadMessages(thread_id=trigger.thread_id, limit=2)[1]
    bot.sendMessage(mock(message.text),
                    thread_id=trigger.thread_id,
                    thread_type=trigger.thread_type)
Beispiel #5
0
import random

from plugin import create_plugin
from message import SteelyMessage

plugin = create_plugin(
    name='stretch',
    author='CianLR',
    help='gives the previous message sttrreeetttccchhhheeeeddddd')

STRETCH_FACTOR = 5


@plugin.listen(command='stretch')
def stretch(bot, trigger: SteelyMessage, **kwargs):
    message = bot.fetchThreadMessages(thread_id=trigger.thread_id, limit=2)[1]
    if not message or not message.text:
        return
    if len(message.text) > 300:
        bot.sendMessage('Too long you spammy f**k',
                        thread_id=trigger.thread_id,
                        thread_type=trigger.thread_type)
        return
    out = ''
    count = 1
    for c in message.text:
        if random.random() < (STRETCH_FACTOR / len(message.text)):
            count += 1
        out += c * count
    bot.sendMessage(out,
                    thread_id=trigger.thread_id,
Beispiel #6
0
import random

from plugin import create_plugin
from message import SteelyMessage

HELP_STR = """
Requests steely to print a random digit to the chat.

Usage:
    /randomdigit - Requests a random digit
    /randomdigit help - This help text
"""

plugin = create_plugin(name='randomdigit', author='CianLR', help=HELP_STR)

SIDE = ['left', 'right']
DIGIT = [
    'big toe',
    'long toe',
    'middle toe',
    'ring toe',
    'little toe',
    'thumb',
    'index finger',
    'middle finger',
    'ring finger',
    'pinky',
]


@plugin.setup()
Beispiel #7
0
import re

from plugin import create_plugin
from message import SteelyMessage


plugin = create_plugin(name='search',
                       author='EdwardDowling',
                       help='searches the previous message')


@plugin.listen(command='search')
def mock_listener(bot, trigger: SteelyMessage, **kwargs):
    def send_message(message):
        bot.sendMessage(message, thread_id=trigger.thread_id,
                        thread_type=trigger.thread_type)
    prev_message = bot.fetchThreadMessages(
        thread_id=trigger.thread_id, limit=2)[1]
    match = re.findall(trigger.text, prev_message.text)[:10]
    if match:
        send_message('\n'.join(match))
    else:
        send_message('no match idiot')
Beispiel #8
0
import random

from plugin import create_plugin
from message import SteelyMessage

plugin = create_plugin(name='scramble',
                       author='izaakf',
                       help='"hey add me on kik" -> "kik me add hey on"')


def scramble(message):
    split_message = message.split()
    if len(split_message) == 0:
        return ""
    elif len(split_message) > 250:
        return "You can't zucc me"
    random.shuffle(split_message)
    return " ".join(split_message)


@plugin.listen(command='scramble')
def listen(bot, trigger: SteelyMessage, **kwargs):
    message = bot.fetchThreadMessages(thread_id=trigger.thread_id, limit=2)[1]
    bot.sendMessage(scramble(message.text),
                    thread_id=trigger.thread_id,
                    thread_type=trigger.thread_type)
Beispiel #9
0
from plugin import create_plugin
from message import SteelyMessage

plugin = create_plugin(name='sort',
                       author='iandioch',
                       help='message -> aeegmss')


@plugin.listen(command='sort')
def mock_listener(bot, trigger: SteelyMessage, **kwargs):
    message = bot.fetchThreadMessages(thread_id=trigger.thread_id, limit=2)[1]
    bot.sendMessage(''.join(sorted(message.text)),
                    thread_id=trigger.thread_id,
                    thread_type=trigger.thread_type)
Beispiel #10
0
import random

from plugin import create_plugin
from message import SteelyMessage

plugin = create_plugin(name='shout',
                       author='iandioch',
                       help='THE BEST PLUGIN!!!1!')


def shout(message):
    parts = message.split('.')
    out = ''
    for part in parts:
        out += part.upper() + \
            ''.join(random.choices(['!', '1'], weights=[
                    5, 1], k=random.randint(2, 8)))
    return out


@plugin.listen(command='shout')
def mock_listener(bot, trigger: SteelyMessage, **kwargs):
    message = bot.fetchThreadMessages(thread_id=trigger.thread_id, limit=2)[1]
    bot.sendMessage(shout(message.text),
                    thread_id=trigger.thread_id,
                    thread_type=trigger.thread_type)
Beispiel #11
0
from message import SteelyMessage
from formatting import code_block

__author__ = 'sentriz'
COMMAND = None
CMD_DB = new_database('stats')
CMD = Query()
TILDA_DB = new_database('quote')
TILDA = Query()
COMMAND_IDENTIFIERS = set(['.', '~', '/'])

LOGGER = logging.getLogger("plugins.stats")
LOGGER.setLevel(logging.INFO)

HELP_STR = '''TODO'''
PLUGIN = create_plugin(name="stats", author="sentriz", help=HELP_STR)

DEFAULT_LIST_SIZE = 10


def first_word_of(message):
    if ' ' in message:
        message = message.split()[0]
    return message


def is_tilda_command(command):
    return bool(TILDA_DB.search(TILDA.cmd == command))


def looks_like_command(command):
Beispiel #12
0
import random

from plugin import create_plugin
from message import SteelyMessage

plugin = create_plugin(name='vowel', author='izaakf', help='no')


def shuffle(string):
    return ''.join(random.sample(string, len(string)))


def vowel_switch(string):
    vowels = "aeiou"
    normal = vowels + vowels.upper()
    shuffled = shuffle(vowels) + shuffle(vowels.upper())
    shuffle_trans = str.maketrans(normal, shuffled)
    return string.translate(shuffle_trans)


@plugin.listen(command='muck')
def mock_listener(bot, trigger: SteelyMessage, **kwargs):
    message = bot.fetchThreadMessages(thread_id=trigger.thread_id, limit=2)[1]
    bot.sendMessage(vowel_switch(message.text),
                    thread_id=trigger.thread_id,
                    thread_type=trigger.thread_type)
Beispiel #13
0
from plugins.intern import simulation

HELP_STR = """Your own personal Steely intern.

This intern can work away on various projects, and might even try to earn you some Lindens.

You can hire an intern with `/intern hire`.
You can check up on them with `/intern check`.

Each intern has various attributes that affect their performance at their tasks:
Intelligence makes them more likely to succeed at investing.
Focus influences the tasks they attempt, and generally makes them more useful.
Efficiency influences the speed at which they can move through tasks.

Make sure to treat your young intern well!"""
plugin = create_plugin(name='intern', author='iandioch', help=HELP_STR)


@plugin.setup()
def setup():
    setup_database()


@plugin.listen(command='intern hire [intern_id]')
def hire(bot, message, **kwargs):
    if 'intern_id' in kwargs and kwargs['intern_id'] != '':
        intern_id = kwargs['intern_id']
        intern_ = get_intern(intern_id)
        hirer = bot.fetchUserInfo(message.author_id)[0]
        bot.sendMessage('{} is hiring intern {}.'.format(
            hirer['full_name'], intern_.name),
Beispiel #14
0
Request your favourite bible quotes, right to the chat.

Usage:
    /bible - Random quote
    /bible Genesis 1:3 - Specific verse
    /bible help - This help text

    Verses are specified in the format {book} {chapter}:{verse}

TODO: Book acronyms, e.g. Gen -> Genesis
TODO: Verse ranges, e.g. Genesis 1:1-3
"""
BIBLE_FILE = "plugins/bible/en_kjv.json"
BIBLE_URL = 'https://raw.githubusercontent.com/thiagobodruk/bible/master/json/en_kjv.json'

plugin = create_plugin(name='bible', author='CianLR', help=HELP_STR)
bible = None
book_to_index = {}


def make_book_to_index(bible):
    btoi = {}
    for i, book in enumerate(bible):
        btoi[book['name'].lower()] = i
    return btoi


@plugin.setup()
def plugin_setup():
    global bible, book_to_index
    try: