Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ea76d7dd8c | ||
|
|
31bd70f971 | ||
|
|
f960a86cad | ||
|
|
468ccc9f95 | ||
|
|
b4f3e8737c | ||
|
|
0908f2bb7f | ||
|
|
384d8eae9d | ||
|
|
da960506a8 | ||
|
|
40dcf57953 | ||
|
|
507a487841 |
No files matched your search
@@ -6,6 +6,10 @@ on:
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
defaults:
|
||||
run:
|
||||
working-directory: src
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
|
||||
@@ -11,6 +11,9 @@ syntax: glob
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
#settings files
|
||||
*.env
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS publish
|
||||
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
|
||||
|
||||
ADD ./src /src
|
||||
WORKDIR /src
|
||||
@@ -10,7 +10,7 @@ RUN dotnet test RgDevBot.sln -c Release
|
||||
RUN dotnet publish RgDevBot.sln -c Release -o /app
|
||||
|
||||
# Final image
|
||||
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:6.0
|
||||
WORKDIR /app
|
||||
COPY --from=publish /app .
|
||||
COPY --from=build /app .
|
||||
ENTRYPOINT ["dotnet", "RgDevBot.dll"]
|
||||
@@ -0,0 +1,18 @@
|
||||
#SHELL := /bin/bash
|
||||
|
||||
ARGS = `arg="$(filter-out $@,$(MAKECMDGOALS))" && echo $${arg:-${1}}`
|
||||
|
||||
update_secrets_sample:
|
||||
@echo "Masking env files..."
|
||||
@find . -name *.env | xargs -I{} cp {} {}.sample
|
||||
@find . -name *.env.sample | xargs -I{} sed -i "s/\=.*/\=xxxxxxxxx/g" {}
|
||||
|
||||
# @cat zigbee2mqtt/settings/configuration.yaml | sed "s/\:.*/\: xxxxxxxxx/g" > zigbee2mqtt/settings/configuration.yaml.sample #mask passwords
|
||||
|
||||
commit: update_secrets_sample
|
||||
git add .
|
||||
git diff-index --quiet HEAD || git commit -m "$(call ARGS,\"updating configuration\")"
|
||||
git push
|
||||
|
||||
%:
|
||||
@:
|
||||
@@ -6,9 +6,16 @@ services:
|
||||
restart: always
|
||||
volumes:
|
||||
- "./sent.json:/app/sent.json"
|
||||
env_file: ./settings.env
|
||||
environment:
|
||||
- TZ=Europe/Moscow
|
||||
logging:
|
||||
driver: json-file
|
||||
options:
|
||||
max-size: 50m
|
||||
tor:
|
||||
build:
|
||||
context: ./tor/docker
|
||||
ports:
|
||||
- "9000:9150"
|
||||
restart: always
|
||||
@@ -1,5 +1,4 @@
|
||||
[
|
||||
622,
|
||||
621,
|
||||
620,
|
||||
619,
|
||||
@@ -28,5 +27,148 @@
|
||||
594,
|
||||
593,
|
||||
592,
|
||||
591
|
||||
591,
|
||||
622,
|
||||
625,
|
||||
626,
|
||||
627,
|
||||
628,
|
||||
629,
|
||||
630,
|
||||
631,
|
||||
632,
|
||||
633,
|
||||
634,
|
||||
635,
|
||||
636,
|
||||
637,
|
||||
638,
|
||||
639,
|
||||
640,
|
||||
641,
|
||||
642,
|
||||
643,
|
||||
644,
|
||||
645,
|
||||
646,
|
||||
647,
|
||||
648,
|
||||
649,
|
||||
650,
|
||||
651,
|
||||
652,
|
||||
653,
|
||||
654,
|
||||
655,
|
||||
656,
|
||||
657,
|
||||
658,
|
||||
659,
|
||||
660,
|
||||
661,
|
||||
662,
|
||||
663,
|
||||
664,
|
||||
665,
|
||||
666,
|
||||
667,
|
||||
697,
|
||||
695,
|
||||
696,
|
||||
694,
|
||||
693,
|
||||
678,
|
||||
676,
|
||||
674,
|
||||
673,
|
||||
672,
|
||||
671,
|
||||
670,
|
||||
669,
|
||||
668,
|
||||
679,
|
||||
680,
|
||||
682,
|
||||
681,
|
||||
683,
|
||||
686,
|
||||
685,
|
||||
698,
|
||||
699,
|
||||
700,
|
||||
701,
|
||||
702,
|
||||
703,
|
||||
704,
|
||||
705,
|
||||
706,
|
||||
707,
|
||||
708,
|
||||
709,
|
||||
710,
|
||||
711,
|
||||
712,
|
||||
713,
|
||||
714,
|
||||
715,
|
||||
716,
|
||||
718,
|
||||
719,
|
||||
720,
|
||||
721,
|
||||
722,
|
||||
723,
|
||||
724,
|
||||
725,
|
||||
726,
|
||||
727,
|
||||
728,
|
||||
729,
|
||||
730,
|
||||
733,
|
||||
734,
|
||||
735,
|
||||
737,
|
||||
736,
|
||||
738,
|
||||
739,
|
||||
740,
|
||||
741,
|
||||
742,
|
||||
743,
|
||||
744,
|
||||
745,
|
||||
746,
|
||||
747,
|
||||
748,
|
||||
749,
|
||||
750,
|
||||
751,
|
||||
752,
|
||||
753,
|
||||
754,
|
||||
755,
|
||||
758,
|
||||
759,
|
||||
760,
|
||||
761,
|
||||
762,
|
||||
763,
|
||||
765,
|
||||
766,
|
||||
767,
|
||||
768,
|
||||
769,
|
||||
770,
|
||||
771,
|
||||
772,
|
||||
774,
|
||||
775,
|
||||
776,
|
||||
781,
|
||||
779,
|
||||
780,
|
||||
778,
|
||||
777,
|
||||
782
|
||||
]
|
||||
@@ -0,0 +1,2 @@
|
||||
TELEGRAM_TOKEN=xxxxxxxxx
|
||||
TELEGRAM_CHAT_ID=xxxxxxxxx
|
||||
+25
-14
@@ -3,8 +3,8 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using RgDevBot.Config;
|
||||
using RgDevBot.ObjectModel;
|
||||
@@ -23,10 +23,10 @@ namespace RgDevBot
|
||||
_config = config;
|
||||
}
|
||||
|
||||
public void Parse()
|
||||
public async Task Parse()
|
||||
{
|
||||
var url = "https://rg-dev.ru/api/news/?type=news";
|
||||
var content = Get(url);
|
||||
var url = "https://rg-dev.ru/api/news/?format=json&type=news";
|
||||
var content = await Get(url);
|
||||
|
||||
var news = JsonConvert.DeserializeObject<NewsListResponse>(content);
|
||||
var latestNews = news?.results;
|
||||
@@ -56,18 +56,29 @@ namespace RgDevBot
|
||||
}
|
||||
}
|
||||
|
||||
public string Get(string url, string contentType = "application/json")
|
||||
public async Task<string> Get(string url, string contentType = "application/json")
|
||||
{
|
||||
var httpRequest = (HttpWebRequest)WebRequest.Create(url);
|
||||
httpRequest.ContentType = contentType;
|
||||
httpRequest.Method = "GET";
|
||||
var client = GetClientWithProxy(new Uri("http://192.168.1.6:9150"));
|
||||
var result = await client.GetAsync(url);
|
||||
return await result.Content.ReadAsStringAsync();
|
||||
}
|
||||
|
||||
var httpResponse = (HttpWebResponse)httpRequest.GetResponse();
|
||||
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
|
||||
private HttpClient GetClientWithProxy(Uri proxy)
|
||||
{
|
||||
var handler = new HttpClientHandler
|
||||
{
|
||||
var result = streamReader.ReadToEnd();
|
||||
return result;
|
||||
}
|
||||
Proxy = new WebProxy($"socks5://{proxy.Host}:{proxy.Port}"),
|
||||
CheckCertificateRevocationList = false,
|
||||
MaxConnectionsPerServer = int.MaxValue,
|
||||
ServerCertificateCustomValidationCallback = (_, _, _, _) => true,
|
||||
UseCookies = true,
|
||||
UseProxy = true,
|
||||
};
|
||||
var client = new HttpClient(handler)
|
||||
{
|
||||
Timeout = TimeSpan.FromSeconds(30),
|
||||
};
|
||||
return client;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using NLog;
|
||||
using RgDevBot.Config;
|
||||
|
||||
@@ -7,7 +8,7 @@ namespace RgDevBot
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
static async Task Main(string[] args)
|
||||
{
|
||||
var config = new SentConfig(LogManager.GetCurrentClassLogger());
|
||||
var bot = new TelegramBot();
|
||||
@@ -16,13 +17,13 @@ namespace RgDevBot
|
||||
{
|
||||
try
|
||||
{
|
||||
parser.Parse();
|
||||
await parser.Parse();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
}
|
||||
Thread.Sleep(TimeSpan.FromSeconds(60));
|
||||
await Task.Delay(TimeSpan.FromSeconds(60));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -6,13 +6,26 @@ namespace RgDevBot
|
||||
public class TelegramBot
|
||||
{
|
||||
private readonly TelegramBotClient _telegram;
|
||||
public string Token => "1479535614:AAFqHdsUFikzOti0zknK_pN2sEONNAXecPY";
|
||||
public long MainChatId;
|
||||
|
||||
public TelegramBot(long chatId = -1001448086132)
|
||||
public TelegramBot()
|
||||
{
|
||||
var token = Environment.GetEnvironmentVariable("TELEGRAM_TOKEN") ??
|
||||
"1479535614:AAFqHdsUFikzOti0zknK_pN2sEONNAXecPY";
|
||||
if (string.IsNullOrEmpty(token))
|
||||
{
|
||||
throw new Exception("Please define TELEGRAM_TOKEN variable.");
|
||||
|
||||
}
|
||||
|
||||
long.TryParse(Environment.GetEnvironmentVariable("TELEGRAM_CHAT_ID"), out var chatId);
|
||||
if (chatId == 0)
|
||||
{
|
||||
//throw new Exception("Please define TELEGRAM_CHAT_ID variable.");
|
||||
}
|
||||
|
||||
MainChatId = chatId;
|
||||
_telegram = new TelegramBotClient(Token);
|
||||
_telegram = new TelegramBotClient(token);
|
||||
_telegram.OnMessage += Bot_OnMessage;
|
||||
_telegram.StartReceiving();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
FROM alpine:latest
|
||||
|
||||
RUN apk update \
|
||||
&& apk upgrade \
|
||||
&& apk add tor \
|
||||
&& rm /var/cache/apk/*
|
||||
|
||||
EXPOSE 9150
|
||||
|
||||
ADD ./torrc /etc/tor/torrc
|
||||
|
||||
USER tor
|
||||
CMD /usr/bin/tor -f /etc/tor/torrc
|
||||
@@ -0,0 +1,31 @@
|
||||
## The directory for keeping all the keys/etc
|
||||
DataDirectory /var/lib/tor
|
||||
|
||||
## Tor opens a socks proxy on port 9150
|
||||
SocksPort 0.0.0.0:9150
|
||||
|
||||
UseBridges 1
|
||||
Bridge 64.227.79.188:6666 E152B4A1489C45CB1A56648D39FABF57C80B73D1
|
||||
Bridge 83.236.208.78:9001 B7837234BF2B3C5142659AE960F32077CD30F198
|
||||
|
||||
## Entry policies to allow/deny SOCKS requests based on IP address.
|
||||
## SocksPolicy accept 192.168.1.0/24
|
||||
SocksPolicy accept *
|
||||
|
||||
## Logs go to stdout at level "notice"
|
||||
Log notice stdout
|
||||
|
||||
ControlPort 0.0.0.0:9051
|
||||
# tor --hash-password myPwD
|
||||
HashedControlPassword 16:B1EC8A12CA8300DF606E7B4D315EC4EDB4E55B33A25C95A2FA457EB0A9
|
||||
|
||||
# Try for at most NUM seconds when building circuits. If the circuit isn't open in that time, give up on it. (Default: 1 minute.)
|
||||
CircuitBuildTimeout 60
|
||||
|
||||
# Send a padding cell every N seconds to keep firewalls from closing our connections while Tor is not in use.
|
||||
KeepalivePeriod 60
|
||||
# Force Tor to consider whether to build a new circuit every NUM seconds.
|
||||
NewCircuitPeriod 10
|
||||
# How many entry guards should we keep at a time?
|
||||
NumEntryGuards 8
|
||||
|
||||
Reference in new issue
Block a user