NobGit
public imalexnord read

Discord-hetzner-VM

No description yet

Languages

Repository composition by tracked source files.

Python
Python 100%
Create file Wiki Documentation
Clone
https://nobgit.com/user/imalexnord/discord-hetzner-vm.git
ssh://[email protected]:2222/user/imalexnord/discord-hetzner-vm.git

Trace

bot.py

Trace helps you understand code history line by line. See who changed each line, when it changed, and which commit introduced it.

bot.py on main
Author Date Commit Line Code
Alex Carrington 7 months ago 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
1
import os
Open commit View diff
1 import os
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
2
import asyncio
Open commit View diff
2 import asyncio
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
3
import sqlite3
Open commit View diff
3 import sqlite3
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
4
from dataclasses import dataclass
Open commit View diff
4 from dataclasses import dataclass
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
5
from typing import Optional, Dict, List, Tuple
Open commit View diff
5 from typing import Optional, Dict, List, Tuple
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
6
Open commit View diff
6
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
7
from dotenv import load_dotenv
Open commit View diff
7 from dotenv import load_dotenv
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
8
Open commit View diff
8
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
9
import discord
Open commit View diff
9 import discord
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
10
from discord import app_commands
Open commit View diff
10 from discord import app_commands
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
11
from discord.ext import commands
Open commit View diff
11 from discord.ext import commands
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
12
Open commit View diff
12
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
13
from hcloud import Client
Open commit View diff
13 from hcloud import Client
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
14
Open commit View diff
14
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
15
Open commit View diff
15
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
16
load_dotenv()
Open commit View diff
16 load_dotenv()
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
17
Open commit View diff
17
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
18
DISCORD_TOKEN = os.getenv("DISCORD_TOKEN")
Open commit View diff
18 DISCORD_TOKEN = os.getenv("DISCORD_TOKEN")
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
19
HCLOUD_TOKEN = os.getenv("HCLOUD_TOKEN")
Open commit View diff
19 HCLOUD_TOKEN = os.getenv("HCLOUD_TOKEN")
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
20
if not DISCORD_TOKEN or not HCLOUD_TOKEN:
Open commit View diff
20 if not DISCORD_TOKEN or not HCLOUD_TOKEN:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
21
    raise RuntimeError("Missing DISCORD_TOKEN or HCLOUD_TOKEN in env")
Open commit View diff
21 raise RuntimeError("Missing DISCORD_TOKEN or HCLOUD_TOKEN in env")
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
22
Open commit View diff
22
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
23
hc = Client(token=HCLOUD_TOKEN)
Open commit View diff
23 hc = Client(token=HCLOUD_TOKEN)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
24
Open commit View diff
24
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
25
DEFAULT_SERVER_TYPE = "cx23"
Open commit View diff
25 DEFAULT_SERVER_TYPE = "cx23"
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
26
DB_PATH = "servers.db"
Open commit View diff
26 DB_PATH = "servers.db"
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
27
Open commit View diff
27
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
28
Open commit View diff
28
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
29
def db_init() -> None:
Open commit View diff
29 def db_init() -> None:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
30
    with sqlite3.connect(DB_PATH) as con:
Open commit View diff
30 with sqlite3.connect(DB_PATH) as con:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
31
        cur = con.cursor()
Open commit View diff
31 cur = con.cursor()
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
32
        cur.execute(
Open commit View diff
32 cur.execute(
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
33
            """
Open commit View diff
33 """
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
34
            CREATE TABLE IF NOT EXISTS server_map (
Open commit View diff
34 CREATE TABLE IF NOT EXISTS server_map (
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
35
                discord_user_id TEXT NOT NULL,
Open commit View diff
35 discord_user_id TEXT NOT NULL,
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
36
                server_id INTEGER NOT NULL,
Open commit View diff
36 server_id INTEGER NOT NULL,
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
37
                server_name TEXT NOT NULL,
Open commit View diff
37 server_name TEXT NOT NULL,
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
38
                PRIMARY KEY(discord_user_id, server_id)
Open commit View diff
38 PRIMARY KEY(discord_user_id, server_id)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
39
            )
Open commit View diff
39 )
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
40
            """
Open commit View diff
40 """
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
41
        )
Open commit View diff
41 )
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
42
        cur.execute(
Open commit View diff
42 cur.execute(
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
43
            """
Open commit View diff
43 """
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
44
            CREATE TABLE IF NOT EXISTS user_defaults (
Open commit View diff
44 CREATE TABLE IF NOT EXISTS user_defaults (
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
45
                discord_user_id TEXT PRIMARY KEY,
Open commit View diff
45 discord_user_id TEXT PRIMARY KEY,
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
46
                network_id INTEGER,
Open commit View diff
46 network_id INTEGER,
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
47
                ssh_key_id INTEGER,
Open commit View diff
47 ssh_key_id INTEGER,
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
48
                firewall_id INTEGER
Open commit View diff
48 firewall_id INTEGER
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
49
            )
Open commit View diff
49 )
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
50
            """
Open commit View diff
50 """
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
51
        )
Open commit View diff
51 )
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
52
        con.commit()
Open commit View diff
52 con.commit()
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
53
Open commit View diff
53
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
54
Open commit View diff
54
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
55
def db_add_server(discord_user_id: int, server_id: int, server_name: str) -> None:
Open commit View diff
55 def db_add_server(discord_user_id: int, server_id: int, server_name: str) -> None:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
56
    with sqlite3.connect(DB_PATH) as con:
Open commit View diff
56 with sqlite3.connect(DB_PATH) as con:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
57
        cur = con.cursor()
Open commit View diff
57 cur = con.cursor()
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
58
        cur.execute(
Open commit View diff
58 cur.execute(
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
59
            "INSERT OR REPLACE INTO server_map(discord_user_id, server_id, server_name) VALUES (?, ?, ?)",
Open commit View diff
59 "INSERT OR REPLACE INTO server_map(discord_user_id, server_id, server_name) VALUES (?, ?, ?)",
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
60
            (str(discord_user_id), int(server_id), server_name),
Open commit View diff
60 (str(discord_user_id), int(server_id), server_name),
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
61
        )
Open commit View diff
61 )
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
62
        con.commit()
Open commit View diff
62 con.commit()
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
63
Open commit View diff
63
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
64
Open commit View diff
64
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
65
def db_find_server(discord_user_id: int, query: str) -> Optional[int]:
Open commit View diff
65 def db_find_server(discord_user_id: int, query: str) -> Optional[int]:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
66
    q = (query or "").strip()
Open commit View diff
66 q = (query or "").strip()
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
67
    with sqlite3.connect(DB_PATH) as con:
Open commit View diff
67 with sqlite3.connect(DB_PATH) as con:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
68
        cur = con.cursor()
Open commit View diff
68 cur = con.cursor()
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
69
        if q.isdigit():
Open commit View diff
69 if q.isdigit():
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
70
            cur.execute(
Open commit View diff
70 cur.execute(
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
71
                "SELECT server_id FROM server_map WHERE discord_user_id=? AND server_id=?",
Open commit View diff
71 "SELECT server_id FROM server_map WHERE discord_user_id=? AND server_id=?",
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
72
                (str(discord_user_id), int(q)),
Open commit View diff
72 (str(discord_user_id), int(q)),
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
73
            )
Open commit View diff
73 )
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
74
            row = cur.fetchone()
Open commit View diff
74 row = cur.fetchone()
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
75
            return row[0] if row else None
Open commit View diff
75 return row[0] if row else None
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
76
Open commit View diff
76
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
77
        cur.execute(
Open commit View diff
77 cur.execute(
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
78
            "SELECT server_id FROM server_map WHERE discord_user_id=? AND server_name=?",
Open commit View diff
78 "SELECT server_id FROM server_map WHERE discord_user_id=? AND server_name=?",
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
79
            (str(discord_user_id), q),
Open commit View diff
79 (str(discord_user_id), q),
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
80
        )
Open commit View diff
80 )
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
81
        row = cur.fetchone()
Open commit View diff
81 row = cur.fetchone()
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
82
        return row[0] if row else None
Open commit View diff
82 return row[0] if row else None
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
83
Open commit View diff
83
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
84
Open commit View diff
84
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
85
def db_get_defaults(discord_user_id: int) -> Tuple[Optional[int], Optional[int], Optional[int]]:
Open commit View diff
85 def db_get_defaults(discord_user_id: int) -> Tuple[Optional[int], Optional[int], Optional[int]]:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
86
    with sqlite3.connect(DB_PATH) as con:
Open commit View diff
86 with sqlite3.connect(DB_PATH) as con:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
87
        cur = con.cursor()
Open commit View diff
87 cur = con.cursor()
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
88
        cur.execute(
Open commit View diff
88 cur.execute(
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
89
            "SELECT network_id, ssh_key_id, firewall_id FROM user_defaults WHERE discord_user_id=?",
Open commit View diff
89 "SELECT network_id, ssh_key_id, firewall_id FROM user_defaults WHERE discord_user_id=?",
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
90
            (str(discord_user_id),),
Open commit View diff
90 (str(discord_user_id),),
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
91
        )
Open commit View diff
91 )
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
92
        row = cur.fetchone()
Open commit View diff
92 row = cur.fetchone()
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
93
        if not row:
Open commit View diff
93 if not row:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
94
            return None, None, None
Open commit View diff
94 return None, None, None
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
95
        return row[0], row[1], row[2]
Open commit View diff
95 return row[0], row[1], row[2]
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
96
Open commit View diff
96
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
97
Open commit View diff
97
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
98
def db_set_defaults(
Open commit View diff
98 def db_set_defaults(
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
99
    discord_user_id: int,
Open commit View diff
99 discord_user_id: int,
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
100
    network_id: Optional[int],
Open commit View diff
100 network_id: Optional[int],
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
101
    ssh_key_id: Optional[int],
Open commit View diff
101 ssh_key_id: Optional[int],
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
102
    firewall_id: Optional[int],
Open commit View diff
102 firewall_id: Optional[int],
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
103
) -> None:
Open commit View diff
103 ) -> None:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
104
    with sqlite3.connect(DB_PATH) as con:
Open commit View diff
104 with sqlite3.connect(DB_PATH) as con:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
105
        cur = con.cursor()
Open commit View diff
105 cur = con.cursor()
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
106
        cur.execute(
Open commit View diff
106 cur.execute(
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
107
            "INSERT OR REPLACE INTO user_defaults(discord_user_id, network_id, ssh_key_id, firewall_id) VALUES (?, ?, ?, ?)",
Open commit View diff
107 "INSERT OR REPLACE INTO user_defaults(discord_user_id, network_id, ssh_key_id, firewall_id) VALUES (?, ?, ?, ?)",
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
108
            (str(discord_user_id), network_id, ssh_key_id, firewall_id),
Open commit View diff
108 (str(discord_user_id), network_id, ssh_key_id, firewall_id),
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
109
        )
Open commit View diff
109 )
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
110
        con.commit()
Open commit View diff
110 con.commit()
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
111
Open commit View diff
111
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
112
Open commit View diff
112
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
113
@dataclass
Open commit View diff
113 @dataclass
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
114
class HetznerCache:
Open commit View diff
114 class HetznerCache:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
115
    locations: Dict[str, object]
Open commit View diff
115 locations: Dict[str, object]
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
116
    server_types: Dict[str, object]
Open commit View diff
116 server_types: Dict[str, object]
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
117
    images_all: Dict[str, object]
Open commit View diff
117 images_all: Dict[str, object]
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
118
    images_x86: Dict[str, object]
Open commit View diff
118 images_x86: Dict[str, object]
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
119
    networks: Dict[int, object]
Open commit View diff
119 networks: Dict[int, object]
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
120
    ssh_keys: Dict[int, object]
Open commit View diff
120 ssh_keys: Dict[int, object]
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
121
    firewalls: Dict[int, object]
Open commit View diff
121 firewalls: Dict[int, object]
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
122
Open commit View diff
122
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
123
Open commit View diff
123
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
124
HCACHE: Optional[HetznerCache] = None
Open commit View diff
124 HCACHE: Optional[HetznerCache] = None
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
125
AUTO_IMAGES_X86: List[str] = []
Open commit View diff
125 AUTO_IMAGES_X86: List[str] = []
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
126
AUTO_LOCATIONS: List[str] = []
Open commit View diff
126 AUTO_LOCATIONS: List[str] = []
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
127
Open commit View diff
127
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
128
Open commit View diff
128
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
129
def _img_arch(img: object) -> str:
Open commit View diff
129 def _img_arch(img: object) -> str:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
130
    arch = getattr(img, "architecture", None)
Open commit View diff
130 arch = getattr(img, "architecture", None)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
131
    return str(arch).lower() if arch is not None else "unknown"
Open commit View diff
131 return str(arch).lower() if arch is not None else "unknown"
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
132
Open commit View diff
132
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
133
Open commit View diff
133
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
134
def _is_x86_arch(arch: str) -> bool:
Open commit View diff
134 def _is_x86_arch(arch: str) -> bool:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
135
    a = (arch or "").lower()
Open commit View diff
135 a = (arch or "").lower()
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
136
    return ("x86" in a) or ("amd64" in a) or ("x86_64" in a)
Open commit View diff
136 return ("x86" in a) or ("amd64" in a) or ("x86_64" in a)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
137
Open commit View diff
137
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
138
Open commit View diff
138
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
139
def build_cache() -> HetznerCache:
Open commit View diff
139 def build_cache() -> HetznerCache:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
140
    locations = {l.name: l for l in hc.locations.get_all()}
Open commit View diff
140 locations = {l.name: l for l in hc.locations.get_all()}
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
141
    server_types = {st.name: st for st in hc.server_types.get_all()}
Open commit View diff
141 server_types = {st.name: st for st in hc.server_types.get_all()}
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
142
Open commit View diff
142
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
143
    images_all_list = hc.images.get_all()
Open commit View diff
143 images_all_list = hc.images.get_all()
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
144
    images_all = {im.name: im for im in images_all_list}
Open commit View diff
144 images_all = {im.name: im for im in images_all_list}
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
145
    images_x86 = {im.name: im for im in images_all_list if _is_x86_arch(_img_arch(im))}
Open commit View diff
145 images_x86 = {im.name: im for im in images_all_list if _is_x86_arch(_img_arch(im))}
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
146
Open commit View diff
146
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
147
    networks = {n.id: n for n in hc.networks.get_all()}
Open commit View diff
147 networks = {n.id: n for n in hc.networks.get_all()}
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
148
    ssh_keys = {k.id: k for k in hc.ssh_keys.get_all()}
Open commit View diff
148 ssh_keys = {k.id: k for k in hc.ssh_keys.get_all()}
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
149
    firewalls = {f.id: f for f in hc.firewalls.get_all()}
Open commit View diff
149 firewalls = {f.id: f for f in hc.firewalls.get_all()}
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
150
Open commit View diff
150
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
151
    return HetznerCache(
Open commit View diff
151 return HetznerCache(
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
152
        locations=locations,
Open commit View diff
152 locations=locations,
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
153
        server_types=server_types,
Open commit View diff
153 server_types=server_types,
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
154
        images_all=images_all,
Open commit View diff
154 images_all=images_all,
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
155
        images_x86=images_x86,
Open commit View diff
155 images_x86=images_x86,
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
156
        networks=networks,
Open commit View diff
156 networks=networks,
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
157
        ssh_keys=ssh_keys,
Open commit View diff
157 ssh_keys=ssh_keys,
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
158
        firewalls=firewalls,
Open commit View diff
158 firewalls=firewalls,
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
159
    )
Open commit View diff
159 )
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
160
Open commit View diff
160
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
161
Open commit View diff
161
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
162
def cache_required() -> HetznerCache:
Open commit View diff
162 def cache_required() -> HetznerCache:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
163
    global HCACHE
Open commit View diff
163 global HCACHE
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
164
    if HCACHE is None:
Open commit View diff
164 if HCACHE is None:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
165
        HCACHE = build_cache()
Open commit View diff
165 HCACHE = build_cache()
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
166
    return HCACHE
Open commit View diff
166 return HCACHE
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
167
Open commit View diff
167
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
168
Open commit View diff
168
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
169
def _top(items: List[str], n: int = 50) -> str:
Open commit View diff
169 def _top(items: List[str], n: int = 50) -> str:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
170
    head = "\n".join(items[:n])
Open commit View diff
170 head = "\n".join(items[:n])
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
171
    if len(items) <= n:
Open commit View diff
171 if len(items) <= n:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
172
        return head
Open commit View diff
172 return head
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
173
    return head + f"\n… (+{len(items) - n} more)"
Open commit View diff
173 return head + f"\n… (+{len(items) - n} more)"
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
174
Open commit View diff
174
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
175
Open commit View diff
175
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
176
def pick_single_or_user_default(kind: str, items_by_id: Dict[int, object], user_default_id: Optional[int]) -> object:
Open commit View diff
176 def pick_single_or_user_default(kind: str, items_by_id: Dict[int, object], user_default_id: Optional[int]) -> object:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
177
    if not items_by_id:
Open commit View diff
177 if not items_by_id:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
178
        raise RuntimeError(f"No {kind} exists in Hetzner.")
Open commit View diff
178 raise RuntimeError(f"No {kind} exists in Hetzner.")
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
179
Open commit View diff
179
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
180
    if len(items_by_id) == 1:
Open commit View diff
180 if len(items_by_id) == 1:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
181
        return next(iter(items_by_id.values()))
Open commit View diff
181 return next(iter(items_by_id.values()))
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
182
Open commit View diff
182
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
183
    if user_default_id and user_default_id in items_by_id:
Open commit View diff
183 if user_default_id and user_default_id in items_by_id:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
184
        return items_by_id[user_default_id]
Open commit View diff
184 return items_by_id[user_default_id]
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
185
Open commit View diff
185
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
186
    lines: List[str] = []
Open commit View diff
186 lines: List[str] = []
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
187
    for obj in items_by_id.values():
Open commit View diff
187 for obj in items_by_id.values():
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
188
        nm = getattr(obj, "name", str(getattr(obj, "id", "?")))
Open commit View diff
188 nm = getattr(obj, "name", str(getattr(obj, "id", "?")))
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
189
        oid = getattr(obj, "id", "?")
Open commit View diff
189 oid = getattr(obj, "id", "?")
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
190
        lines.append(f"- {nm} (id {oid})")
Open commit View diff
190 lines.append(f"- {nm} (id {oid})")
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
191
    lines.sort()
Open commit View diff
191 lines.sort()
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
192
Open commit View diff
192
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
193
    raise RuntimeError(
Open commit View diff
193 raise RuntimeError(
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
194
        f"Multiple {kind}s exist, and no default is set.\n"
Open commit View diff
194 f"Multiple {kind}s exist, and no default is set.\n"
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
195
        f"Use /setdefaults to choose IDs.\n\n"
Open commit View diff
195 f"Use /setdefaults to choose IDs.\n\n"
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
196
        f"Available {kind}s:\n" + "\n".join(lines)
Open commit View diff
196 f"Available {kind}s:\n" + "\n".join(lines)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
197
    )
Open commit View diff
197 )
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
198
Open commit View diff
198
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
199
Open commit View diff
199
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
200
def cloud_init_for_app(app: str) -> str:
Open commit View diff
200 def cloud_init_for_app(app: str) -> str:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
201
    app = (app or "").strip().lower()
Open commit View diff
201 app = (app or "").strip().lower()
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
202
Open commit View diff
202
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
203
    if app in ("", "none"):
Open commit View diff
203 if app in ("", "none"):
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
204
        return ""
Open commit View diff
204 return ""
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
205
Open commit View diff
205
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
206
    if app == "coolify":
Open commit View diff
206 if app == "coolify":
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
207
        return (
Open commit View diff
207 return (
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
208
            "#cloud-config\n"
Open commit View diff
208 "#cloud-config\n"
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
209
            "package_update: true\n"
Open commit View diff
209 "package_update: true\n"
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
210
            "packages:\n"
Open commit View diff
210 "packages:\n"
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
211
            "  - curl\n"
Open commit View diff
211 " - curl\n"
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
212
            "runcmd:\n"
Open commit View diff
212 "runcmd:\n"
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
213
            "  - curl -fsSL https://get.docker.com | sh\n"
Open commit View diff
213 " - curl -fsSL https://get.docker.com | sh\n"
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
214
            "  - curl -fsSL https://cdn.coollabs.io/coolify/install.sh | bash\n"
Open commit View diff
214 " - curl -fsSL https://cdn.coollabs.io/coolify/install.sh | bash\n"
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
215
        )
Open commit View diff
215 )
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
216
Open commit View diff
216
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
217
    if app == "wireguard":
Open commit View diff
217 if app == "wireguard":
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
218
        return (
Open commit View diff
218 return (
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
219
            "#cloud-config\n"
Open commit View diff
219 "#cloud-config\n"
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
220
            "package_update: true\n"
Open commit View diff
220 "package_update: true\n"
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
221
            "packages:\n"
Open commit View diff
221 "packages:\n"
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
222
            "  - wireguard\n"
Open commit View diff
222 " - wireguard\n"
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
223
            "  - qrencode\n"
Open commit View diff
223 " - qrencode\n"
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
224
            "runcmd:\n"
Open commit View diff
224 "runcmd:\n"
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
225
            "  - sysctl -w net.ipv4.ip_forward=1\n"
Open commit View diff
225 " - sysctl -w net.ipv4.ip_forward=1\n"
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
226
            "  - sysctl -w net.ipv6.conf.all.forwarding=1\n"
Open commit View diff
226 " - sysctl -w net.ipv6.conf.all.forwarding=1\n"
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
227
        )
Open commit View diff
227 )
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
228
Open commit View diff
228
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
229
    raise RuntimeError(f'Unknown app "{app}". Supported: none, coolify, wireguard')
Open commit View diff
229 raise RuntimeError(f'Unknown app "{app}". Supported: none, coolify, wireguard')
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
230
Open commit View diff
230
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
231
Open commit View diff
231
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
232
def server_embed(server) -> discord.Embed:
Open commit View diff
232 def server_embed(server) -> discord.Embed:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
233
    public_net = getattr(server, "public_net", None)
Open commit View diff
233 public_net = getattr(server, "public_net", None)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
234
    ipv4 = public_net.ipv4.ip if public_net and getattr(public_net, "ipv4", None) else "N/A"
Open commit View diff
234 ipv4 = public_net.ipv4.ip if public_net and getattr(public_net, "ipv4", None) else "N/A"
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
235
    ipv6 = public_net.ipv6.ip if public_net and getattr(public_net, "ipv6", None) else "N/A"
Open commit View diff
235 ipv6 = public_net.ipv6.ip if public_net and getattr(public_net, "ipv6", None) else "N/A"
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
236
Open commit View diff
236
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
237
    dc = getattr(server, "datacenter", None)
Open commit View diff
237 dc = getattr(server, "datacenter", None)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
238
    dc_name = dc.name if dc else "N/A"
Open commit View diff
238 dc_name = dc.name if dc else "N/A"
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
239
    loc = getattr(dc, "location", None) if dc else None
Open commit View diff
239 loc = getattr(dc, "location", None) if dc else None
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
240
    loc_name = loc.name if loc else "N/A"
Open commit View diff
240 loc_name = loc.name if loc else "N/A"
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
241
Open commit View diff
241
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
242
    embed = discord.Embed(title=f"✅ VM Ready: {server.name}")
Open commit View diff
242 embed = discord.Embed(title=f"✅ VM Ready: {server.name}")
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
243
    embed.add_field(name="Server ID", value=str(server.id), inline=True)
Open commit View diff
243 embed.add_field(name="Server ID", value=str(server.id), inline=True)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
244
    embed.add_field(name="Status", value=str(server.status), inline=True)
Open commit View diff
244 embed.add_field(name="Status", value=str(server.status), inline=True)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
245
    embed.add_field(name="Type", value=server.server_type.name, inline=True)
Open commit View diff
245 embed.add_field(name="Type", value=server.server_type.name, inline=True)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
246
    embed.add_field(name="Location", value=f"{dc_name} ({loc_name})", inline=False)
Open commit View diff
246 embed.add_field(name="Location", value=f"{dc_name} ({loc_name})", inline=False)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
247
    embed.add_field(name="IPv4", value=ipv4, inline=True)
Open commit View diff
247 embed.add_field(name="IPv4", value=ipv4, inline=True)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
248
    embed.add_field(name="IPv6", value=ipv6, inline=True)
Open commit View diff
248 embed.add_field(name="IPv6", value=ipv6, inline=True)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
249
    embed.add_field(name="Image", value=(server.image.name if getattr(server, "image", None) else "N/A"), inline=False)
Open commit View diff
249 embed.add_field(name="Image", value=(server.image.name if getattr(server, "image", None) else "N/A"), inline=False)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
250
    embed.set_footer(text="Hetzner Provisioner")
Open commit View diff
250 embed.set_footer(text="Hetzner Provisioner")
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
251
    return embed
Open commit View diff
251 return embed
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
252
Open commit View diff
252
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
253
Open commit View diff
253
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
254
def suggest_locations_text() -> str:
Open commit View diff
254 def suggest_locations_text() -> str:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
255
    c = cache_required()
Open commit View diff
255 c = cache_required()
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
256
    names = sorted(c.locations.keys())
Open commit View diff
256 names = sorted(c.locations.keys())
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
257
    return "Try a different location. Available (first 25): " + ", ".join(names[:25]) + (" …" if len(names) > 25 else "")
Open commit View diff
257 return "Try a different location. Available (first 25): " + ", ".join(names[:25]) + (" …" if len(names) > 25 else "")
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
258
Open commit View diff
258
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
259
Open commit View diff
259
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
260
def suggest_x86_images_text() -> str:
Open commit View diff
260 def suggest_x86_images_text() -> str:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
261
    c = cache_required()
Open commit View diff
261 c = cache_required()
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
262
    names = sorted(c.images_x86.keys())
Open commit View diff
262 names = sorted(c.images_x86.keys())
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
263
    return "Valid x86 images (first 25): " + ", ".join(names[:25]) + (" …" if len(names) > 25 else "")
Open commit View diff
263 return "Valid x86 images (first 25): " + ", ".join(names[:25]) + (" …" if len(names) > 25 else "")
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
264
Open commit View diff
264
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
265
Open commit View diff
265
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
266
def create_server(discord_user_id: int, name: str, location_name: str, image_name: str, app: str) -> object:
Open commit View diff
266 def create_server(discord_user_id: int, name: str, location_name: str, image_name: str, app: str) -> object:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
267
    c = cache_required()
Open commit View diff
267 c = cache_required()
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
268
Open commit View diff
268
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
269
    st = c.server_types.get(DEFAULT_SERVER_TYPE)
Open commit View diff
269 st = c.server_types.get(DEFAULT_SERVER_TYPE)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
270
    if not st:
Open commit View diff
270 if not st:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
271
        raise RuntimeError(f"Server type {DEFAULT_SERVER_TYPE} not found in Hetzner.")
Open commit View diff
271 raise RuntimeError(f"Server type {DEFAULT_SERVER_TYPE} not found in Hetzner.")
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
272
Open commit View diff
272
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
273
    loc_key = (location_name or "").strip()
Open commit View diff
273 loc_key = (location_name or "").strip()
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
274
    loc = c.locations.get(loc_key)
Open commit View diff
274 loc = c.locations.get(loc_key)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
275
    if not loc:
Open commit View diff
275 if not loc:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
276
        raise RuntimeError(f'Unknown location "{location_name}". {suggest_locations_text()}')
Open commit View diff
276 raise RuntimeError(f'Unknown location "{location_name}". {suggest_locations_text()}')
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
277
Open commit View diff
277
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
278
    img_key = (image_name or "").strip()
Open commit View diff
278 img_key = (image_name or "").strip()
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
279
    img = c.images_x86.get(img_key)
Open commit View diff
279 img = c.images_x86.get(img_key)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
280
    if not img:
Open commit View diff
280 if not img:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
281
        if img_key in c.images_all:
Open commit View diff
281 if img_key in c.images_all:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
282
            actual = _img_arch(c.images_all[img_key])
Open commit View diff
282 actual = _img_arch(c.images_all[img_key])
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
283
            raise RuntimeError(
Open commit View diff
283 raise RuntimeError(
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
284
                f"Image \"{img_key}\" is not x86-compatible (architecture: {actual})."
Open commit View diff
284 f"Image \"{img_key}\" is not x86-compatible (architecture: {actual})."
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
285
                "Pick an x86 image. Use /images or autocomplete."
Open commit View diff
285 "Pick an x86 image. Use /images or autocomplete."
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
286
                f"{suggest_x86_images_text()}"
Open commit View diff
286 f"{suggest_x86_images_text()}"
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
287
            )
Open commit View diff
287 )
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
288
        raise RuntimeError(
Open commit View diff
288 raise RuntimeError(
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
289
            f'Unknown image "{img_key}". Use /images to list valid x86 options.\n'
Open commit View diff
289 f'Unknown image "{img_key}". Use /images to list valid x86 options.\n'
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
290
            f"{suggest_x86_images_text()}"
Open commit View diff
290 f"{suggest_x86_images_text()}"
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
291
        )
Open commit View diff
291 )
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
292
Open commit View diff
292
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
293
    user_data = cloud_init_for_app(app)
Open commit View diff
293 user_data = cloud_init_for_app(app)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
294
Open commit View diff
294
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
295
    net_id, ssh_id, fw_id = db_get_defaults(discord_user_id)
Open commit View diff
295 net_id, ssh_id, fw_id = db_get_defaults(discord_user_id)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
296
    net = pick_single_or_user_default("network", c.networks, net_id)
Open commit View diff
296 net = pick_single_or_user_default("network", c.networks, net_id)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
297
    ssh_key = pick_single_or_user_default("SSH key", c.ssh_keys, ssh_id)
Open commit View diff
297 ssh_key = pick_single_or_user_default("SSH key", c.ssh_keys, ssh_id)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
298
    firewall = pick_single_or_user_default("firewall", c.firewalls, fw_id)
Open commit View diff
298 firewall = pick_single_or_user_default("firewall", c.firewalls, fw_id)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
299
Open commit View diff
299
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
300
    resp = hc.servers.create(
Open commit View diff
300 resp = hc.servers.create(
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
301
        name=name,
Open commit View diff
301 name=name,
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
302
        server_type=st,
Open commit View diff
302 server_type=st,
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
303
        image=img,
Open commit View diff
303 image=img,
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
304
        location=loc,
Open commit View diff
304 location=loc,
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
305
        networks=[net],
Open commit View diff
305 networks=[net],
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
306
        ssh_keys=[ssh_key],
Open commit View diff
306 ssh_keys=[ssh_key],
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
307
        firewalls=[firewall],
Open commit View diff
307 firewalls=[firewall],
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
308
        user_data=(user_data if user_data else None),
Open commit View diff
308 user_data=(user_data if user_data else None),
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
309
        labels={"managed_by": "discord-bot", "discord_user_id": str(discord_user_id)},
Open commit View diff
309 labels={"managed_by": "discord-bot", "discord_user_id": str(discord_user_id)},
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
310
    )
Open commit View diff
310 )
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
311
    return resp.server
Open commit View diff
311 return resp.server
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
312
Open commit View diff
312
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
313
Open commit View diff
313
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
314
intents = discord.Intents.default()
Open commit View diff
314 intents = discord.Intents.default()
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
315
bot = commands.Bot(command_prefix="!", intents=intents)
Open commit View diff
315 bot = commands.Bot(command_prefix="!", intents=intents)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
316
Open commit View diff
316
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
317
Open commit View diff
317
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
318
def is_dm(interaction: discord.Interaction) -> bool:
Open commit View diff
318 def is_dm(interaction: discord.Interaction) -> bool:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
319
    return interaction.guild is None
Open commit View diff
319 return interaction.guild is None
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
320
Open commit View diff
320
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
321
Open commit View diff
321
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
322
def _is_resource_limit_error(e: Exception) -> bool:
Open commit View diff
322 def _is_resource_limit_error(e: Exception) -> bool:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
323
    s = str(e).lower()
Open commit View diff
323 s = str(e).lower()
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
324
    return ("resource_limit_exceeded" in s) or ("server limit reached" in s) or ("limit reached" in s)
Open commit View diff
324 return ("resource_limit_exceeded" in s) or ("server limit reached" in s) or ("limit reached" in s)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
325
Open commit View diff
325
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
326
Open commit View diff
326
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
327
def _server_quota_remaining() -> Optional[int]:
Open commit View diff
327 def _server_quota_remaining() -> Optional[int]:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
328
    try:
Open commit View diff
328 try:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
329
        limits = hc.limits.get()
Open commit View diff
329 limits = hc.limits.get()
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
330
        resources = getattr(limits, "resources", None)
Open commit View diff
330 resources = getattr(limits, "resources", None)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
331
        if not resources:
Open commit View diff
331 if not resources:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
332
            return None
Open commit View diff
332 return None
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
333
        servers = getattr(resources, "servers", None)
Open commit View diff
333 servers = getattr(resources, "servers", None)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
334
        if not servers:
Open commit View diff
334 if not servers:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
335
            return None
Open commit View diff
335 return None
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
336
        maxv = getattr(servers, "max", None)
Open commit View diff
336 maxv = getattr(servers, "max", None)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
337
        used = getattr(servers, "used", None)
Open commit View diff
337 used = getattr(servers, "used", None)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
338
        if maxv is None or used is None:
Open commit View diff
338 if maxv is None or used is None:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
339
            return None
Open commit View diff
339 return None
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
340
        return int(maxv) - int(used)
Open commit View diff
340 return int(maxv) - int(used)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
341
    except Exception:
Open commit View diff
341 except Exception:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
342
        return None
Open commit View diff
342 return None
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
343
Open commit View diff
343
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
344
Open commit View diff
344
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
345
async def safe_reply(
Open commit View diff
345 async def safe_reply(
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
346
    interaction: discord.Interaction,
Open commit View diff
346 interaction: discord.Interaction,
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
347
    content: Optional[str] = None,
Open commit View diff
347 content: Optional[str] = None,
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
348
    embed: Optional[discord.Embed] = None,
Open commit View diff
348 embed: Optional[discord.Embed] = None,
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
349
    ephemeral: bool = False,
Open commit View diff
349 ephemeral: bool = False,
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
350
):
Open commit View diff
350 ):
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
351
    if is_dm(interaction):
Open commit View diff
351 if is_dm(interaction):
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
352
        ephemeral = False
Open commit View diff
352 ephemeral = False
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
353
Open commit View diff
353
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
354
    if interaction.response.is_done():
Open commit View diff
354 if interaction.response.is_done():
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
355
        await interaction.followup.send(content=content, embed=embed, ephemeral=ephemeral)
Open commit View diff
355 await interaction.followup.send(content=content, embed=embed, ephemeral=ephemeral)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
356
    else:
Open commit View diff
356 else:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
357
        await interaction.response.send_message(content=content, embed=embed, ephemeral=ephemeral)
Open commit View diff
357 await interaction.response.send_message(content=content, embed=embed, ephemeral=ephemeral)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
358
Open commit View diff
358
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
359
Open commit View diff
359
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
360
async def send_long(interaction: discord.Interaction, text: str, ephemeral: bool = True) -> None:
Open commit View diff
360 async def send_long(interaction: discord.Interaction, text: str, ephemeral: bool = True) -> None:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
361
    if text is None:
Open commit View diff
361 if text is None:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
362
        return
Open commit View diff
362 return
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
363
    ep = False if is_dm(interaction) else ephemeral
Open commit View diff
363 ep = False if is_dm(interaction) else ephemeral
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
364
    chunks: List[str] = []
Open commit View diff
364 chunks: List[str] = []
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
365
    s = text
Open commit View diff
365 s = text
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
366
    while len(s) > 1900:
Open commit View diff
366 while len(s) > 1900:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
367
        cut = s.rfind("\n", 0, 1900)
Open commit View diff
367 cut = s.rfind("\n", 0, 1900)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
368
        if cut == -1:
Open commit View diff
368 if cut == -1:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
369
            cut = 1900
Open commit View diff
369 cut = 1900
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
370
        chunks.append(s[:cut])
Open commit View diff
370 chunks.append(s[:cut])
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
371
        s = s[cut:].lstrip("\n")
Open commit View diff
371 s = s[cut:].lstrip("\n")
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
372
    if s:
Open commit View diff
372 if s:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
373
        chunks.append(s)
Open commit View diff
373 chunks.append(s)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
374
Open commit View diff
374
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
375
    first = True
Open commit View diff
375 first = True
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
376
    for chunk in chunks:
Open commit View diff
376 for chunk in chunks:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
377
        if first and not interaction.response.is_done():
Open commit View diff
377 if first and not interaction.response.is_done():
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
378
            await interaction.response.send_message(chunk, ephemeral=ep)
Open commit View diff
378 await interaction.response.send_message(chunk, ephemeral=ep)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
379
            first = False
Open commit View diff
379 first = False
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
380
        else:
Open commit View diff
380 else:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
381
            await interaction.followup.send(chunk, ephemeral=ep)
Open commit View diff
381 await interaction.followup.send(chunk, ephemeral=ep)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
382
Open commit View diff
382
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
383
Open commit View diff
383
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
384
async def image_autocomplete(interaction: discord.Interaction, current: str) -> List[app_commands.Choice[str]]:
Open commit View diff
384 async def image_autocomplete(interaction: discord.Interaction, current: str) -> List[app_commands.Choice[str]]:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
385
    try:
Open commit View diff
385 try:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
386
        cur = (current or "").lower().strip()
Open commit View diff
386 cur = (current or "").lower().strip()
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
387
        if not AUTO_IMAGES_X86:
Open commit View diff
387 if not AUTO_IMAGES_X86:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
388
            return []
Open commit View diff
388 return []
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
389
        names = AUTO_IMAGES_X86
Open commit View diff
389 names = AUTO_IMAGES_X86
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
390
        if cur:
Open commit View diff
390 if cur:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
391
            names = [n for n in names if cur in n.lower()]
Open commit View diff
391 names = [n for n in names if cur in n.lower()]
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
392
        return [app_commands.Choice(name=n, value=n) for n in names[:25]]
Open commit View diff
392 return [app_commands.Choice(name=n, value=n) for n in names[:25]]
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
393
    except Exception as e:
Open commit View diff
393 except Exception as e:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
394
        print("image_autocomplete error:", repr(e))
Open commit View diff
394 print("image_autocomplete error:", repr(e))
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
395
        return []
Open commit View diff
395 return []
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
396
Open commit View diff
396
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
397
Open commit View diff
397
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
398
async def location_autocomplete(interaction: discord.Interaction, current: str) -> List[app_commands.Choice[str]]:
Open commit View diff
398 async def location_autocomplete(interaction: discord.Interaction, current: str) -> List[app_commands.Choice[str]]:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
399
    try:
Open commit View diff
399 try:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
400
        cur = (current or "").lower().strip()
Open commit View diff
400 cur = (current or "").lower().strip()
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
401
        if not AUTO_LOCATIONS:
Open commit View diff
401 if not AUTO_LOCATIONS:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
402
            return []
Open commit View diff
402 return []
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
403
        names = AUTO_LOCATIONS
Open commit View diff
403 names = AUTO_LOCATIONS
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
404
        if cur:
Open commit View diff
404 if cur:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
405
            names = [n for n in names if cur in n.lower()]
Open commit View diff
405 names = [n for n in names if cur in n.lower()]
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
406
        return [app_commands.Choice(name=n, value=n) for n in names[:25]]
Open commit View diff
406 return [app_commands.Choice(name=n, value=n) for n in names[:25]]
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
407
    except Exception as e:
Open commit View diff
407 except Exception as e:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
408
        print("location_autocomplete error:", repr(e))
Open commit View diff
408 print("location_autocomplete error:", repr(e))
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
409
        return []
Open commit View diff
409 return []
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
410
Open commit View diff
410
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
411
Open commit View diff
411
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
412
@bot.event
Open commit View diff
412 @bot.event
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
413
async def on_ready():
Open commit View diff
413 async def on_ready():
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
414
    global HCACHE, AUTO_IMAGES_X86, AUTO_LOCATIONS
Open commit View diff
414 global HCACHE, AUTO_IMAGES_X86, AUTO_LOCATIONS
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
415
Open commit View diff
415
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
416
    db_init()
Open commit View diff
416 db_init()
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
417
Open commit View diff
417
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
418
    HCACHE = await asyncio.to_thread(build_cache)
Open commit View diff
418 HCACHE = await asyncio.to_thread(build_cache)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
419
    AUTO_IMAGES_X86 = sorted(HCACHE.images_x86.keys())
Open commit View diff
419 AUTO_IMAGES_X86 = sorted(HCACHE.images_x86.keys())
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
420
    AUTO_LOCATIONS = sorted(HCACHE.locations.keys())
Open commit View diff
420 AUTO_LOCATIONS = sorted(HCACHE.locations.keys())
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
421
Open commit View diff
421
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
422
    try:
Open commit View diff
422 try:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
423
        await bot.tree.sync()
Open commit View diff
423 await bot.tree.sync()
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
424
    except Exception as e:
Open commit View diff
424 except Exception as e:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
425
        print("Sync failed:", e)
Open commit View diff
425 print("Sync failed:", e)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
426
Open commit View diff
426
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
427
    print(f"Logged in as {bot.user}")
Open commit View diff
427 print(f"Logged in as {bot.user}")
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
428
Open commit View diff
428
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
429
Open commit View diff
429
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
430
@bot.tree.error
Open commit View diff
430 @bot.tree.error
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
431
async def on_app_command_error(interaction: discord.Interaction, error: app_commands.AppCommandError):
Open commit View diff
431 async def on_app_command_error(interaction: discord.Interaction, error: app_commands.AppCommandError):
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
432
    try:
Open commit View diff
432 try:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
433
        await safe_reply(
Open commit View diff
433 await safe_reply(
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
434
            interaction,
Open commit View diff
434 interaction,
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
435
            content=f"❌ Command error:\n`{type(error).__name__}: {error}`",
Open commit View diff
435 content=f"❌ Command error:\n`{type(error).__name__}: {error}`",
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
436
            ephemeral=True,
Open commit View diff
436 ephemeral=True,
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
437
        )
Open commit View diff
437 )
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
438
    except Exception:
Open commit View diff
438 except Exception:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
439
        pass
Open commit View diff
439 pass
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
440
    raise error
Open commit View diff
440 raise error
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
441
Open commit View diff
441
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
442
Open commit View diff
442
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
443
@bot.tree.command(name="create", description="Create a Hetzner VM (required: name, location, image)")
Open commit View diff
443 @bot.tree.command(name="create", description="Create a Hetzner VM (required: name, location, image)")
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
444
@app_commands.describe(
Open commit View diff
444 @app_commands.describe(
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
445
    name="VM name",
Open commit View diff
445 name="VM name",
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
446
    location="Hetzner location (e.g. hel1, nbg1)",
Open commit View diff
446 location="Hetzner location (e.g. hel1, nbg1)",
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
447
    image="x86 image name (use /images to list all, autocomplete helps)",
Open commit View diff
447 image="x86 image name (use /images to list all, autocomplete helps)",
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
448
    app="Optional app install (none/coolify/wireguard) applied via cloud-init",
Open commit View diff
448 app="Optional app install (none/coolify/wireguard) applied via cloud-init",
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
449
    count="How many VMs to create (1-10)",
Open commit View diff
449 count="How many VMs to create (1-10)",
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
450
)
Open commit View diff
450 )
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
451
@app_commands.autocomplete(location=location_autocomplete, image=image_autocomplete)
Open commit View diff
451 @app_commands.autocomplete(location=location_autocomplete, image=image_autocomplete)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
452
async def create_cmd(
Open commit View diff
452 async def create_cmd(
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
453
    interaction: discord.Interaction,
Open commit View diff
453 interaction: discord.Interaction,
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
454
    name: str,
Open commit View diff
454 name: str,
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
455
    location: str,
Open commit View diff
455 location: str,
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
456
    image: str,
Open commit View diff
456 image: str,
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
457
    app: Optional[str] = "none",
Open commit View diff
457 app: Optional[str] = "none",
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
458
    count: Optional[int] = 1,
Open commit View diff
458 count: Optional[int] = 1,
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
459
):
Open commit View diff
459 ):
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
460
    await interaction.response.defer(thinking=True)
Open commit View diff
460 await interaction.response.defer(thinking=True)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
461
Open commit View diff
461
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
462
    base = (name or "").strip().upper()
Open commit View diff
462 base = (name or "").strip().upper()
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
463
    if not base:
Open commit View diff
463 if not base:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
464
        await safe_reply(interaction, content="❌ Name can’t be empty.", ephemeral=True)
Open commit View diff
464 await safe_reply(interaction, content="❌ Name can’t be empty.", ephemeral=True)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
465
        return
Open commit View diff
465 return
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
466
Open commit View diff
466
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
467
    try:
Open commit View diff
467 try:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
468
        n = int(count or 1)
Open commit View diff
468 n = int(count or 1)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
469
    except Exception:
Open commit View diff
469 except Exception:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
470
        await safe_reply(interaction, content="❌ count must be a number.", ephemeral=True)
Open commit View diff
470 await safe_reply(interaction, content="❌ count must be a number.", ephemeral=True)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
471
        return
Open commit View diff
471 return
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
472
Open commit View diff
472
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
473
    if n < 1 or n > 10:
Open commit View diff
473 if n < 1 or n > 10:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
474
        await safe_reply(interaction, content="❌ count must be between 1 and 10.", ephemeral=True)
Open commit View diff
474 await safe_reply(interaction, content="❌ count must be between 1 and 10.", ephemeral=True)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
475
        return
Open commit View diff
475 return
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
476
Open commit View diff
476
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
477
    remaining = _server_quota_remaining()
Open commit View diff
477 remaining = _server_quota_remaining()
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
478
    if remaining is not None and remaining <= 0:
Open commit View diff
478 if remaining is not None and remaining <= 0:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
479
        await safe_reply(interaction, content="❌ Hetzner server limit reached on this account.", ephemeral=True)
Open commit View diff
479 await safe_reply(interaction, content="❌ Hetzner server limit reached on this account.", ephemeral=True)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
480
        return
Open commit View diff
480 return
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
481
    if remaining is not None and n > remaining:
Open commit View diff
481 if remaining is not None and n > remaining:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
482
        await safe_reply(
Open commit View diff
482 await safe_reply(
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
483
            interaction,
Open commit View diff
483 interaction,
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
484
            content=f"❌ You requested {n} VM(s), but your Hetzner account only has quota for {remaining} more.",
Open commit View diff
484 content=f"❌ You requested {n} VM(s), but your Hetzner account only has quota for {remaining} more.",
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
485
            ephemeral=True,
Open commit View diff
485 ephemeral=True,
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
486
        )
Open commit View diff
486 )
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
487
        return
Open commit View diff
487 return
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
488
Open commit View diff
488
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
489
    loc = (location or "").strip()
Open commit View diff
489 loc = (location or "").strip()
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
490
    img = (image or "").strip()
Open commit View diff
490 img = (image or "").strip()
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
491
    app_val = (app or "none").strip().lower()
Open commit View diff
491 app_val = (app or "none").strip().lower()
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
492
Open commit View diff
492
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
493
    planned_names: List[str] = [base] + [f"{base}{i}" for i in range(1, n)]
Open commit View diff
493 planned_names: List[str] = [base] + [f"{base}{i}" for i in range(1, n)]
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
494
Open commit View diff
494
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
495
    created_ids: List[int] = []
Open commit View diff
495 created_ids: List[int] = []
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
496
    created_names: List[str] = []
Open commit View diff
496 created_names: List[str] = []
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
497
Open commit View diff
497
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
498
    for vm_name in planned_names:
Open commit View diff
498 for vm_name in planned_names:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
499
        try:
Open commit View diff
499 try:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
500
            server = await asyncio.to_thread(create_server, interaction.user.id, vm_name, loc, img, app_val)
Open commit View diff
500 server = await asyncio.to_thread(create_server, interaction.user.id, vm_name, loc, img, app_val)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
501
        except Exception as e:
Open commit View diff
501 except Exception as e:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
502
            if _is_resource_limit_error(e):
Open commit View diff
502 if _is_resource_limit_error(e):
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
503
                msg = "❌ Hetzner server limit reached on this account."
Open commit View diff
503 msg = "❌ Hetzner server limit reached on this account."
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
504
            else:
Open commit View diff
504 else:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
505
                msg = f"❌ Failed creating VM:\n`{e}`"
Open commit View diff
505 msg = f"❌ Failed creating VM:\n`{e}`"
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
506
Open commit View diff
506
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
507
            if created_names:
Open commit View diff
507 if created_names:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
508
                await safe_reply(
Open commit View diff
508 await safe_reply(
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
509
                    interaction,
Open commit View diff
509 interaction,
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
510
                    content=(
Open commit View diff
510 content=(
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
511
                        "❌ Failed creating one of the VMs.\n"
Open commit View diff
511 "❌ Failed creating one of the VMs.\n"
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
512
                        f"Created so far: {', '.join(created_names)}\n\n"
Open commit View diff
512 f"Created so far: {', '.join(created_names)}\n\n"
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
513
                        + (msg if _is_resource_limit_error(e) else f"Error: `{e}`")
Open commit View diff
513 + (msg if _is_resource_limit_error(e) else f"Error: `{e}`")
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
514
                    ),
Open commit View diff
514 ),
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
515
                    ephemeral=True,
Open commit View diff
515 ephemeral=True,
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
516
                )
Open commit View diff
516 )
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
517
            else:
Open commit View diff
517 else:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
518
                await safe_reply(interaction, content=msg, ephemeral=True)
Open commit View diff
518 await safe_reply(interaction, content=msg, ephemeral=True)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
519
            return
Open commit View diff
519 return
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
520
Open commit View diff
520
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
521
        db_add_server(interaction.user.id, server.id, server.name)
Open commit View diff
521 db_add_server(interaction.user.id, server.id, server.name)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
522
        created_ids.append(int(server.id))
Open commit View diff
522 created_ids.append(int(server.id))
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
523
        created_names.append(server.name)
Open commit View diff
523 created_names.append(server.name)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
524
Open commit View diff
524
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
525
    await asyncio.sleep(20)
Open commit View diff
525 await asyncio.sleep(20)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
526
Open commit View diff
526
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
527
    embeds: List[discord.Embed] = []
Open commit View diff
527 embeds: List[discord.Embed] = []
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
528
    for sid in created_ids:
Open commit View diff
528 for sid in created_ids:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
529
        try:
Open commit View diff
529 try:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
530
            srv = hc.servers.get_by_id(sid)
Open commit View diff
530 srv = hc.servers.get_by_id(sid)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
531
            embeds.append(server_embed(srv))
Open commit View diff
531 embeds.append(server_embed(srv))
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
532
        except Exception as e:
Open commit View diff
532 except Exception as e:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
533
            await safe_reply(interaction, content=f"⚠️ Created server {sid}, but fetch failed: `{e}`", ephemeral=True)
Open commit View diff
533 await safe_reply(interaction, content=f"⚠️ Created server {sid}, but fetch failed: `{e}`", ephemeral=True)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
534
Open commit View diff
534
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
535
    if not embeds:
Open commit View diff
535 if not embeds:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
536
        await safe_reply(interaction, content="⚠️ VMs created, but I couldn’t fetch details.", ephemeral=True)
Open commit View diff
536 await safe_reply(interaction, content="⚠️ VMs created, but I couldn’t fetch details.", ephemeral=True)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
537
        return
Open commit View diff
537 return
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
538
Open commit View diff
538
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
539
    for i in range(0, len(embeds), 10):
Open commit View diff
539 for i in range(0, len(embeds), 10):
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
540
        await safe_reply(interaction, embed=embeds[i], ephemeral=True)
Open commit View diff
540 await safe_reply(interaction, embed=embeds[i], ephemeral=True)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
541
        for extra in embeds[i + 1 : i + 10]:
Open commit View diff
541 for extra in embeds[i + 1 : i + 10]:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
542
            await interaction.followup.send(embed=extra, ephemeral=(not is_dm(interaction)))
Open commit View diff
542 await interaction.followup.send(embed=extra, ephemeral=(not is_dm(interaction)))
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
543
Open commit View diff
543
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
544
Open commit View diff
544
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
545
@bot.tree.command(name="s", description="Get info about one of your servers (by name or ID)")
Open commit View diff
545 @bot.tree.command(name="s", description="Get info about one of your servers (by name or ID)")
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
546
@app_commands.describe(server="Server name or ID")
Open commit View diff
546 @app_commands.describe(server="Server name or ID")
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
547
async def s_cmd(interaction: discord.Interaction, server: str):
Open commit View diff
547 async def s_cmd(interaction: discord.Interaction, server: str):
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
548
    sid = db_find_server(interaction.user.id, server)
Open commit View diff
548 sid = db_find_server(interaction.user.id, server)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
549
    if not sid:
Open commit View diff
549 if not sid:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
550
        await safe_reply(interaction, content="I can’t find that server under your user.", ephemeral=True)
Open commit View diff
550 await safe_reply(interaction, content="I can’t find that server under your user.", ephemeral=True)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
551
        return
Open commit View diff
551 return
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
552
Open commit View diff
552
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
553
    try:
Open commit View diff
553 try:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
554
        srv = hc.servers.get_by_id(sid)
Open commit View diff
554 srv = hc.servers.get_by_id(sid)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
555
    except Exception as e:
Open commit View diff
555 except Exception as e:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
556
        await safe_reply(interaction, content=f"Fetch failed:\n`{e}`", ephemeral=True)
Open commit View diff
556 await safe_reply(interaction, content=f"Fetch failed:\n`{e}`", ephemeral=True)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
557
        return
Open commit View diff
557 return
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
558
Open commit View diff
558
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
559
    await safe_reply(interaction, embed=server_embed(srv), ephemeral=True)
Open commit View diff
559 await safe_reply(interaction, embed=server_embed(srv), ephemeral=True)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
560
Open commit View diff
560
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
561
Open commit View diff
561
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
562
@bot.tree.command(name="refresh", description="Refresh Hetzner options cache")
Open commit View diff
562 @bot.tree.command(name="refresh", description="Refresh Hetzner options cache")
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
563
async def refresh_cmd(interaction: discord.Interaction):
Open commit View diff
563 async def refresh_cmd(interaction: discord.Interaction):
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
564
    global HCACHE, AUTO_IMAGES_X86, AUTO_LOCATIONS
Open commit View diff
564 global HCACHE, AUTO_IMAGES_X86, AUTO_LOCATIONS
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
565
    await safe_reply(interaction, content="Refreshing Hetzner cache…", ephemeral=True)
Open commit View diff
565 await safe_reply(interaction, content="Refreshing Hetzner cache…", ephemeral=True)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
566
Open commit View diff
566
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
567
    try:
Open commit View diff
567 try:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
568
        HCACHE = await asyncio.to_thread(build_cache)
Open commit View diff
568 HCACHE = await asyncio.to_thread(build_cache)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
569
        AUTO_IMAGES_X86 = sorted(HCACHE.images_x86.keys())
Open commit View diff
569 AUTO_IMAGES_X86 = sorted(HCACHE.images_x86.keys())
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
570
        AUTO_LOCATIONS = sorted(HCACHE.locations.keys())
Open commit View diff
570 AUTO_LOCATIONS = sorted(HCACHE.locations.keys())
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
571
    except Exception as e:
Open commit View diff
571 except Exception as e:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
572
        await safe_reply(interaction, content=f"❌ Refresh failed:\n`{e}`", ephemeral=True)
Open commit View diff
572 await safe_reply(interaction, content=f"❌ Refresh failed:\n`{e}`", ephemeral=True)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
573
        return
Open commit View diff
573 return
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
574
Open commit View diff
574
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
575
    await safe_reply(
Open commit View diff
575 await safe_reply(
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
576
        interaction,
Open commit View diff
576 interaction,
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
577
        content=(
Open commit View diff
577 content=(
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
578
            "✅ Refreshed.\n"
Open commit View diff
578 "✅ Refreshed.\n"
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
579
            f"Locations: {len(HCACHE.locations)}\n"
Open commit View diff
579 f"Locations: {len(HCACHE.locations)}\n"
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
580
            f"Server types: {len(HCACHE.server_types)}\n"
Open commit View diff
580 f"Server types: {len(HCACHE.server_types)}\n"
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
581
            f"Images(all): {len(HCACHE.images_all)}\n"
Open commit View diff
581 f"Images(all): {len(HCACHE.images_all)}\n"
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
582
            f"Images(x86): {len(HCACHE.images_x86)}\n"
Open commit View diff
582 f"Images(x86): {len(HCACHE.images_x86)}\n"
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
583
            f"Networks: {len(HCACHE.networks)}\n"
Open commit View diff
583 f"Networks: {len(HCACHE.networks)}\n"
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
584
            f"SSH keys: {len(HCACHE.ssh_keys)}\n"
Open commit View diff
584 f"SSH keys: {len(HCACHE.ssh_keys)}\n"
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
585
            f"Firewalls: {len(HCACHE.firewalls)}"
Open commit View diff
585 f"Firewalls: {len(HCACHE.firewalls)}"
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
586
        ),
Open commit View diff
586 ),
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
587
        ephemeral=True,
Open commit View diff
587 ephemeral=True,
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
588
    )
Open commit View diff
588 )
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
589
Open commit View diff
589
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
590
Open commit View diff
590
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
591
@bot.tree.command(name="images", description="List ALL valid x86 image names (compatible with cx23)")
Open commit View diff
591 @bot.tree.command(name="images", description="List ALL valid x86 image names (compatible with cx23)")
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
592
async def images_cmd(interaction: discord.Interaction):
Open commit View diff
592 async def images_cmd(interaction: discord.Interaction):
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
593
    c = cache_required()
Open commit View diff
593 c = cache_required()
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
594
    names = sorted(c.images_x86.keys())
Open commit View diff
594 names = sorted(c.images_x86.keys())
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
595
    text = "x86 Images:\n" + _top(names, n=len(names))
Open commit View diff
595 text = "x86 Images:\n" + _top(names, n=len(names))
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
596
    await send_long(interaction, text, ephemeral=True)
Open commit View diff
596 await send_long(interaction, text, ephemeral=True)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
597
Open commit View diff
597
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
598
Open commit View diff
598
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
599
@bot.tree.command(name="locations", description="List available Hetzner locations")
Open commit View diff
599 @bot.tree.command(name="locations", description="List available Hetzner locations")
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
600
async def locations_cmd(interaction: discord.Interaction):
Open commit View diff
600 async def locations_cmd(interaction: discord.Interaction):
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
601
    c = cache_required()
Open commit View diff
601 c = cache_required()
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
602
    names = sorted(c.locations.keys())
Open commit View diff
602 names = sorted(c.locations.keys())
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
603
    text = "Locations:\n" + _top(names, n=min(len(names), 200))
Open commit View diff
603 text = "Locations:\n" + _top(names, n=min(len(names), 200))
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
604
    await send_long(interaction, text, ephemeral=True)
Open commit View diff
604 await send_long(interaction, text, ephemeral=True)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
605
Open commit View diff
605
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
606
Open commit View diff
606
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
607
@bot.tree.command(name="networks", description="List networks discovered from Hetzner")
Open commit View diff
607 @bot.tree.command(name="networks", description="List networks discovered from Hetzner")
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
608
async def networks_cmd(interaction: discord.Interaction):
Open commit View diff
608 async def networks_cmd(interaction: discord.Interaction):
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
609
    c = cache_required()
Open commit View diff
609 c = cache_required()
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
610
    lines = sorted([f"- {n.name} (id {n.id})" for n in c.networks.values()])
Open commit View diff
610 lines = sorted([f"- {n.name} (id {n.id})" for n in c.networks.values()])
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
611
    text = "Networks:\n" + ("\n".join(lines) if lines else "None")
Open commit View diff
611 text = "Networks:\n" + ("\n".join(lines) if lines else "None")
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
612
    await send_long(interaction, text, ephemeral=True)
Open commit View diff
612 await send_long(interaction, text, ephemeral=True)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
613
Open commit View diff
613
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
614
Open commit View diff
614
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
615
@bot.tree.command(name="sshkeys", description="List SSH keys discovered from Hetzner")
Open commit View diff
615 @bot.tree.command(name="sshkeys", description="List SSH keys discovered from Hetzner")
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
616
async def sshkeys_cmd(interaction: discord.Interaction):
Open commit View diff
616 async def sshkeys_cmd(interaction: discord.Interaction):
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
617
    c = cache_required()
Open commit View diff
617 c = cache_required()
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
618
    lines = sorted([f"- {k.name} (id {k.id})" for k in c.ssh_keys.values()])
Open commit View diff
618 lines = sorted([f"- {k.name} (id {k.id})" for k in c.ssh_keys.values()])
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
619
    text = "SSH keys:\n" + ("\n".join(lines) if lines else "None")
Open commit View diff
619 text = "SSH keys:\n" + ("\n".join(lines) if lines else "None")
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
620
    await send_long(interaction, text, ephemeral=True)
Open commit View diff
620 await send_long(interaction, text, ephemeral=True)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
621
Open commit View diff
621
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
622
Open commit View diff
622
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
623
@bot.tree.command(name="firewalls", description="List firewalls discovered from Hetzner")
Open commit View diff
623 @bot.tree.command(name="firewalls", description="List firewalls discovered from Hetzner")
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
624
async def firewalls_cmd(interaction: discord.Interaction):
Open commit View diff
624 async def firewalls_cmd(interaction: discord.Interaction):
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
625
    c = cache_required()
Open commit View diff
625 c = cache_required()
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
626
    lines = sorted([f"- {f.name} (id {f.id})" for f in c.firewalls.values()])
Open commit View diff
626 lines = sorted([f"- {f.name} (id {f.id})" for f in c.firewalls.values()])
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
627
    text = "Firewalls:\n" + ("\n".join(lines) if lines else "None")
Open commit View diff
627 text = "Firewalls:\n" + ("\n".join(lines) if lines else "None")
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
628
    await send_long(interaction, text, ephemeral=True)
Open commit View diff
628 await send_long(interaction, text, ephemeral=True)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
629
Open commit View diff
629
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
630
Open commit View diff
630
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
631
@bot.tree.command(
Open commit View diff
631 @bot.tree.command(
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
632
    name="setdefaults",
Open commit View diff
632 name="setdefaults",
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
633
    description="Set defaults (only needed if you have multiple networks/ssh keys/firewalls)",
Open commit View diff
633 description="Set defaults (only needed if you have multiple networks/ssh keys/firewalls)",
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
634
)
Open commit View diff
634 )
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
635
@app_commands.describe(
Open commit View diff
635 @app_commands.describe(
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
636
    network_id="Default network ID",
Open commit View diff
636 network_id="Default network ID",
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
637
    ssh_key_id="Default SSH key ID",
Open commit View diff
637 ssh_key_id="Default SSH key ID",
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
638
    firewall_id="Default firewall ID",
Open commit View diff
638 firewall_id="Default firewall ID",
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
639
)
Open commit View diff
639 )
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
640
async def setdefaults_cmd(
Open commit View diff
640 async def setdefaults_cmd(
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
641
    interaction: discord.Interaction,
Open commit View diff
641 interaction: discord.Interaction,
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
642
    network_id: Optional[int] = None,
Open commit View diff
642 network_id: Optional[int] = None,
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
643
    ssh_key_id: Optional[int] = None,
Open commit View diff
643 ssh_key_id: Optional[int] = None,
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
644
    firewall_id: Optional[int] = None,
Open commit View diff
644 firewall_id: Optional[int] = None,
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
645
):
Open commit View diff
645 ):
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
646
    c = cache_required()
Open commit View diff
646 c = cache_required()
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
647
Open commit View diff
647
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
648
    if network_id is not None and network_id not in c.networks:
Open commit View diff
648 if network_id is not None and network_id not in c.networks:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
649
        await safe_reply(interaction, content=f"Unknown network_id {network_id}. Use /networks to list.", ephemeral=True)
Open commit View diff
649 await safe_reply(interaction, content=f"Unknown network_id {network_id}. Use /networks to list.", ephemeral=True)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
650
        return
Open commit View diff
650 return
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
651
    if ssh_key_id is not None and ssh_key_id not in c.ssh_keys:
Open commit View diff
651 if ssh_key_id is not None and ssh_key_id not in c.ssh_keys:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
652
        await safe_reply(interaction, content=f"Unknown ssh_key_id {ssh_key_id}. Use /sshkeys to list.", ephemeral=True)
Open commit View diff
652 await safe_reply(interaction, content=f"Unknown ssh_key_id {ssh_key_id}. Use /sshkeys to list.", ephemeral=True)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
653
        return
Open commit View diff
653 return
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
654
    if firewall_id is not None and firewall_id not in c.firewalls:
Open commit View diff
654 if firewall_id is not None and firewall_id not in c.firewalls:
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
655
        await safe_reply(interaction, content=f"Unknown firewall_id {firewall_id}. Use /firewalls to list.", ephemeral=True)
Open commit View diff
655 await safe_reply(interaction, content=f"Unknown firewall_id {firewall_id}. Use /firewalls to list.", ephemeral=True)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
656
        return
Open commit View diff
656 return
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
657
Open commit View diff
657
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
658
    db_set_defaults(interaction.user.id, network_id, ssh_key_id, firewall_id)
Open commit View diff
658 db_set_defaults(interaction.user.id, network_id, ssh_key_id, firewall_id)
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
659
    await safe_reply(
Open commit View diff
659 await safe_reply(
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
660
        interaction,
Open commit View diff
660 interaction,
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
661
        content=(
Open commit View diff
661 content=(
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
662
            "✅ Defaults saved:\n"
Open commit View diff
662 "✅ Defaults saved:\n"
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
663
            f"- network_id: {network_id}\n"
Open commit View diff
663 f"- network_id: {network_id}\n"
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
664
            f"- ssh_key_id: {ssh_key_id}\n"
Open commit View diff
664 f"- ssh_key_id: {ssh_key_id}\n"
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
665
            f"- firewall_id: {firewall_id}"
Open commit View diff
665 f"- firewall_id: {firewall_id}"
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
666
        ),
Open commit View diff
666 ),
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
667
        ephemeral=True,
Open commit View diff
667 ephemeral=True,
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
668
    )
Open commit View diff
668 )
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
669
Open commit View diff
669
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
670
Open commit View diff
670
same change 7535a60

Initial commit

Full commit hash
7535a60ae0497f7561f00efdcf83193d8cb112ec
Author
Alex Carrington <[email protected]>
Date
7 months ago
Selected line
671
bot.run(DISCORD_TOKEN)
Open commit View diff
671 bot.run(DISCORD_TOKEN)