Compare commits

...
10 Commits
Author SHA1 Message Date
monster ea76d7dd8c ++
.NET / build (push) Failing after 52s
2022-05-16 07:45:50 +03:00
kislovdm 31bd70f971 rgdev++ 2022-05-16 07:42:46 +03:00
Your Name f960a86cad ok 2022-04-25 11:34:41 +00:00
someuser 468ccc9f95 proxy 2022-04-25 14:24:52 +03:00
monster b4f3e8737c ok 2021-02-05 21:20:56 +03:00
monster 0908f2bb7f ok 2021-02-05 21:17:50 +03:00
Your Name 384d8eae9d updating configuration 2021-02-05 18:11:29 +00:00
Your Name da960506a8 updating configuration 2021-02-05 18:09:13 +00:00
Your Name 40dcf57953 updating configuration 2021-02-05 18:08:21 +00:00
monster 507a487841 Update dotnet.yml 2021-02-05 20:41:54 +03:00
13 changed files with 271 additions and 26 deletions

No files matched your search

+4
View File
@@ -6,6 +6,10 @@ on:
pull_request: pull_request:
branches: [ master ] branches: [ master ]
defaults:
run:
working-directory: src
jobs: jobs:
build: build:
+3
View File
@@ -11,6 +11,9 @@ syntax: glob
*.userosscache *.userosscache
*.sln.docstates *.sln.docstates
#settings files
*.env
# User-specific files (MonoDevelop/Xamarin Studio) # User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs *.userprefs
+3 -3
View File
@@ -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 ADD ./src /src
WORKDIR /src WORKDIR /src
@@ -10,7 +10,7 @@ RUN dotnet test RgDevBot.sln -c Release
RUN dotnet publish RgDevBot.sln -c Release -o /app RUN dotnet publish RgDevBot.sln -c Release -o /app
# Final image # Final image
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 FROM mcr.microsoft.com/dotnet/aspnet:6.0
WORKDIR /app WORKDIR /app
COPY --from=publish /app . COPY --from=build /app .
ENTRYPOINT ["dotnet", "RgDevBot.dll"] ENTRYPOINT ["dotnet", "RgDevBot.dll"]
+18
View File
@@ -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
%:
@:
+7
View File
@@ -6,9 +6,16 @@ services:
restart: always restart: always
volumes: volumes:
- "./sent.json:/app/sent.json" - "./sent.json:/app/sent.json"
env_file: ./settings.env
environment: environment:
- TZ=Europe/Moscow - TZ=Europe/Moscow
logging: logging:
driver: json-file driver: json-file
options: options:
max-size: 50m max-size: 50m
tor:
build:
context: ./tor/docker
ports:
- "9000:9150"
restart: always
+144 -2
View File
@@ -1,5 +1,4 @@
[ [
622,
621, 621,
620, 620,
619, 619,
@@ -28,5 +27,148 @@
594, 594,
593, 593,
592, 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
] ]
+2
View File
@@ -0,0 +1,2 @@
TELEGRAM_TOKEN=xxxxxxxxx
TELEGRAM_CHAT_ID=xxxxxxxxx
+25 -14
View File
@@ -3,8 +3,8 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Text; using System.Net.Http;
using System.Text.Json.Serialization; using System.Threading.Tasks;
using Newtonsoft.Json; using Newtonsoft.Json;
using RgDevBot.Config; using RgDevBot.Config;
using RgDevBot.ObjectModel; using RgDevBot.ObjectModel;
@@ -23,10 +23,10 @@ namespace RgDevBot
_config = config; _config = config;
} }
public void Parse() public async Task Parse()
{ {
var url = "https://rg-dev.ru/api/news/?type=news"; var url = "https://rg-dev.ru/api/news/?format=json&type=news";
var content = Get(url); var content = await Get(url);
var news = JsonConvert.DeserializeObject<NewsListResponse>(content); var news = JsonConvert.DeserializeObject<NewsListResponse>(content);
var latestNews = news?.results; 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); var client = GetClientWithProxy(new Uri("http://192.168.1.6:9150"));
httpRequest.ContentType = contentType; var result = await client.GetAsync(url);
httpRequest.Method = "GET"; return await result.Content.ReadAsStringAsync();
}
var httpResponse = (HttpWebResponse)httpRequest.GetResponse(); private HttpClient GetClientWithProxy(Uri proxy)
using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) {
var handler = new HttpClientHandler
{ {
var result = streamReader.ReadToEnd(); Proxy = new WebProxy($"socks5://{proxy.Host}:{proxy.Port}"),
return result; CheckCertificateRevocationList = false,
} MaxConnectionsPerServer = int.MaxValue,
ServerCertificateCustomValidationCallback = (_, _, _, _) => true,
UseCookies = true,
UseProxy = true,
};
var client = new HttpClient(handler)
{
Timeout = TimeSpan.FromSeconds(30),
};
return client;
} }
} }
} }
+4 -3
View File
@@ -1,5 +1,6 @@
using System; using System;
using System.Threading; using System.Threading;
using System.Threading.Tasks;
using NLog; using NLog;
using RgDevBot.Config; using RgDevBot.Config;
@@ -7,7 +8,7 @@ namespace RgDevBot
{ {
class Program class Program
{ {
static void Main(string[] args) static async Task Main(string[] args)
{ {
var config = new SentConfig(LogManager.GetCurrentClassLogger()); var config = new SentConfig(LogManager.GetCurrentClassLogger());
var bot = new TelegramBot(); var bot = new TelegramBot();
@@ -16,13 +17,13 @@ namespace RgDevBot
{ {
try try
{ {
parser.Parse(); await parser.Parse();
} }
catch (Exception e) catch (Exception e)
{ {
Console.WriteLine(e); Console.WriteLine(e);
} }
Thread.Sleep(TimeSpan.FromSeconds(60)); await Task.Delay(TimeSpan.FromSeconds(60));
} }
} }
} }
+1 -1
View File
@@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>net6.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
+16 -3
View File
@@ -6,13 +6,26 @@ namespace RgDevBot
public class TelegramBot public class TelegramBot
{ {
private readonly TelegramBotClient _telegram; private readonly TelegramBotClient _telegram;
public string Token => "1479535614:AAFqHdsUFikzOti0zknK_pN2sEONNAXecPY";
public long MainChatId; 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; MainChatId = chatId;
_telegram = new TelegramBotClient(Token); _telegram = new TelegramBotClient(token);
_telegram.OnMessage += Bot_OnMessage; _telegram.OnMessage += Bot_OnMessage;
_telegram.StartReceiving(); _telegram.StartReceiving();
} }
+13
View File
@@ -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
+31
View File
@@ -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