Script: sarcasm.py

Adds random capitalization to your sentence.
Author: Fsaev — Version: 1.0 — License: GPL-3.0-or-later
For WeeChat ≥ 0.3.0.
Tags: input, py3
Added: 2023-04-02

Download GitHub Repository

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Script Name: sarcasm.py
# Script Author: Fsaev
# Script License: GPLv3

SCRIPT_NAME = 'sarcasm'
SCRIPT_AUTHOR = 'Fsaev <fredrik@saevland.com>'
SCRIPT_VERSION = '1.0'
SCRIPT_LICENSE = 'GPLv3'
SCRIPT_DESC = 'Adds random capitalization to your sentence'

import_ok = True

try:
    import weechat
except ImportError:
    print('This script must be run under WeeChat')
    print('You can obtain a copy of WeeChat, for free, at https://weechat.org')
    import_ok = False

from random import randint

def sarcasm_cb(data, buffer, args):
    newstring = ""
    for arg in args:
        if randint(0, 1) == 1:
            newstring += arg.upper()
        else:
            newstring += arg.lower()

    weechat.command(buffer, newstring)

    return weechat.WEECHAT_RC_OK

if __name__ == "__main__" and import_ok:
    if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""):
        weechat.hook_command(
            "sarcasm",
            """Adds random capitalization to your sentence to indicate that you are being sarcastic, e.g.
/sarcasm I love to put ketchup on my pizza

results in:
i lOVe tO Put KEtChUp oN mY pIzZa
""",
            "message", "",
            "",
            "sarcasm_cb", ""
        )