This commit is contained in:
gallant 2022-05-19 18:40:31 -05:00
commit fb87798869
3 changed files with 155 additions and 0 deletions

75
autoascii.py Normal file
View file

@ -0,0 +1,75 @@
#-*- coding: utf-8 -*-
# Copyright (c) 2013 Anton Vilhelm Ásgeirsson <anton@antonvilhelm.is>
#
# Everyone is permitted to copy and distribute verbatim or modified
# copies of this license document, and changing it is allowed as long
# as the name is changed.
#
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
#
# 0. You just DO WHAT THE FUCK YOU WANT TO.
# Greentext:
# ----------
# Modifies any messages starting with '>' to display green text, similar to
# the way popular imageboards do.
import weechat as w
import re
import requests
import os
# Registstration variables.
SCRIPT_NAME = "autottm"
SCRIPT_AUTHOR = "God"
SCRIPT_VERSION = "0.1"
SCRIPT_LICENSE = "WTFPL"
SCRIPT_DESC = "Modify messages starting with 'https://cdn.discordapp.com' to display better link."
# Registration function.
w.register(
SCRIPT_NAME,
SCRIPT_AUTHOR,
SCRIPT_VERSION,
SCRIPT_LICENSE,
SCRIPT_DESC,
"",""
)
# Greentext callback function.
def greentext_cb(data, modifier, modifier_data, string):
try:
nick, msg = string.split('\t')
except ValueError as e: #Get rid of those python error messages.
return string
try:
discordindex = msg.index('https://')
except:
return string
wackindex = len(msg) -1
if msg.find('.png') > -1:
wackindex = msg.index('.png')
elif msg.find('.jpg') > -1:
wackindex = msg.index('.jpg')
else:
return string
msg = msg[discordindex:wackindex+4]
#print(discordindex)
#print(msg[discordindex:])
data = {
'url': msg
}
r = requests.post(url = 'https://ttm.sh', data = data)
print(r.text)
r = os.system("kitty +kitten icat " + r.text)
return "%s\t%s%s" % (nick, w.color('green'), r)
#return r.text
#w.hook_modifier("weechat_print", "greentext_cb", "")
w.hook_modifier("irc_in2_privmsg", "greentext_cb", "")

71
autottm.py Normal file
View file

@ -0,0 +1,71 @@
#-*- coding: utf-8 -*-
# Copyright (c) 2013 Anton Vilhelm Ásgeirsson <anton@antonvilhelm.is>
#
# Everyone is permitted to copy and distribute verbatim or modified
# copies of this license document, and changing it is allowed as long
# as the name is changed.
#
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
#
# 0. You just DO WHAT THE FUCK YOU WANT TO.
# Greentext:
# ----------
# Modifies any messages starting with '>' to display green text, similar to
# the way popular imageboards do.
import weechat as w
import re
import requests
# Registstration variables.
SCRIPT_NAME = "autottm"
SCRIPT_AUTHOR = "God"
SCRIPT_VERSION = "0.1"
SCRIPT_LICENSE = "WTFPL"
SCRIPT_DESC = "Modify messages starting with 'https://cdn.discordapp.com' to display better link."
# Registration function.
w.register(
SCRIPT_NAME,
SCRIPT_AUTHOR,
SCRIPT_VERSION,
SCRIPT_LICENSE,
SCRIPT_DESC,
"",""
)
# Greentext callback function.
def greentext_cb(data, modifier, modifier_data, string):
try:
nick, msg = string.split('\t')
except ValueError as e: #Get rid of those python error messages.
return string
try:
discordindex = msg.index('https://')
except:
return string
wackindex = len(msg) -1
if msg.find('.png') > -1:
wackindex = msg.index('.png')
elif msg.find('.jpg') > -1:
wackindex = msg.index('.jpg')
else:
return string
msg = msg[discordindex:wackindex+4]
#print(discordindex)
#print(msg[discordindex:])
data = {
'url': msg
}
r = requests.post(url = 'https://ttm.sh', data = data)
print(r.text)
return "%s\t%s%s" % (nick, w.color('green'), r.text)
#return r.text
w.hook_modifier("weechat_print", "greentext_cb", "")

9
cdntottm.py Normal file
View file

@ -0,0 +1,9 @@
import requests
data = {
'url':"https://upload.wikimedia.org/wikipedia/en/thumb/5/50/Goofy_Duckipedia.png/220px-Goofy_Duckipedia.png"
}
r = requests.post(url = 'https://ttm.sh', data = data)
print(r.text)