Skip to content

Commit

Permalink
Revert "Fix Couldn't resolve username @name and add option to disab…
Browse files Browse the repository at this point in the history
…le web server run (Liminiens#34)" (Liminiens#35)

This reverts commit 8d29618.
  • Loading branch information
Liminiens authored Oct 23, 2020
1 parent 8d29618 commit e9c9a98
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 24 deletions.
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

0 comments on commit e9c9a98

Please sign in to comment.