Skip to content

Commit

Permalink
Successful using akka in bot as tiny https server that receive
Browse files Browse the repository at this point in the history
messages from telegram servers. Bot communicate with telegram servers
via local installed 3proxy through SOCKS. Thanks author of bot4
"Alfonso² Peterssen"
and issue bot4s/telegram#76
  • Loading branch information
AlexGruPerm committed Jul 2, 2019
1 parent 50dd503 commit 2e86690
Show file tree
Hide file tree
Showing 6 changed files with 314 additions and 655 deletions.
47 changes: 30 additions & 17 deletions src/main/resources/README.txt
Original file line number Diff line number Diff line change
@@ -1,25 +1,38 @@

--------------------------------------------------------------------------------------
KEYS:
C:\jdk1.8.0_181\bin\keytool -genkey -keyalg RSA -alias mtspredbot -keystore mtspredbot.jks -storepass 333333 -validity 360 -keysize 2048
C:\jdk1.8.0_181\bin\keytool -importkeystore -srckeystore mtspredbot.jks -destkeystore mtspredbot.p12 -srcstoretype jks -deststoretype pkcs12
C:\openssl\openssl pkcs12 -in mtspredbot.p12 -out mtspredbot.pem

C:\jdk1.8.0_181\bin\keytool -genkey -keyalg RSA -alias mtspredbot -keystore mtspredbotjks.jks -storepass XXXXXXXXXXXXXXX -validity 360 -keysize 2048
C:\jdk1.8.0_181\bin\keytool -importkeystore -srckeystore mtspredbotjks.jks -destkeystore mtspredbotkcs.p12 -srcstoretype jks -deststoretype pkcs12
C:\openssl\openssl pkcs12 -in C:\tcert\mtspredbotkcs.p12 -out C:\tcert\mtspredbot.pem -nokeys
manually edit mtspredbot.pem and stay only public cert:

--------------------------------------------------------------------------------------
ngrok authkey XXXXXXXXXXXXXXXXXXXX
Authtoken saved to configuration file: C:\Users\Administrator/.ngrok2/ngrok.yml
ngrok http 8443
Bag Attributes
friendlyName: mtspredbot
localKeyID:
...
-----BEGIN CERTIFICATE-----
hexstaffhere
...
-----END CERTIFICATE-----

Session Status online
Account (Plan: Free)
Version 2.3.30
Region United States (us)
Web Interface http://127.0.0.1:4040
Forwarding https://59913958.ngrok.io -> http://localhost:8443
--------------------------------------------------------------------------------------
control.conf

teleg {
token="xxxxxxxxxxx"
chatid=111
user_admin=222
webhook_port=8443
webhookUrl="https://12.34.56.78:8443"
keyStorePassword=333333
}

val baseUrl = "http://VDS ip:8443"
val client = new AkkaHttpClient(botToken)
override val port = 8443
override val webhookUrl = "https://59913958.ngrok.io"
cassandra {
src {
ip="12.34.56.78"
dc="datacenter1"
}
}

--------------------------------------------------------------------------------------
4 changes: 2 additions & 2 deletions src/main/resources/logback.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
<level>TRACE</level>
</filter>
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
Expand All @@ -17,7 +17,7 @@
</encoder>
</appender>

<root level="INFO">
<root level="TRACE">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</root>
Expand Down
16 changes: 1 addition & 15 deletions src/main/scala/mtspredbot/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -53,32 +53,18 @@ object Main extends App {
throw e
}


//(Long) Polling
//val bot = new telegBot(log, config, sessSrc)
//Webhook
val bot = new telegBotWH(log, config, sessSrc)
val eol = bot.run



def SeesionConnectedCheck(isClosed :Boolean) :String =
!isClosed==true match {case true => "connected" case false => "disconnected"}


/*
bot.sendMessageTest(
"""
Bot "mtsPredBot" started and ready to communicate.
You can use command /help to see possible commands.
Cassandra DB - """ + SeesionConnectedCheck(sessSrc.sess.isClosed) + """ """+sessSrc.getIpDc+"""
""".stripMargin)
*/

println("Press [ENTER] to shutdown the bot, it may take a few seconds...")
scala.io.StdIn.readLine()
log.info("~~~~~~~~~~~~~~~~~~~~~~~~ SHUTDOWN TELEGRAM BOT ~~~~~~~~~~~~~~~~~~~~~~~~")
sessSrc.sess.close()
//sessSrc.sess.close()
bot.shutdown()
Await.result(eol, Duration.Inf)
}
112 changes: 0 additions & 112 deletions src/main/scala/mtspredbot/ScalajHttpClientMy.scala

This file was deleted.

0 comments on commit 2e86690

Please sign in to comment.