Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Fix Couldn't resolve username @name and add option to disable web server run" #35

Merged
merged 1 commit into from
Oct 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,15 @@ You can choose two ways to configure grinder but keep in mind about configuratio
"Token": "test",
"ChannelId": 111,
"AdminUserId": 123,
"RunAzureWebServer": true,
"Socks5Proxy": {
"Hostname": "Hostme",
"Port": 1337,
"Username": "User",
"Password": "Secrete"
},
"ChatsToMonitor": [
"@Sample",
"@Text"
"Sample",
"Text"
],
"AllowedUsers": [
"Pasha",
Expand Down Expand Up @@ -103,8 +102,8 @@ Grinder_Bot__AllowedUsers__0=Pasha
Grinder_Bot__AllowedUsers__1=Technique

#ChatsToMonitor - chats where bot will read messages and replies
Grinder_Bot__ChatsToMonitor__0=@Sample
Grinder_Bot__ChatsToMonitor__1=@Text
Grinder_Bot__ChatsToMonitor__0=Sample
Grinder_Bot__ChatsToMonitor__1=Text

#AdminUserId - telegram user id who will be able to send private messages to bot
Grinder_Bot__AdminUserId=123
Expand Down
3 changes: 1 addition & 2 deletions src/Grinder/Datastore.fs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
namespace Grinder

open System
open FSharp.Control.Tasks.V2
open Microsoft.EntityFrameworkCore
open Grinder.DataAccess
Expand Down Expand Up @@ -29,7 +28,7 @@ module Datastore =
use context = new GrinderContext()
let! user =
context.Users
.FirstOrDefaultAsync(fun u -> u.Username.Equals(username.TrimStart('@'), StringComparison.InvariantCultureIgnoreCase))
.FirstOrDefaultAsync(fun u -> u.Username = username.TrimStart('@'))
return user
|> Option.ofObj
|> Option.fold (fun _ u -> UserIdFound u.UserId) UserIdNotFound
Expand Down
28 changes: 12 additions & 16 deletions src/Grinder/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ module Program =
AllowedUsers: string array
ChannelId: int64
AdminUserId: int64
DisableAzureWebServer: bool
}

[<CLIMutable>]
Expand Down Expand Up @@ -173,21 +172,18 @@ module Program =

printfn "Bot started"

if not config.DisableAzureWebServer then
// Needed for azure web app deploy check. We have to response with anything on port 80
use listener = new HttpListener()
listener.Prefixes.Add("http://*:80/")
listener.Start()

let buffer = System.Text.Encoding.UTF8.GetBytes "OK"

while true do
let ctx = listener.GetContext()
let output = ctx.Response.OutputStream
output.Write(buffer, 0, buffer.Length)
output.Close()
else
Console.ReadLine () |> ignore
// Needed for azure web app deploy check. We have to response with anything on port 80
use listener = new HttpListener()
listener.Prefixes.Add("http://*:80/")
listener.Start()

let buffer = System.Text.Encoding.UTF8.GetBytes "OK"

while true do
let ctx = listener.GetContext()
let output = ctx.Response.OutputStream
output.Write(buffer, 0, buffer.Length)
output.Close();

printfn "Bot exited"
0 // return an integer exit code
1 change: 0 additions & 1 deletion src/Grinder/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"Token": "REPLACEME",
"ChannelId": 0,
"AdminUserId": 0,
"DisableAzureWebServer": true,
// uncomment if you need proxy
// "Socks5Proxy": {
// "Hostname": "REPLACEME",
Expand Down