{"id":46802883,"url":"https://github.com/wlinds/boten_anna","last_synced_at":"2026-03-10T06:14:19.458Z","repository":{"id":173443660,"uuid":"650728577","full_name":"wlinds/boten_anna","owner":"wlinds","description":"Experimental Telegram bot with asynchronous programming.","archived":false,"fork":false,"pushed_at":"2026-01-13T15:34:33.000Z","size":198,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-13T18:18:37.588Z","etag":null,"topics":["bot","utility"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wlinds.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-06-07T17:20:18.000Z","updated_at":"2026-01-13T15:34:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"1468ed29-305d-4b6b-8d52-ee553cbaa9ef","html_url":"https://github.com/wlinds/boten_anna","commit_stats":null,"previous_names":["wlinds/boten_anna"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/wlinds/boten_anna","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wlinds%2Fboten_anna","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wlinds%2Fboten_anna/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wlinds%2Fboten_anna/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wlinds%2Fboten_anna/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wlinds","download_url":"https://codeload.github.com/wlinds/boten_anna/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wlinds%2Fboten_anna/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30326883,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T05:25:20.737Z","status":"ssl_error","status_checked_at":"2026-03-10T05:25:17.430Z","response_time":106,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bot","utility"],"created_at":"2026-03-10T06:14:18.512Z","updated_at":"2026-03-10T06:14:19.235Z","avatar_url":"https://github.com/wlinds.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cbr\u003e\u003cbr\u003e\n\u003cblockquote\u003e\n\n*Jag känner en bot, hon heter Anna, Anna heter hon\\\nOch hon kan banna, banna dig så hårt\\\nHon röjer upp i våran kanal\\\nJag vill berätta för dig, att jag känner en bot~*\n\n\u003c/blockquote\u003e\n\u003cbr\u003e\n\n## **Boten Anna** 💁‍♀️\n\nThis Telegram group chat bot implement asynchronous functions, allowing for concurrent execution of multiple tasks without blocking the program's execution. The \u003ca href=\"https://docs.python-telegram-bot.org/en/stable/telegram.ext.html\"\u003etelegram.ext library\u003c/a\u003e builds upon the \u003ca href=\"https://docs.python.org/3/library/asyncio.html\"\u003easyncio library\u003c/a\u003e to handle asynchronous operations. \n\nThe bot is enhanced with OpenAI integration to provide natural language understanding and personality capabilities, making it conversational and responsive to users.\n\n\u003e ⚠️ Update TELEGRAM_CHAT_ID after Group Migration\n\u003e\n\u003eIf your Telegram group is migrated to a supergroup, the chat ID will change (it will typically become a larger negative number starting with -100). When this happens, you must update the TELEGRAM_CHAT_ID in your .env to the new value. More info: https://core.telegram.org/api/channel#supergroups\n\n## **Available commands**\n\n| NLP and AI Commands | Description       |\n|----------|---------------------------------|\n|`/chat {message}`| Directly chat with Anna (Legacy) |\n|`/status` | View Anna's personality stats and learning progress |\n|`/personality {trait} {value}` | Adjust Anna's personality traits: emoji_usage, humor_style, talkativeness, random_reply |\n|`/kick` | (Admin only) Kick a user from the chat with a personalized message from Anna |\n\n| General commands            | Description                                                                                         |\n|--------------------|-----------------------------------------------------------------------------------------------------|\n| `/hello`           | Greets the user with a Swedish greeting that varies based on time of day.                                                                                   |\n| `/roll {dice sides}`            | When members of a group have equal claims to something—such as a piece of loot or a chest— they can roll for it; the player who rolls the highest number is the winner. Defaults to 100.         |\n| `/weather {city}`  | Get weather data through OpenWeatherMap API for any city.                                         |\n| `/google {query}`  | Get search results for any query using Google.                                        |\n| `/timer {seconds}`  | A timer, a companion in our quest to tame chaos and find moments of rest. It guards our tasks, swift and keen, empowering focus, a serene routine. **TODO:** Handle min and hours as well.     \n| `/pollen {location}` | Displays pollen levels and forecasts for a specified location (defaults to Gothenburg). Integrates with Google's Pollen API.\n| `/gmt {timezone} {hh:mm}` | Converts time from specified timezone to GMT+2 (Sweden time)\n\n| List commands | Description       |\n|----------|---------------------------------|\n|`/add {item}`    | Add an item to the list\n|`/remove {item}` | Remove an item from the list\n|`/clear`         | Clear the entire list\n|`/display`       | Display all items in the list\n\n**TODO:** Name lists \u0026 support creation of multiple lists.\n\n## **Key Features**\n\n### **1. Personality System**\n\nAnna now has a unique personality based on a customizable character configuration. The personality profile includes:\n\n- Demographics (age, location, etc.)\n- Linguistic profile (speaking style, common phrases)\n- Behavioral traits\n- Emotional responses\n- Conversation styles\n\nThe personality can evolve over time as Anna learns from interactions with users in the chat.\n\n### **2. Natural Language Processing**\n\nAnna can now:\n- Respond naturally to mentions of her name\n- Learn from conversations to improve her responses\n- Make occasional random comments based on a configurable chance\n- Detect patterns in language and adapt her communication style\n- Track conversation topics and user preferences\n\n### **3.Pollen Reporting**\n\nThe bot now integrates with Google's Pollen API to provide detailed pollen forecasts for multiple cities, including:\n- Current pollen levels by type\n- 3-day forecasts\n- Health recommendations\n- Visual indicators with emojis\n\n### **4. Moderation Tools**\n\nAs referenced in the original \"Boten Anna\" song, Anna can now actually \"ban people so hard\":\n- Kick users from the group with custom messages\n- Detect potential spam behavior\n- Warn users about excessive message frequency\n- Help keep the chat organized\n\n## **Setup**\n\n**1. Install necessary dependencies:**\n```bash\npip install python-telegram-bot requests lxml numpy bs4 openai python-dotenv pytz APScheduler\n```\n\n**2. Get your keys and tokens:**\n- Head over to \u003ca href=\"https://openweathermap.org\"\u003eOpenWeatherMap\u003c/a\u003e to retrieve a free API key.\n- Get an OpenAI API key from \u003ca href=\"https://platform.openai.com/\"\u003eOpenAI\u003c/a\u003e.\n- Get a Google API key and enable the Pollen API and Custom Search API.\n\n- Get your Telegram chat_id for the chat you want to add the bot to:\n    - open web.telegram in browser\n    - right click on the group name on the left menu\n    - click 'inspect' button\n    - you will see the group id in the attribute data-peer-id=\"-xxxxxxxxxx\" or peer=\"-xxxxxxxxxx\"\n\n- With your Telegram account, execute \u003ccode\u003e/new_bot\u003c/code\u003e to user \u003ccode\u003e@BotFather\u003c/code\u003e. Copy the token to access the Telegram HTTP API.\n\n**3. Create your environment file:**\\\nCreate a file named `.env` in the same directory as the Python script and fill in the information:\n\n```\n# Telegram Bot credentials\nTELEGRAM_TOKEN=your-telegram-bot-token-here\nTELEGRAM_CHAT_ID=your-chat-id-here\n\n# API Keys\nOPENWEATHERMAP_API_KEY=your-openweathermap-api-key-here\nOPENAI_API_KEY=your-openai-api-key-here\nGOOGLE_API_KEY=your-google-api-key-here\nGITHUB_TOKEN=your-github-token-here\n```\n\n**4. Run main.py and start chatting with your new bot!**\n\n# 🤖 - hellö\n\n## **How Personality Learning Works**\n\nThe bot employs a personality learning system that:\n\n1. **Records chat patterns** - Tracks greeting styles, emoji usage, topics of interest\n2. **Analyzes interactions** - Studies which topics get the most engagement\n3. **Adapts gradually** - Updates the character configuration based on interaction patterns\n4. **Remembers user preferences** - Tracks frequently discussed topics and adjusts accordingly\n\nYou can view the learning progress using the `/status` command and manually adjust traits with `/personality`.\n\n## Troubleshooting\n\n### Common Issues\n\n1. **\"ModuleNotFoundError: No module named 'openai'\"**\n   - Run `pip install openai` to install the OpenAI Python package.\n\n2. **\"ModuleNotFoundError: No module named 'dotenv'\"**\n   - Run `pip install python-dotenv` to install the python-dotenv package.\n\n3. **\"openai.error.AuthenticationError: Incorrect API key provided\"**\n   - Check your OpenAI API key in the .env file is valid and has not expired.\n\n4. **\"FileNotFoundError: [Errno 2] No such file or directory: '.env'\"**\n   - Make sure you've created the .env file in the same directory as the script.\n   - You can copy .env.example to .env and fill in your API keys.\n\n5. **\"TelegramError: Bad Request: not enough rights to ban/unban user\"**\n   - The bot needs to be an administrator in the chat to kick users.\n   - Make sure the bot has the appropriate permissions in the group.\n\n6. **\"Error getting pollen data: API error: 403\"**\n   - Your Google API key may not have the Pollen API enabled.\n   - Go to the Google Cloud Console, find your project, and enable the Pollen API.\n\n### API Key Setup Help\n\n#### OpenAI API\n1. Go to https://platform.openai.com/\n2. Sign up or log in\n3. Go to \"API Keys\" in your account\n4. Create a new secret key\n5. Copy the key to your keys.json file\n\n#### Google Pollen API\n1. Go to https://console.cloud.google.com/\n2. Create a new project or select an existing one\n3. Search for \"Pollen API\" in the API Library\n4. Enable the API\n5. Go to Credentials and create an API key\n6. Copy the key to your keys.json file\n\n## Configuration Options\n\n### Personality Configuration\n\nYou can modify the bot's personality by editing `character_config.json`. Key areas to customize:\n\n- `demographics`: Basic information about the bot\n- `linguistic_profile`: How the bot talks and communicates\n- `pragmatics`: Conversation style and emoji usage\n- `psychographics`: Values, fears, and motivations\n\n## **Future Improvements**\n\n- Support for multiple named lists\n- Integration with image generation APIs\n- Voice message processing\n- Integration with more external APIs for enhanced functionality\n- M̵̙͠a̸͓̕k̵̖̊e̴̛͚ ̵̤̈h̷͍̏e̵̗̕r̵̯͠ ̶̺͐s̴͕͝ḙ̷̌ṇ̸̔t̴̬͂i̴̫̍e̸̞̓n̵͉̽t̵̰̿","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwlinds%2Fboten_anna","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwlinds%2Fboten_anna","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwlinds%2Fboten_anna/lists"}