--- /dev/null
+import os
+import sqlite3
+import time
+from aptbot.bot import Message, Commands, Bot
+
+COOLDOWN = 60
+END_TIME = 0
+
+PATH = os.path.dirname(os.path.realpath(__file__))
+PATH = os.path.join(PATH, "..")
+
+
+def main(bot: Bot, message: Message):
+ conn = sqlite3.connect(os.path.join(PATH, "lol_data.db"))
+ c = conn.cursor()
+
+ tables = ["lol_queue", "ow"]
+
+ for table in tables:
+ c.execute(
+ f"""
+ UPDATE
+ {table}
+ SET
+ last_available = ?,
+ time_remaining = time_remaining - (? - last_available)
+ WHERE
+ available = 0;
+ """,
+ (
+ int(time.time()),
+ int(time.time()),
+ ),
+ )
+ c.execute(f"DELETE FROM {table} WHERE time_remaining < 0;")
+ if c.rowcount:
+ bot.send_privmsg(message.channel, f"/announce {c.rowcount} user{'s were' if c.rowcount > 1 else ' was'} just removed from {table if table != 'lol_queue' else 'lol'} queue.")
+
+ conn.commit()
+
+ conn.close()
--- /dev/null
+from aptbot.bot import Message, Commands, Bot
+import os
+import tools.smart_privmsg
+import openai
+from openai.error import RateLimitError
+
+PERMISSION = 99
+PREFIX = "?"
+DESCRIPTION = ""
+USER_COOLDOWN = 40
+GLOBAL_COOLDOWN = 20
+
+openai.api_key = os.getenv("OPENAI_API")
+
+def main(bot: Bot, message: Message):
+ replied_message = message.tags.get("reply-parent-msg-body", None)
+ if replied_message:
+ msg = replied_message
+ replied_msg_id = message.tags["reply-parent-msg-id"]
+ else:
+ msg = " ".join(message.value.split(" ")[1:])
+ replied_msg_id = message.tags['id']
+
+
+ try:
+ response = openai.Completion.create(
+ # model="davinci:ft-personal:9ball-2022-12-05-08-37-36",
+ model="davinci:ft-personal-2022-12-06-10-03-18",
+ prompt=f"9ball is an 8ball. 9ball answers your questions reluctantly with sarcastic and unhelpful responses.\n{message.nick}: {msg}\n\n###\n\n",
+ temperature=1,
+ max_tokens=60,
+ top_p=0.3,
+ frequency_penalty=0.5,
+ presence_penalty=0.0,
+ stop=[" END"],
+ )
+ except RateLimitError:
+ tools.smart_privmsg.send_safe(bot, message.channel, "UwU Sowwy. The sevwews awe ovewloaded :( Twy again in a few minutes OwO", reply=replied_msg_id)
+
+ print(response)
+ if response:
+ msg = response["choices"][0]["text"]
+ # msg = msg[:msg.find("#")]
+ else:
+ msg = "Sadge nothing was returned"
+
+ tools.smart_privmsg.send_safe(bot, message.channel, msg, reply=replied_msg_id)
+ # bot.send_privmsg(message.channel, msg, reply=replied_msg_id)
import sqlite3
import tools.smart_privmsg
import random
+import shlex
logger = logging.getLogger(__name__)
PATH = os.path.dirname(os.path.realpath(__file__))
PATH = os.path.join(PATH, "..")
-
-def main(bot: Bot, message: Message):
+def check_queue(bot: Bot, message: Message, table: str):
if random.random() < 0.02:
q = [
"https://imgur.com/d5qGioI",
c = conn.cursor()
c.execute(
- """
- SELECT twitch_id, priority_queue FROM lol_queue WHERE available = 1 ORDER BY position ASC;
+ f"""
+ SELECT twitch_id, priority_queue FROM {table} WHERE available = 1 ORDER BY position ASC;
"""
)
fetched = c.fetchall()
reply=message.tags["id"],
)
c.execute(
- """
- SELECT data FROM lol_queue_data WHERE name = 'queuesize';
+ f"""
+ SELECT data FROM {table}_data WHERE name = 'queuesize';
"""
)
try:
)
c.execute(
- """
- SELECT twitch_id FROM lol_queue WHERE available = 0 ORDER BY position ASC;
+ f"""
+ SELECT twitch_id FROM {table} WHERE available = 0 ORDER BY position ASC;
"""
)
fetched_unavailable = c.fetchall()
)
conn.close()
+
+
+def parse(query):
+ query = query.split()
+ try:
+ if query[0].lower() in {"ow", "overwatch", "ow2", "overwatch2"}:
+ return {"--game": "ow"}
+ except:
+ pass
+ return {"--game": "lol_queue"}
+ d = dict()
+ for i in shlex.split(query):
+ try:
+ d[i.split('=')[0]] = i.split('=')[1]
+ except:
+ pass
+ return d
+
+
+def scrub(table_name):
+ return ''.join(chr for chr in table_name if chr.isalnum() or chr == '_')
+
+
+def main(bot: Bot, message: Message):
+ args = " ".join(message.value.split(" ")[1:])
+ args = parse(args)
+ check_queue(bot, message, scrub(args.get("--game", "lol_queue")))
import ttv_api.users
import sqlite3
import time
+import shlex
logger = logging.getLogger(__name__)
PATH = os.path.join(PATH, "..")
-def main(bot: Bot, message: Message):
+def clean_queue(bot: Bot, message: Message, table: str):
twitch = ttv_api.users.get_users(user_logins=[message.channel])
if not twitch:
bot.send_privmsg(
conn = sqlite3.connect(os.path.join(PATH, "lol_data.db"))
c = conn.cursor()
- c.execute("DELETE FROM lol_queue")
+ c.execute(f"DELETE FROM {table}")
conn.commit()
c.execute(
- """
- INSERT INTO lol_queue (
+ f"""
+ INSERT INTO {table} (
"twitch_id",
"position",
"available",
)
conn.close()
+
+
+def parse(query):
+ query = query.split()
+ try:
+ if query[0].lower() in {"ow", "overwatch", "ow2", "overwatch2"}:
+ return {"--game": "ow"}
+ except:
+ pass
+ return {"--game": "lol_queue"}
+ d = dict()
+ for i in shlex.split(query):
+ try:
+ d[i.split('=')[0]] = i.split('=')[1]
+ except:
+ pass
+ return d
+
+
+def scrub(table_name):
+ return ''.join(chr for chr in table_name if chr.isalnum() or chr == '_')
+
+
+def main(bot: Bot, message: Message):
+ args = " ".join(message.value.split(" ")[1:])
+ args = parse(args)
+ clean_queue(bot, message, scrub(args.get("--game", "lol_queue")))
from aptbot.bot import Message, Commands, Bot
import os
+import shlex
import logging
import ttv_api.users
import sqlite3
PATH = os.path.join(PATH, "..")
-def main(bot: Bot, message: Message):
+def force_here(bot: Bot, message: Message, table: str):
twitch_name = message.tags.get("reply-parent-user-login", None)
if not twitch_name:
twitch_name = message.value.split(" ")[1]
c = conn.cursor()
c.execute(
- """
+ f"""
UPDATE
- lol_queue
+ {table}
SET
position = (
CASE
SELECT
position
FROM
- lol_queue
+ {table}
WHERE
twitch_id = ?
) < (
SELECT
position
FROM
- lol_queue
+ {table}
WHERE
available = 1
ORDER BY
SELECT
data
FROM
- lol_queue_data
+ {table}_data
WHERE
name = 'queuesize'
)
SELECT
max(position)
FROM
- lol_queue
+ {table}
WHERE
priority_queue = 1
OR position <= (
SELECT
position
FROM
- lol_queue
+ {table}
WHERE
available = 1
ORDER BY
SELECT
data
FROM
- lol_queue_data
+ {table}_data
WHERE
name = 'queuesize'
)
)
c.execute(
- """
+ f"""
UPDATE
- lol_queue
+ {table}
SET
available = 1,
priority_queue = (
SELECT
position
FROM
- lol_queue
+ {table}
WHERE
twitch_id = ?
) < (
SELECT
position
FROM
- lol_queue
+ {table}
WHERE
available = 1
ORDER BY
SELECT
data
FROM
- lol_queue_data
+ {table}_data
WHERE
name = 'queuesize'
)
SELECT
position
FROM
- lol_queue
+ {table}
WHERE
twitch_id = ?
) < (
SELECT
position
FROM
- lol_queue
+ {table}
WHERE
available = 1
ORDER BY
SELECT
data
FROM
- lol_queue_data
+ {table}_data
WHERE
name = 'queuesize'
)
SELECT
max(position)
FROM
- lol_queue
+ {table}
WHERE
priority_queue = 1
OR position <= (
SELECT
position
FROM
- lol_queue
+ {table}
WHERE
available = 1
ORDER BY
SELECT
data
FROM
- lol_queue_data
+ {table}_data
WHERE
name = 'queuesize'
)
conn.close()
return
conn.commit()
- c.execute("DELETE FROM lol_queue WHERE time_remaining < 0;")
+ c.execute(f"DELETE FROM {table} WHERE time_remaining < 0;")
if c.rowcount > 0:
bot.send_privmsg(
message.channel,
reply=message.tags["id"],
)
conn.close()
+
+
+def parse(query):
+ query = query.split()
+ try:
+ if query[1].lower() in {"ow", "overwatch", "ow2", "overwatch2"}:
+ return {"--game": "ow"}
+ except:
+ pass
+ return {"--game": "lol_queue"}
+ d = dict()
+ for i in shlex.split(query):
+ try:
+ d[i.split('=')[0]] = i.split('=')[1]
+ except:
+ pass
+ return d
+
+
+def scrub(table_name):
+ return ''.join(chr for chr in table_name if chr.isalnum() or chr == '_')
+
+
+def main(bot: Bot, message: Message):
+ args = " ".join(message.value.split(" ")[1:])
+ args = parse(args)
+ force_here(bot, message, scrub(args.get("--game", "lol_queue")))
from aptbot.bot import Message, Commands, Bot
+import shlex
import os
import logging
import ttv_api.users
DEFAULT_TIME_REMAINING = 60 * 60
-def main(bot: Bot, message: Message):
+def force_join(bot: Bot, message: Message, table: str):
twitch_name = message.tags.get("reply-parent-user-login", None)
if not twitch_name:
twitch_name = message.value.split(" ")[1]
c = conn.cursor()
c.execute(
- """
- SELECT position FROM lol_queue ORDER BY position DESC;
+ f"""
+ SELECT position FROM {table} ORDER BY position DESC;
"""
)
try:
c.execute(
- """
- INSERT INTO lol_queue (
+ f"""
+ INSERT INTO {table} (
"twitch_id",
"position",
"available",
reply=message.tags["id"],
)
conn.close()
+
+
+def parse(query):
+ query = query.split()
+ try:
+ if query[1].lower() in {"ow", "overwatch", "ow2", "overwatch2"}:
+ return {"--game": "ow"}
+ except:
+ pass
+ return {"--game": "lol_queue"}
+ d = dict()
+ for i in shlex.split(query):
+ try:
+ d[i.split('=')[0]] = i.split('=')[1]
+ except:
+ pass
+ return d
+
+
+def scrub(table_name):
+ return ''.join(chr for chr in table_name if chr.isalnum() or chr == '_')
+
+
+def main(bot: Bot, message: Message):
+ args = " ".join(message.value.split(" ")[1:])
+ args = parse(args)
+ force_join(bot, message, scrub(args.get("--game", "lol_queue")))
import logging
import ttv_api.users
import sqlite3
+import shlex
logger = logging.getLogger(__name__)
PATH = os.path.join(PATH, "..")
-def main(bot: Bot, message: Message):
+def force_leave(bot: Bot, message: Message, table: str):
twitch_name = message.tags.get("reply-parent-user-login", None)
if not twitch_name:
twitch_name = message.value.split(" ")[1]
c = conn.cursor()
c.execute(
- """
- DELETE FROM lol_queue WHERE twitch_id = ?;
+ f"""
+ DELETE FROM {table} WHERE twitch_id = ?;
""",
(twitch_id,),
)
reply=message.tags["id"],
)
conn.close()
+
+
+def parse(query):
+ query = query.split()
+ try:
+ if query[1].lower() in {"ow", "overwatch", "ow2", "overwatch2"}:
+ return {"--game": "ow"}
+ except:
+ pass
+ return {"--game": "lol_queue"}
+ d = dict()
+ for i in shlex.split(query):
+ try:
+ d[i.split('=')[0]] = i.split('=')[1]
+ except:
+ pass
+ return d
+
+
+def scrub(table_name):
+ return ''.join(chr for chr in table_name if chr.isalnum() or chr == '_')
+
+
+def main(bot: Bot, message: Message):
+ args = " ".join(message.value.split(" ")[1:])
+ args = parse(args)
+ force_leave(bot, message, scrub(args.get("--game", "lol_queue")))
import ttv_api.users
import sqlite3
import time
+import shlex
logger = logging.getLogger(__name__)
PATH = os.path.join(PATH, "..")
-def main(bot: Bot, message: Message):
+def force_not_here(bot: Bot, message: Message, table: str):
twitch_name = message.tags.get("reply-parent-user-login", None)
if not twitch_name:
twitch_name = message.value.split(" ")[1]
c = conn.cursor()
c.execute(
- """
- UPDATE lol_queue SET available = 0, priority_queue = null, last_available = ? WHERE twitch_id = ?;
+ f"""
+ UPDATE {table} SET available = 0, priority_queue = null, last_available = ? WHERE twitch_id = ?;
""",
(
int(time.time()),
reply=message.tags["id"],
)
conn.close()
+
+
+def parse(query):
+ query = query.split()
+ try:
+ if query[1].lower() in {"ow", "overwatch", "ow2", "overwatch2"}:
+ return {"--game": "ow"}
+ except:
+ pass
+ return {"--game": "lol_queue"}
+ d = dict()
+ for i in shlex.split(query):
+ try:
+ d[i.split('=')[0]] = i.split('=')[1]
+ except:
+ pass
+ return d
+
+
+def scrub(table_name):
+ return ''.join(chr for chr in table_name if chr.isalnum() or chr == '_')
+
+
+def main(bot: Bot, message: Message):
+ args = " ".join(message.value.split(" ")[1:])
+ args = parse(args)
+ force_not_here(bot, message, scrub(args.get("--game", "lol_queue")))
import ttv_api.users
import sqlite3
import time
+import shlex
logger = logging.getLogger(__name__)
PERMISSION = 99
PREFIX = "?"
DESCRIPTION = r"Makes yourself available in the list."
-USER_COOLDOWN = 600
+USER_COOLDOWN = 10
GLOBAL_COOLDOWN = 0
PATH = os.path.dirname(os.path.realpath(__file__))
PATH = os.path.join(PATH, "..")
-def main(bot: Bot, message: Message):
+def here(bot: Bot, message: Message, table: str):
twitch = ttv_api.users.get_users(user_logins=[message.nick])
if not twitch:
bot.send_privmsg(
c = conn.cursor()
c.execute(
- """
+ f"""
UPDATE
- lol_queue
+ {table}
SET
position = (
CASE
SELECT
position
FROM
- lol_queue
+ {table}
WHERE
twitch_id = ?
) < (
SELECT
position
FROM
- lol_queue
+ {table}
WHERE
available = 1
ORDER BY
SELECT
data
FROM
- lol_queue_data
+ {table}_data
WHERE
name = 'queuesize'
)
SELECT
max(position)
FROM
- lol_queue
+ {table}
WHERE
priority_queue = 1
OR position <= (
SELECT
position
FROM
- lol_queue
+ {table}
WHERE
available = 1
ORDER BY
SELECT
data
FROM
- lol_queue_data
+ {table}_data
WHERE
name = 'queuesize'
)
)
c.execute(
- """
+ f"""
UPDATE
- lol_queue
+ {table}
SET
available = 1,
priority_queue = (
SELECT
position
FROM
- lol_queue
+ {table}
WHERE
twitch_id = ?
) < (
SELECT
position
FROM
- lol_queue
+ {table}
WHERE
available = 1
ORDER BY
SELECT
data
FROM
- lol_queue_data
+ {table}_data
WHERE
name = 'queuesize'
)
SELECT
position
FROM
- lol_queue
+ {table}
WHERE
twitch_id = ?
) < (
SELECT
position
FROM
- lol_queue
+ {table}
WHERE
available = 1
ORDER BY
SELECT
data
FROM
- lol_queue_data
+ {table}_data
WHERE
name = 'queuesize'
)
SELECT
max(position)
FROM
- lol_queue
+ {table}
WHERE
priority_queue = 1
OR position <= (
SELECT
position
FROM
- lol_queue
+ {table}
WHERE
available = 1
ORDER BY
SELECT
data
FROM
- lol_queue_data
+ {table}_data
WHERE
name = 'queuesize'
)
conn.close()
return
conn.commit()
- c.execute("DELETE FROM lol_queue WHERE time_remaining < 0;")
+ c.execute(f"DELETE FROM {table} WHERE time_remaining < 0;")
if c.rowcount > 0:
bot.send_privmsg(
message.channel,
reply=message.tags["id"],
)
conn.close()
+
+
+def parse(query):
+ query = query.split()
+ try:
+ if query[1].lower() in {"ow", "overwatch", "ow2", "overwatch2"}:
+ return {"--game": "ow"}
+ except:
+ pass
+ return {"--game": "lol_queue"}
+ d = dict()
+ for i in shlex.split(query):
+ try:
+ d[i.split('=')[0]] = i.split('=')[1]
+ except:
+ pass
+ return d
+
+
+def scrub(table_name):
+ return ''.join(chr for chr in table_name if chr.isalnum() or chr == '_')
+
+
+def main(bot: Bot, message: Message):
+ args = " ".join(message.value.split(" ")[1:])
+ args = parse(args)
+ here(bot, message, scrub(args.get("--game", "lol_queue")))
import logging
import ttv_api.users
import sqlite3
+import shlex
logger = logging.getLogger(__name__)
PERMISSION = 99
PREFIX = "?"
DESCRIPTION = r"Joins the queue to play the game with the streamer."
-USER_COOLDOWN = 60
+USER_COOLDOWN = 10
GLOBAL_COOLDOWN = 0
PATH = os.path.dirname(os.path.realpath(__file__))
DEFAULT_TIME_REMAINING = 60 * 60
-def main(bot: Bot, message: Message):
+def join(bot: Bot, message: Message, table: str):
twitch = ttv_api.users.get_users(user_logins=[message.nick])
if not twitch:
bot.send_privmsg(
c = conn.cursor()
c.execute(
- """
- SELECT position FROM lol_queue ORDER BY position DESC;
+ f"""
+ SELECT position FROM {table} ORDER BY position DESC;
"""
)
try:
c.execute(
- """
- INSERT INTO lol_queue (
+ f"""
+ INSERT INTO {table} (
"twitch_id",
"position",
"available",
reply=message.tags["id"],
)
conn.close()
+
+
+def parse(query):
+ query = query.split()
+ try:
+ if query[0].lower() in {"ow", "overwatch", "ow2", "overwatch2"}:
+ return {"--game": "ow"}
+ except:
+ pass
+ return {"--game": "lol_queue"}
+ d = dict()
+ for i in shlex.split(query):
+ try:
+ d[i.split('=')[0]] = i.split('=')[1]
+ except:
+ pass
+ return d
+
+
+def scrub(table_name):
+ return ''.join(chr for chr in table_name if chr.isalnum() or chr == '_')
+
+
+def main(bot: Bot, message: Message):
+ args = " ".join(message.value.split(" ")[1:])
+ args = parse(args)
+ join(bot, message, scrub(args.get("--game", "lol_queue")))
import logging
import ttv_api.users
import sqlite3
+import shlex
logger = logging.getLogger(__name__)
PATH = os.path.join(PATH, "..")
-def main(bot: Bot, message: Message):
+def leave(bot: Bot, message: Message, table: str):
twitch = ttv_api.users.get_users(user_logins=[message.nick])
if not twitch:
bot.send_privmsg(
c = conn.cursor()
c.execute(
- """
- DELETE FROM lol_queue WHERE twitch_id = ?;
+ f"""
+ DELETE FROM {table} WHERE twitch_id = ?;
""",
(twitch_id,),
)
reply=message.tags["id"],
)
conn.close()
+
+
+def parse(query):
+ query = query.split()
+ try:
+ if query[0].lower() in {"ow", "overwatch", "ow2", "overwatch2"}:
+ return {"--game": "ow"}
+ except:
+ pass
+ return {"--game": "lol_queue"}
+ d = dict()
+ for i in shlex.split(query):
+ try:
+ d[i.split('=')[0]] = i.split('=')[1]
+ except:
+ pass
+ return d
+
+
+def scrub(table_name):
+ return ''.join(chr for chr in table_name if chr.isalnum() or chr == '_')
+
+
+def main(bot: Bot, message: Message):
+ args = " ".join(message.value.split(" ")[1:])
+ args = parse(args)
+ leave(bot, message, scrub(args.get("--game", "lol_queue")))
import logging
import ttv_api.users
import sqlite3
+import shlex
logger = logging.getLogger(__name__)
PATH = os.path.join(PATH, "..")
-def main(bot: Bot, message: Message):
+def move_down(bot: Bot, message: Message, table: str):
twitch_name = message.tags.get("reply-parent-user-login", None)
if not twitch_name:
twitch_name = message.value.split(" ")[1]
try:
c.execute(
- """
+ f"""
UPDATE
- lol_queue
+ {table}
SET
position = (
SELECT
min(position)
FROM
- lol_queue
+ {table}
WHERE
position > (
SELECT
position
FROM
- lol_queue
+ {table}
WHERE
twitch_id = ?
)
SELECT
position
FROM
- lol_queue
+ {table}
WHERE
twitch_id = ?
) - position
SELECT
min(position)
FROM
- lol_queue
+ {table}
WHERE
position > (
SELECT
position
FROM
- lol_queue
+ {table}
WHERE
twitch_id = ?
)
SELECT
position
FROM
- lol_queue
+ {table}
WHERE
twitch_id = ?
)
message.channel, "Successfully moved them down.", reply=message.tags["id"]
)
conn.close()
+
+
+def parse(query):
+ query = query.split()
+ try:
+ if query[1].lower() in {"ow", "overwatch", "ow2", "overwatch2"}:
+ return {"--game": "ow"}
+ except:
+ pass
+ return {"--game": "lol_queue"}
+ d = dict()
+ for i in shlex.split(query):
+ try:
+ d[i.split('=')[0]] = i.split('=')[1]
+ except:
+ pass
+ return d
+
+
+def scrub(table_name):
+ return ''.join(chr for chr in table_name if chr.isalnum() or chr == '_')
+
+
+def main(bot: Bot, message: Message):
+ args = " ".join(message.value.split(" ")[1:])
+ args = parse(args)
+ move_down(bot, message, scrub(args.get("--game", "lol_queue")))
import logging
import ttv_api.users
import sqlite3
+import shlex
logger = logging.getLogger(__name__)
PATH = os.path.join(PATH, "..")
-def main(bot: Bot, message: Message):
+def move_up(bot: Bot, message: Message, table: str):
twitch_name = message.tags.get("reply-parent-user-login", None)
if not twitch_name:
twitch_name = message.value.split(" ")[1]
try:
c.execute(
- """
+ f"""
UPDATE
- lol_queue
+ {table}
SET
position = (
SELECT
max(position)
FROM
- lol_queue
+ {table}
WHERE
position < (
SELECT
position
FROM
- lol_queue
+ {table}
WHERE
twitch_id = ?
)
SELECT
position
FROM
- lol_queue
+ {table}
WHERE
twitch_id = ?
) - position
SELECT
max(position)
FROM
- lol_queue
+ {table}
WHERE
position < (
SELECT
position
FROM
- lol_queue
+ {table}
WHERE
twitch_id = ?
)
SELECT
position
FROM
- lol_queue
+ {table}
WHERE
twitch_id = ?
)
message.channel, "Successfully moved them up.", reply=message.tags["id"]
)
conn.close()
+
+
+def parse(query):
+ query = query.split()
+ try:
+ if query[1].lower() in {"ow", "overwatch", "ow2", "overwatch2"}:
+ return {"--game": "ow"}
+ except:
+ pass
+ return {"--game": "lol_queue"}
+ d = dict()
+ for i in shlex.split(query):
+ try:
+ d[i.split('=')[0]] = i.split('=')[1]
+ except:
+ pass
+ return d
+
+
+def scrub(table_name):
+ return ''.join(chr for chr in table_name if chr.isalnum() or chr == '_')
+
+
+def main(bot: Bot, message: Message):
+ args = " ".join(message.value.split(" ")[1:])
+ args = parse(args)
+ move_up(bot, message, scrub(args.get("--game", "lol_queue")))
import ttv_api.users
import sqlite3
import random
+import shlex
logger = logging.getLogger(__name__)
PATH = os.path.join(PATH, "..")
-def main(bot: Bot, message: Message):
+def new_teams(bot: Bot, message: Message, table: str):
conn = sqlite3.connect(os.path.join(PATH, "lol_data.db"))
c = conn.cursor()
c.execute(
- """
- SELECT twitch_id FROM lol_queue WHERE available = 1 ORDER BY position ASC;
+ f"""
+ SELECT twitch_id FROM {table} WHERE available = 1 ORDER BY position ASC;
"""
)
fetched = c.fetchall()
reply=message.tags["id"],
)
c.execute(
- """
- SELECT data FROM lol_queue_data WHERE name = 'queuesize';
+ f"""
+ SELECT data FROM {table}_data WHERE name = 'queuesize';
"""
)
fetched = c.fetchone()
blue_team: list[ttv_api.users.User] = queue_users[: queue_size // 2]
red_team: list[ttv_api.users.User] = queue_users[queue_size // 2 :]
- c.execute("UPDATE lol_queue SET team = NULL")
- sql = f"UPDATE lol_queue SET team = 0 WHERE twitch_id IN ({(', ?' * (queue_size // 2))[2:]})"
+ c.execute(f"UPDATE {table} SET team = NULL")
+ sql = f"UPDATE {table} SET team = 0 WHERE twitch_id IN ({(', ?' * (queue_size // 2))[2:]})"
c.execute(sql, tuple(user.user_id for user in blue_team))
- sql = f"UPDATE lol_queue SET team = 1 WHERE twitch_id IN ({(', ?' * (queue_size - queue_size // 2))[2:]})"
+ sql = f"UPDATE {table} SET team = 1 WHERE twitch_id IN ({(', ?' * (queue_size - queue_size // 2))[2:]})"
c.execute(sql, tuple(user.user_id for user in red_team))
conn.commit()
)
conn.close()
+
+
+def parse(query):
+ query = query.split()
+ try:
+ if query[1].lower() in {"ow", "overwatch", "ow2", "overwatch2"}:
+ return {"--game": "ow"}
+ except:
+ pass
+ return {"--game": "lol_queue"}
+ d = dict()
+ for i in shlex.split(query):
+ try:
+ d[i.split('=')[0]] = i.split('=')[1]
+ except:
+ pass
+ return d
+
+
+def scrub(table_name):
+ return ''.join(chr for chr in table_name if chr.isalnum() or chr == '_')
+
+
+def main(bot: Bot, message: Message):
+ args = " ".join(message.value.split(" ")[1:])
+ args = parse(args)
+ new_teams(bot, message, scrub(args.get("--game", "lol_queue")))
import ttv_api.users
import sqlite3
import time
+import shlex
logger = logging.getLogger(__name__)
PATH = os.path.join(PATH, "..")
-def main(bot: Bot, message: Message):
+def not_here(bot: Bot, message: Message, table: str):
twitch = ttv_api.users.get_users(user_logins=[message.nick])
if not twitch:
bot.send_privmsg(
c = conn.cursor()
c.execute(
- """
- UPDATE lol_queue SET available = 0, priority_queue = null, last_available = ? WHERE twitch_id = ?;
+ f"""
+ UPDATE {table} SET available = 0, priority_queue = null, last_available = ? WHERE twitch_id = ?;
""",
(
int(time.time()),
reply=message.tags["id"],
)
conn.close()
+
+
+def parse(query):
+ query = query.split()
+ try:
+ if query[1].lower() in {"ow", "overwatch", "ow2", "overwatch2"}:
+ return {"--game": "ow"}
+ except:
+ pass
+ return {"--game": "lol_queue"}
+ d = dict()
+ for i in shlex.split(query):
+ try:
+ d[i.split('=')[0]] = i.split('=')[1]
+ except:
+ pass
+ return d
+
+
+def scrub(table_name):
+ return ''.join(chr for chr in table_name if chr.isalnum() or chr == '_')
+
+
+def main(bot: Bot, message: Message):
+ args = " ".join(message.value.split(" ")[1:])
+ args = parse(args)
+ not_here(bot, message, scrub(args.get("--game", "lol_queue")))
import ttv_api.users
import sqlite3
import tools.smart_privmsg
+import shlex
logger = logging.getLogger(__name__)
PATH = os.path.join(PATH, "..")
-def main(bot: Bot, message: Message):
+def teams(bot: Bot, message: Message, table: str):
conn = sqlite3.connect(os.path.join(PATH, "lol_data.db"))
c = conn.cursor()
c.execute(
- """
- SELECT twitch_id, team FROM lol_queue WHERE team in (0, 1);
+ f"""
+ SELECT twitch_id, team FROM {table} WHERE team in (0, 1);
"""
)
fetched = c.fetchall()
)
conn.close()
+
+
+def parse(query):
+ query = query.split()
+ try:
+ if query[1].lower() in {"ow", "overwatch", "ow2", "overwatch2"}:
+ return {"--game": "ow"}
+ except:
+ pass
+ return {"--game": "lol_queue"}
+ d = dict()
+ for i in shlex.split(query):
+ try:
+ d[i.split('=')[0]] = i.split('=')[1]
+ except:
+ pass
+ return d
+
+
+def scrub(table_name):
+ return ''.join(chr for chr in table_name if chr.isalnum() or chr == '_')
+
+
+def main(bot: Bot, message: Message):
+ args = " ".join(message.value.split(" ")[1:])
+ args = parse(args)
+ teams(bot, message, scrub(args.get("--game", "lol_queue")))
import os
import logging
import sqlite3
+import shlex
logger = logging.getLogger(__name__)
PATH = os.path.join(PATH, "..")
-def main(bot: Bot, message: Message):
+def team_size(bot: Bot, message: Message, table: str):
replied_message = message.tags.get("reply-parent-msg-body", None)
if replied_message:
queue_size = message.value.split(" ")[2]
c = conn.cursor()
c.execute(
- """
- REPLACE INTO lol_queue_data (name, data) VALUES ('queuesize', ?)
+ f"""
+ REPLACE INTO {table}_data (name, data) VALUES ('queuesize', ?)
""",
(queue_size,),
)
)
conn.close()
+
+
+def parse(query):
+ query = query.split()
+ try:
+ if query[0].lower() in {"ow", "overwatch", "ow2", "overwatch2"}:
+ return {"--game": "ow"}
+ except:
+ pass
+ return {"--game": "lol_queue"}
+ d = dict()
+ for i in shlex.split(query):
+ try:
+ d[i.split('=')[0]] = i.split('=')[1]
+ except:
+ pass
+ return d
+
+
+def scrub(table_name):
+ return ''.join(chr for chr in table_name if chr.isalnum() or chr == '_')
+
+
+def main(bot: Bot, message: Message):
+ args = " ".join(message.value.split(" ")[1:])
+ args = parse(args)
+ team_size(bot, message, scrub(args.get("--game", "lol_queue")))
import scripts.unit_converter
import scripts.alwase
import scripts.chatting
+import scripts.chat
+import scripts.crylaugh
import database_manager
import analyze_auto_message
import time
reload(scripts.unit_converter)
reload(scripts.alwase)
reload(scripts.chatting)
+reload(scripts.chat)
+reload(scripts.crylaugh)
reload(database_manager)
reload(analyze_auto_message)
scripts.alwase.alwase(bot, message)
scripts.chatting.chatting(bot, message)
scripts.chatting.chatting_annoy(bot, message)
+ scripts.chat.chat(bot, message)
+ scripts.crylaugh.crylaugh(bot, message)
+
+ # if message.command == Commands.PART:
+ # if message.nick in {'jelemar', 'flauenn', 'ihaspeks', 'blobin_wobin', 'officiallysp'}:
+ # bot.send_privmsg(message.channel, f"/announce {message.nick} has left chat")
+ # if message.command == Commands.JOIN:
+ # if message.nick in {'jelemar', 'flauenn', 'ihaspeks', 'blobin_wobin', 'officiallysp'}:
+ # bot.send_privmsg(message.channel, f"/announce {message.nick} has joined chat")
tools.raid.raid(bot, message)
except KeyError:
replied_msg_id = None
msgs = [
- "It's alwase Madge",
- "Why don't you spell it alwase? Madge",
- "Spell it alwase or peepoArriveBan",
+ "It's ALWASE gigaMadge",
+ "Why don't you spell it ALWASE ? gigaMadge",
+ "Spell it ALWASE or peepoArriveBan",
]
msg = random.choice(msgs)
tools.smart_privmsg.send(bot, message, msg, reply=replied_msg_id)
--- /dev/null
+from aptbot.bot import Message, Commands, Bot
+import tools.smart_privmsg
+import openai
+import os
+
+openai.api_key = os.getenv("OPENAI_API")
+
+def chat(bot: Bot, message: Message):
+ if not message.nick in {'skgyorugo', 'ihaspeks'}:
+ return
+ if not message.value.startswith("# "):
+ return
+
+ replied_message = message.tags.get("reply-parent-msg-body", None)
+ if replied_message:
+ msg = replied_message
+ replied_msg_id = message.tags["reply-parent-msg-id"]
+ else:
+ msg = " ".join(message.value.split(" ")[1:])
+ replied_msg_id = message.tags['id']
+
+ response = openai.Completion.create(
+ model="text-davinci-003",
+ prompt=msg,
+ temperature=1,
+ max_tokens=4000,
+ top_p=0.3,
+ frequency_penalty=0.5,
+ presence_penalty=0.5,
+ )
+
+ if response:
+ msg = response["choices"][0]["text"]
+ msg = msg.replace("\n", " ")
+ else:
+ msg = "Sadge nothing was returned"
+
+ tools.smart_privmsg.send(bot, message, msg, reply=replied_msg_id)
if message.nick.lower() not in nicks:
return
msg = "Chatting " + message.value
+ # msg = "Pepelaff " + message.value
tools.smart_privmsg.send(bot, message, msg)
c = conn.cursor()
c.execute("DELETE FROM lol_queue")
+ c.execute("DELETE FROM ow")
conn.commit()
c.execute(
9999999,
),
)
+ c.execute(
+ """
+ INSERT INTO ow (
+ "twitch_id",
+ "position",
+ "available",
+ "last_available",
+ "time_remaining"
+ ) VALUES (?, ?, ?, ?, ?);
+ """,
+ (
+ twitch_id,
+ 0,
+ 1,
+ None,
+ 9999999,
+ ),
+ )
conn.commit()
conn.close()
--- /dev/null
+import os
+import random
+import sqlite3
+import logging
+from fastapi import FastAPI
+from fastapi.middleware.cors import CORSMiddleware
+
+app = FastAPI()
+
+origins = ["*"]
+
+app.add_middleware(
+ CORSMiddleware,
+ allow_origins=origins,
+ allow_credentials=True,
+ allow_methods=["*"],
+ allow_headers=["*"],
+)
+
+@app.get("/clip")
+async def root():
+ clips = [
+ "https://clips-media-assets2.twitch.tv/AT-cm%7CMGyhlrJbd3gtietAgP63LA.mp4",
+ "https://clips-media-assets2.twitch.tv/WATxq6O_aQBU1qrftJJ0fQ/AT-cm%7CWATxq6O_aQBU1qrftJJ0fQ.mp4",
+ ]
+ return random.choice(clips)
+
+# logger = logging.getLogger(__name__)
+
+# PATH = os.path.dirname(os.path.realpath(__file__))
+# logger.debug(f"PATH set to: {PATH}")
+
+
+# def do_command(bot: Bot, message: Message, command_modules: dict):
+# db_name_database = "database.db"
+# conn = sqlite3.connect(os.path.join(PATH, db_name_database))
+# c = conn.cursor()
+# logger.info(f"connected to database {db_name_database}")
--- /dev/null
+from aptbot.bot import Bot, Message, Commands
+import tools.smart_privmsg
+import random
+
+
+def crylaugh(bot: Bot, message: Message):
+ if random.random() > 0.05:
+ return
+ if "😂" not in message.value:
+ return
+ try:
+ replied_msg_id = message.tags["id"]
+ except KeyError:
+ replied_msg_id = None
+ msg = "Oh 😂 look 😂 at 😂 me 😂 I 😂 use 😂 this 😂 funny 😂 emoji 😂 hahahaha 😂😂😂😂😂 lit 💯 👌"
+ tools.smart_privmsg.send(bot, message, msg, reply=replied_msg_id)