Can't run bot
fulcanelly opened this issue · 4 comments
fulcanelly commented
When trying to reproduce simple example getting error even from first line
open Funogram.Bot
The namespace 'Bot' is not defined. [/home/fulcanelly/...src/App/App.fsproj]
When changing it to open Funogram
it compiles, but... nothing else does...
All attempts to improvise as well leads to nothing:
Bot.startBot { defaultConfig with Token = "your token" }
/home/fulcanelly...src/App/Program.fs(33,5): error FS0039: The value, namespace, type or module 'Bot' is not defined. Maybe you want one of the following: box bool not [/home/fulcanelly/code.../App.fsproj]
Dolfik1 commented
Documentation is partially obsolete. Check out our sample bot.
There is another example (not tested, but should work):
open Funogram.Api
open Funogram.Types
open Funogram.Telegram.Api
open Funogram.Telegram.Types
open Funogram.Telegram.Bot
let config = { defaultConfig with Token = "your token" }
let updateArrived ctx =
match ctx.Update.Message with
| Some { From = Some { Id = id} } ->
sendMessageBase (ChatId.Int id) "Hello, world!" None None None None None
|> api config |> Async.Ignore |> Async.Start
| _ -> ()
[<EntryPoint>]
let main _ =
startBot config updateArrived None |> Async.RunSynchronously
fulcanelly commented
This time everything compiles without warnings but when trying to run getting this error:
Unhandled exception. System.TypeInitializationException: The type initializer for '<StartupCode$App>.$Program' threw an exception.
---> System.TypeInitializationException: The type initializer for '<StartupCode$Funogram-Telegram>.$Funogram.Telegram.Bot' threw an exception.
---> System.MissingMethodException: Method not found: 'Void BotConfig..ctor(System.String, Microsoft.FSharp.Core.FSharpOption`1<Int64>, Microsoft.FSharp.Core.FSharpOption`1<Int32>, Microsoft.FSharp.Core.FSharpOption`1<Int32>, Microsoft.FSharp.Core.FSharpOption`1<System.Collections.Generic.IEnumerable`1<System.String>>, System.Uri, System.Net.Http.HttpClient)'.
--- End of inner exception stack trace ---
at Funogram.Telegram.Bot.get_defaultConfig()
at <StartupCode$App>.$Program..cctor() in /home/fulcanelly/code/.../App/Program.fs:line 7
--- End of inner exception stack trace ---
at Program.main(String[] _arg1)
Aborted (core dumped)
It seems like something missing or wrong version used.
So there is my App.fsproj wich may cause this:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="Program.fs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Library\Library.fsproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="FunHttp" Version="1.0.0" />
<PackageReference Include="Funogram" Version="2.0.3" />
<PackageReference Include="Funogram.Telegram" Version="4.4.0" />
<PackageReference Update="FSharp.Core" Version="4.7.1" />
</ItemGroup>
</Project>
Dolfik1 commented
I have successfully build this project:
Sample.zip
You also can try to update Funogram.Telegram to 4.4.2.3
fulcanelly commented
OK, after update sample bot started to work