Compare commits
No commits in common. "4b6bb780d43391a5bda0082bd54ea1550a5e21ff" and "bb96bcde612287652ebbeffbae73a6758af7bcd6" have entirely different histories.
4b6bb780d4
...
bb96bcde61
@ -1,14 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Configuration;
|
|
||||||
using Matrix.Sdk;
|
|
||||||
|
|
||||||
namespace TeleTok
|
|
||||||
{
|
|
||||||
public class MatrixListener
|
|
||||||
{
|
|
||||||
public void RunListener()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
68
Program.cs
68
Program.cs
@ -10,84 +10,26 @@ namespace TeleTok
|
|||||||
.AddJsonFile("config.json", true)
|
.AddJsonFile("config.json", true)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
// Value to see what bot mode to run in
|
|
||||||
public static string botMode = config.GetSection("TeleTokConf:botMode").Value;
|
|
||||||
|
|
||||||
// Telegram bot config
|
|
||||||
public static string token = config.GetSection("TeleTokConf:token").Value;
|
public static string token = config.GetSection("TeleTokConf:token").Value;
|
||||||
public static string ptInstance = config.GetSection("TeleTokConf:ptInstance").Value;
|
public static string ptInstance = config.GetSection("TeleTokConf:proxitokInstance").Value;
|
||||||
|
|
||||||
// Matrix bot config
|
|
||||||
public static string matrixAddress = config.GetSection("TeleTokConf:matrixAddress").Value;
|
|
||||||
public static string mBotUser = config.GetSection("TeleTokConf:mBotUser").Value;
|
|
||||||
public static string mBotPass = config.GetSection("TeleTokConf:mBotPass").Value;
|
|
||||||
|
|
||||||
static async Task Main(string[] args)
|
static async Task Main(string[] args)
|
||||||
{
|
|
||||||
//Checks to see what mode to run the bot in
|
|
||||||
|
|
||||||
if(botMode == "telegram")
|
|
||||||
{
|
{
|
||||||
//Checks if the config json data is valid
|
//Checks if the config json data is valid
|
||||||
if(ConfigCheck(token) == false)
|
if(token == "" || token == null || token == "INSERT TOKEN HERE")
|
||||||
{
|
{
|
||||||
LogMessage("Telegram bot token is invalid! Exiting...");
|
LogMessage("Telegram bot token is invalid! Exiting...");
|
||||||
}
|
}
|
||||||
else if(ConfigCheck(ptInstance) == false)
|
else if(ptInstance == "" || ptInstance == null || ptInstance == "PROXITOK INSTANCE URL")
|
||||||
{
|
{
|
||||||
LogMessage("Proxitok instance is invalid! Exiting...");
|
LogMessage("Proxitok instance is invalid! Exiting...");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TelegramListener tListener = new TelegramListener();
|
TelegramListener listener = new TelegramListener();
|
||||||
LogMessage("Now listening...");
|
LogMessage("Now listening...");
|
||||||
|
|
||||||
tListener.RunListener();
|
listener.RunListener();
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(botMode == "matrix")
|
|
||||||
{
|
|
||||||
//Checks if the config json data is valid
|
|
||||||
if(ConfigCheck(matrixAddress) == false)
|
|
||||||
{
|
|
||||||
LogMessage("Synapse address is invalid! Exiting...");
|
|
||||||
}
|
|
||||||
else if(ConfigCheck(mBotUser) == false)
|
|
||||||
{
|
|
||||||
LogMessage("Matrix bot username is invalid! Exiting...");
|
|
||||||
}
|
|
||||||
else if(ConfigCheck(mBotPass) == false)
|
|
||||||
{
|
|
||||||
LogMessage("Matrix bot password is invalid! Exiting...");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MatrixListener mListener = new MatrixListener();
|
|
||||||
LogMessage("Now listening...");
|
|
||||||
|
|
||||||
mListener.RunListener();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LogMessage("Bot mode is not configured! Enter either \'telegram\' or \'matrix\'");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool ConfigCheck(string confItem)
|
|
||||||
{
|
|
||||||
if(confItem == "" || confItem == null
|
|
||||||
|| confItem == "INSERT TOKEN HERE"
|
|
||||||
|| confItem == "PROXITOK INSTANCE URL"
|
|
||||||
|| confItem == "SYNAPSE SERVER URL"
|
|
||||||
|| confItem == "MATRIX BOT USERNAMEL"
|
|
||||||
|| confItem == "MATRIX BOT PASSWORD")
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Matrix.Sdk" Version="1.0.7" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.2" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.2" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
|
||||||
<PackageReference Include="Telegram.Bot" Version="17.0.0" />
|
<PackageReference Include="Telegram.Bot" Version="17.0.0" />
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
{
|
{
|
||||||
"TeleTokConf": {
|
"TeleTokConf": {
|
||||||
"botMode": "telegram",
|
|
||||||
"token": "INSERT TOKEN HERE",
|
"token": "INSERT TOKEN HERE",
|
||||||
"ptInstance": "PROXITOK INSTANCE URL",
|
"proxitokInstance": "PROXITOK INSTANCE URL"
|
||||||
"matrixAddress": "SYNAPSE SERVER URL",
|
|
||||||
"mBotUser": "MATRIX BOT USERNAME",
|
|
||||||
"mBotPass": "MATRIX BOT PASSWORD"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user