File: sarcasm.py

package info (click to toggle)
weechat-scripts 20250416-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,892 kB
  • sloc: python: 46,251; perl: 24,316; ruby: 2,382; tcl: 400; lisp: 338; javascript: 138; makefile: 14; sh: 9
file content (47 lines) | stat: -rw-r--r-- 1,251 bytes parent folder | download
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", ""
        )