Compare commits
3 commits
2491b0a596
...
1434a8c35b
Author | SHA1 | Date | |
---|---|---|---|
Gabriel Simmer | 1434a8c35b | ||
Gabriel Simmer | 8d749d4ccd | ||
Gabriel Simmer | d8c530f958 |
16
discord-nitter-bot/Dockerfile
Normal file
16
discord-nitter-bot/Dockerfile
Normal file
|
@ -0,0 +1,16 @@
|
|||
# Set the base image
|
||||
FROM python:3.12-slim
|
||||
|
||||
# Set the working directory inside the container
|
||||
WORKDIR /app
|
||||
|
||||
RUN pip install --no-cache-dir requests discord.py
|
||||
|
||||
# Copy the rest of the application code
|
||||
COPY . .
|
||||
|
||||
# Expose the ports needed to access the application
|
||||
EXPOSE 8080
|
||||
|
||||
# Specify the command to run your Python application
|
||||
CMD ["python", "main.py"]
|
3
discord-nitter-bot/README.md
Normal file
3
discord-nitter-bot/README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
Simple little Discord bot that pings my internal Nitter instance with the [read only patch](https://git.gmem.ca/arch/nitter/commit/ab48e5885161880438db4b0451e8bd2e568f14b0) applied to generate links using Discord.
|
||||
|
||||
An alternative to fx/vxtwitter that is able to link to the full post and replies.
|
51
discord-nitter-bot/main.py
Executable file
51
discord-nitter-bot/main.py
Executable file
|
@ -0,0 +1,51 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i python3 -p bash python312 python312Packages.requests python312Packages.discordpy
|
||||
# permission int: 277025409024
|
||||
import discord
|
||||
from discord import app_commands
|
||||
from urllib.parse import urlparse
|
||||
import requests
|
||||
import os
|
||||
|
||||
|
||||
intents = discord.Intents.default()
|
||||
client = discord.Client(intents=intents, activity=discord.Game('Swearing at Twitter'))
|
||||
tree = app_commands.CommandTree(client)
|
||||
|
||||
|
||||
@client.event
|
||||
async def on_ready():
|
||||
await tree.sync()
|
||||
print(f'We have logged in as {client.user}')
|
||||
|
||||
@tree.command()
|
||||
async def nitter(interaction: discord.Interaction, link: str):
|
||||
"""Create a nitter.gmem.ca link"""
|
||||
if link[:4] != 'http':
|
||||
link = f'//{link}'
|
||||
|
||||
try:
|
||||
urlparsed = urlparse(link)
|
||||
except:
|
||||
print(f'failed to parse {link}')
|
||||
|
||||
if 'twitter.com' not in urlparsed.netloc:
|
||||
await interaction.response.send_message('invalid twitter link', ephemeral=True)
|
||||
return
|
||||
|
||||
nitter_url = f'https://nitter.gmem.ca{urlparsed.path}'
|
||||
response = requests.get(nitter_url)
|
||||
# 4xx error codes
|
||||
if 399 < response.status_code < 500:
|
||||
await interaction.response.send_message('could not find tweet/user', ephemeral=True)
|
||||
return
|
||||
# 5xx error codes
|
||||
|
||||
if 499 < response.status_code < 600:
|
||||
await interaction.response.send_message('internal nitter server error', ephemeral=True)
|
||||
return
|
||||
|
||||
await interaction.response.send_message(nitter_url)
|
||||
|
||||
token = os.environ['DISCORD_BOT_TOKEN']
|
||||
client.run(token)
|
|
@ -29,6 +29,11 @@
|
|||
];
|
||||
};
|
||||
};
|
||||
"_acme-challenge.router" = {
|
||||
txt = {
|
||||
data = ["CJKnxKczldLEAy6zPkST0xeJ5Cy-xdT_ElzqMxhNh5E"];
|
||||
};
|
||||
};
|
||||
}
|
||||
// lib.attrsets.genAttrs [
|
||||
# Internally hosted applications
|
||||
|
|
48
flake.lock
48
flake.lock
|
@ -239,11 +239,11 @@
|
|||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1711133180,
|
||||
"narHash": "sha256-WJOahf+6115+GMl3wUfURu8fszuNeJLv9qAWFQl3Vmo=",
|
||||
"lastModified": 1712212014,
|
||||
"narHash": "sha256-s+lbaf3nLRn1++/X2eXwY9mYCA/m9l8AvyG8beeOaXE=",
|
||||
"owner": "nix-community",
|
||||
"repo": "home-manager",
|
||||
"rev": "1c2c5e4cabba4c43504ef0f8cc3f3dfa284e2dbb",
|
||||
"rev": "7e91f2a0ba4b62b88591279d54f741a13e36245b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -260,11 +260,11 @@
|
|||
"treefmt": "treefmt"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1705801181,
|
||||
"narHash": "sha256-vH+n5qMnwFCx3LMON2hQMi9PjMpmTraGYXe1czJTfAg=",
|
||||
"lastModified": 1711480255,
|
||||
"narHash": "sha256-CPF0+ZW3biHoWHE88bZt6a7G65X5Bxtgvw7xwLGrDJ4=",
|
||||
"owner": "hall",
|
||||
"repo": "kubenix",
|
||||
"rev": "76b8053b27b062b11f0c9b495050cc55606ac9dc",
|
||||
"rev": "5692af23e0835e7b21ec4e2f362b5ef9ff96d893",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -279,11 +279,11 @@
|
|||
"nixpkgs-lib": "nixpkgs-lib"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1711282133,
|
||||
"narHash": "sha256-s6z371miAZonduv53LQzjthvNCs4R+oTbv9cRu+iyL8=",
|
||||
"lastModified": 1711886936,
|
||||
"narHash": "sha256-D2WENp9GuaCostvNcQ7vElekk0V5cuMdnFZ7NfRhVrQ=",
|
||||
"owner": "nix-community",
|
||||
"repo": "lib-aggregate",
|
||||
"rev": "120535dff702c551ec76a125a181d90131407264",
|
||||
"rev": "9c06929b83e57c18d125f1105ba6a423f24083d2",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -355,11 +355,11 @@
|
|||
},
|
||||
"nixlib": {
|
||||
"locked": {
|
||||
"lastModified": 1711241261,
|
||||
"narHash": "sha256-knrTvpl81yGFHIpm1SsLDApe0thFkw1cl3ISAMPmP/0=",
|
||||
"lastModified": 1711846064,
|
||||
"narHash": "sha256-cqfX0QJNEnge3a77VnytM0Q6QZZ0DziFXt6tSCV8ZSc=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixpkgs.lib",
|
||||
"rev": "b2a1eeef8c185f6bd27432b053ff09d773244cbc",
|
||||
"rev": "90b1a963ff84dc532db92f678296ff2499a60a87",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -397,11 +397,11 @@
|
|||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1711375484,
|
||||
"narHash": "sha256-+d4HqehyQvuHUKR8Nv9HGGd/SP5wjg3MA/hEYJBWQq0=",
|
||||
"lastModified": 1712191720,
|
||||
"narHash": "sha256-xXtSSnVHURHsxLQO30dzCKW5NJVGV/umdQPmFjPFMVA=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixos-generators",
|
||||
"rev": "2b3720c7af2271be8cee713cd2f69c5127b0a8e4",
|
||||
"rev": "0c15e76bed5432d7775a22e8d22059511f59d23a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -444,11 +444,11 @@
|
|||
},
|
||||
"nixpkgs-lib": {
|
||||
"locked": {
|
||||
"lastModified": 1711241261,
|
||||
"narHash": "sha256-knrTvpl81yGFHIpm1SsLDApe0thFkw1cl3ISAMPmP/0=",
|
||||
"lastModified": 1711846064,
|
||||
"narHash": "sha256-cqfX0QJNEnge3a77VnytM0Q6QZZ0DziFXt6tSCV8ZSc=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixpkgs.lib",
|
||||
"rev": "b2a1eeef8c185f6bd27432b053ff09d773244cbc",
|
||||
"rev": "90b1a963ff84dc532db92f678296ff2499a60a87",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -467,11 +467,11 @@
|
|||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1711448229,
|
||||
"narHash": "sha256-/6y7LCwrworngRqqnUCf+J1QbscCBiWrFFsz3xkY6ls=",
|
||||
"lastModified": 1712237761,
|
||||
"narHash": "sha256-NoMBBCADTms3yx5BL+sbc7vfDivNiYULO6t9GBAsPt0=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixpkgs-wayland",
|
||||
"rev": "d06cfad4d4684e0ed64b914d39b8f21a002a3a51",
|
||||
"rev": "9b77653338f52da4b498abdf4835efb6ff6e453e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -530,11 +530,11 @@
|
|||
},
|
||||
"nixpkgs_5": {
|
||||
"locked": {
|
||||
"lastModified": 1711370797,
|
||||
"narHash": "sha256-2xu0jVSjuKhN97dqc4bVtvEH52Rwh6+uyI1XCnzoUyI=",
|
||||
"lastModified": 1712192574,
|
||||
"narHash": "sha256-LbbVOliJKTF4Zl2b9salumvdMXuQBr2kuKP5+ZwbYq4=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "c726225724e681b3626acc941c6f95d2b0602087",
|
||||
"rev": "f480f9d09e4b4cf87ee6151eba068197125714de",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
owner = "octodns";
|
||||
repo = pname;
|
||||
rev = "main";
|
||||
sha256 = "sha256-NSA6loxfvhlqzWJ77kLQQzseRNR5E/sVOxsusf3ATts=";
|
||||
sha256 = "sha256-KVdH55wkTk2n2t/Y+n9+/5SCk3ml8vXIlFbtmOL4DlA=";
|
||||
};
|
||||
doCheck = false;
|
||||
propagatedBuildInputs = with pkgs.python3Packages; [
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
(import ./immich.nix)
|
||||
(import ./endpoints.nix)
|
||||
(import ./homepage.nix)
|
||||
(import ./pterodactyl.nix)
|
||||
# (import ./pterodactyl.nix)
|
||||
(import ./cloudflare-exporter.nix)
|
||||
(import ./piped.nix)
|
||||
(import ./conduit.nix)
|
||||
|
@ -24,5 +24,6 @@
|
|||
(import ./nitter.nix)
|
||||
(import ./changedetection.nix)
|
||||
(import ./nextdns-exporter.nix)
|
||||
(import ./nitter-bot.nix)
|
||||
];
|
||||
}
|
||||
|
|
|
@ -409,7 +409,7 @@
|
|||
trustedInterfaces = ["tailscale0"];
|
||||
checkReversePath = "loose";
|
||||
enable = true;
|
||||
allowedTCPPorts = [22 80 443 9798 2049];
|
||||
allowedTCPPorts = [22 80 443 9798 2049 4328];
|
||||
allowedUDPPorts = [41641];
|
||||
};
|
||||
nftables.enable = true;
|
||||
|
|
Loading…
Reference in a new issue