Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
T
TeleLlama3 Bot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mohamadbashar.disoki
TeleLlama3 Bot
Commits
9b53736c
Commit
9b53736c
authored
Apr 29, 2024
by
Mohamad Bashar Desoki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Init Telegram Bot
parents
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
143 additions
and
0 deletions
+143
-0
.gitignore
.gitignore
+39
-0
pom.xml
pom.xml
+39
-0
Bot.java
src/main/java/org/example/Bot.java
+45
-0
Main.java
src/main/java/org/example/Main.java
+13
-0
log4j.properties
src/main/resources/log4j.properties
+7
-0
No files found.
.gitignore
0 → 100644
View file @
9b53736c
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store
\ No newline at end of file
pom.xml
0 → 100644
View file @
9b53736c
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
org.example
</groupId>
<artifactId>
BotTutorial
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<properties>
<maven.compiler.source>
17
</maven.compiler.source>
<maven.compiler.target>
17
</maven.compiler.target>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>
org.telegram
</groupId>
<artifactId>
telegrambots
</artifactId>
<version>
6.0.1
</version>
</dependency>
<dependency>
<groupId>
org.slf4j
</groupId>
<artifactId>
slf4j-log4j12
</artifactId>
<version>
1.7.6
</version>
<scope>
runtime
</scope>
</dependency>
<dependency>
<groupId>
log4j
</groupId>
<artifactId>
log4j
</artifactId>
<version>
1.2.17
</version>
<scope>
runtime
</scope>
</dependency>
</dependencies>
</project>
\ No newline at end of file
src/main/java/org/example/Bot.java
0 → 100644
View file @
9b53736c
package
org
.
example
;
import
org.telegram.telegrambots.bots.TelegramLongPollingBot
;
import
org.telegram.telegrambots.meta.api.methods.send.SendMessage
;
import
org.telegram.telegrambots.meta.api.objects.Update
;
import
org.telegram.telegrambots.meta.exceptions.TelegramApiException
;
public
class
Bot
extends
TelegramLongPollingBot
{
// https://core.telegram.org/bots/tutorial
@Override
public
String
getBotUsername
()
{
return
"Put your Telegram Username here"
;
}
@Override
public
String
getBotToken
()
{
return
"Put your Telegram Token here "
;
}
private
String
prompts
;
@Override
public
void
onUpdateReceived
(
Update
update
)
{
var
msg
=
update
.
getMessage
();
var
user
=
msg
.
getFrom
();
var
id
=
user
.
getId
();
System
.
out
.
println
(
user
.
getFirstName
()
+
" wrote "
+
msg
.
getText
());
}
public
void
sendText
(
Long
who
,
String
what
){
SendMessage
sm
=
SendMessage
.
builder
()
.
chatId
(
who
.
toString
())
//Who are we sending a message to
.
text
(
what
).
build
();
//Message content
try
{
execute
(
sm
);
//Actually sending the message
}
catch
(
TelegramApiException
e
)
{
throw
new
RuntimeException
(
e
);
//Any error will be printed here
}
}
}
\ No newline at end of file
src/main/java/org/example/Main.java
0 → 100644
View file @
9b53736c
package
org
.
example
;
import
org.telegram.telegrambots.meta.TelegramBotsApi
;
import
org.telegram.telegrambots.meta.exceptions.TelegramApiException
;
import
org.telegram.telegrambots.updatesreceivers.DefaultBotSession
;
public
class
Main
{
public
static
void
main
(
String
[]
args
)
throws
TelegramApiException
{
TelegramBotsApi
botsApi
=
new
TelegramBotsApi
(
DefaultBotSession
.
class
);
botsApi
.
registerBot
(
new
Bot
());
}
}
\ No newline at end of file
src/main/resources/log4j.properties
0 → 100644
View file @
9b53736c
# Root logger option
log4j.rootLogger
=
ERROR, stdout
# Direct log messages to stdout
log4j.appender.stdout
=
org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target
=
System.out
log4j.appender.stdout.layout
=
org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern
=
%d{HH:mm:ss} %-5p %c{1}:%L - %m%n
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment